GET
/
api
/
loyalty
/
rules
import SnagSolutions from '@snagsolutions/sdk';

const client = new SnagSolutions({
  apiKey: process.env['X_API_KEY'], // This is the default and can be omitted
});

async function main() {
  const rules = await client.loyalty.rules.list();

  console.log(rules.data);
}

main();
{
  "data": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174000",
      "name": "Loyalty Rule",
      "description": "Loyalty Rule Description",
      "endTime": "2023-10-01T12:34:56Z",
      "startTime": "2023-10-01T12:34:56Z",
      "rewardType": "points",
      "organizationId": "123e4567-e89b-12d3-a456-426614174001",
      "websiteId": "123e4567-e89b-12d3-a456-426614174002",
      "collectionAddress": "0x1234567890abcdef1234567890abcdef12345678",
      "type": "purchase",
      "frequency": "daily",
      "amount": 10,
      "createdAt": "2023-10-01T12:34:56Z",
      "updatedAt": "2023-10-05T15:30:00Z",
      "deletedAt": null,
      "mediaUrl": "https://assets.snagsolutions.io/media.png",
      "metadata": {
        "key": "value"
      },
      "loyaltyRuleChain": [
        {
          "id": "123e4567-e89b-12d3-a456-426614174001",
          "name": "My Rule Chain",
          "loyaltyRuleId": "123e4567-e89b-12d3-a456-426614174111",
          "loyaltyConditions": [
            {
              "id": "123e4567-e89b-12d3-a456-426614174001",
              "type": "rule",
              "description": "My Condition",
              "amount": 100,
              "repeatCount": 1,
              "requiredCount": 1,
              "csvUrl": "https://example.com/csv",
              "association": [
                {
                  "id": "123e4567-e89b-12d3-a456-426614174001",
                  "loyaltyRuleGroupId": "123e4567-e89b-12d3-a456-426614174001",
                  "loyaltyRuleId": "123e4567-e89b-12d3-a456-426614174111",
                  "loyaltyCurrencyId": "123e4567-e89b-12d3-a456-426614174001",
                  "loyaltyBadgeId": "123e4567-e89b-12d3-a456-426614174001",
                  "loyaltyRule": {
                    "name": "My Loyalty Rule"
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "hasNextPage": true
}

Authorizations

X-API-KEY
string
header
required

Query Parameters

organizationId
string

Unique identifier for the organization to filter by

Example:

"123e4567-e89b-12d3-a456-426614174001"

websiteId
string

Unique identifier for the website to filter by

Example:

"123e4567-e89b-12d3-a456-426614174002"

collectionAddress
string

Address of the collection to filter by

Example:

"0x1234567890abcdef1234567890abcdef12345678"

loyaltyRuleGroupId
string

ID of the loyalty rule group to filter results

Example:

"123e4567-e89b-12d3-a456-426614174004"

startingAfter
string

Pagination cursor to start after a specific resource ID

Example:

"123e4567-e89b-12d3-a456-426614174010"

limit
number
default:10

Maximum number of records to return (max 1000)

Required range: 1 <= x <= 1000
Example:

50

loyaltyRuleId

The IDs of the loyalty rule

Example:

"123e4567-e89b-12d3-a456-426614174001"

isActive
enum<string>

If true this will only return active rules, the rules for which the startTime is in the past and the endTime is in the future

Available options:
true,
false
Example:

true

includeLoyaltyRuleChains
enum<string>

If true this will only return loyalty rule chains

Available options:
true,
false
Example:

true

Response

200
application/json
200

The response is of type object.