Overview

In some cases, you may need to manually update loyalty point balances outside the context of automated rules or spend actions. For example:

  • Resetting all user balances to zero.
  • Crediting or debiting points manually for a specific promotion or adjustment.

Snag provides two approaches for handling this: a no-code solution via the admin dashboard and a programmatic solution using the API.


Approaches

We provide a no-code solution for this via the admin dashboard. Note: this approach supports up to 250,000 balance changes per CSV upload.

Steps:

  1. Go to the admin dashboard: https://admin.snagsolutions.io.
  2. Navigate to the Loyalty page from the left-side menu.
  3. Click Update Balances (this opens the modal for updating user balances and provides a CSV template for uploading balance changes).
  4. Download and fill out the CSV template with the relevant balance changes.
  5. Upload the completed CSV file in the modal.
  6. Click Add to queue the balance changes. A rule will be created to represent the queued changes. If it does not appear immediately, refresh the page.
  7. Verify execution:
    • Click the eye icon on the created rule.
    • Compare the Rewards count to the number of rows in your CSV file. If they match, execution is complete.

API

For programmatic updates, use the POST /api/loyalty/transactions endpoint to create a loyalty transaction and update balances.

Endpoint: POST /api/loyalty/transactions

Request Body:

{
  "description": "An explanation for the manual balance adjustment",
  "loyaltyCurrencyId": "string",
  "entries": [
    {
      "walletAddress": "0x00",
      "direction": "debit",
      "amount": 0
    },
    {
      "walletAddress": "0x01",
      "direction": "credit",
      "amount": 100
    }
  ]
}
  • description: Explanation for the adjustment (e.g., “Reset balances to zero”).
  • loyaltyCurrencyId: The ID of the loyalty currency to update.
  • entries: A list of transactions specifying:
    • walletAddress: The wallet of the user whose balance is being adjusted.
    • direction: Either credit to add points or debit to remove points.
    • amount: The number of points to credit or debit.

Example Response:

{
  "code": 200,
  "message": "Values updated successfully."
}

Steps

  1. Prepare the JSON payload with your required adjustments.
  2. Send a POST request to the endpoint with your payload.
  3. Verify the response to ensure the transaction was processed successfully.

Summary

For flexibility and simplicity:

  • Use the Admin Dashboard for batch updates and non-technical workflows.
  • Use the API for programmatic and highly customized updates.

Both approaches ensure your loyalty balances are kept up to date with minimal effort.