POST
/
api
/
loyalty
/
badges
import SnagSolutions from '@snagsolutions/sdk';

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

const badge = await client.loyalty.badges.create({
  conditions: [{}],
  imageUrl: 'https://example.com/image.png',
  name: 'Example Badge',
  organizationId: '123e4567-e89b-12d3-a456-426614174222',
  websiteId: '123e4567-e89b-12d3-a456-426614174111',
});

console.log(badge.id);
{
  "id": "123e4567-e89b-12d3-a456-426614174333",
  "name": "Example Badge",
  "description": "Example description",
  "imageUrl": "https://example.com/image.png",
  "loyaltyConditions": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174333",
      "type": "rule",
      "description": "Example description",
      "amount": 10,
      "repeatCount": 5,
      "requiredCount": 5,
      "loyaltyRuleGroupId": "123e4567-e89b-12d3-a456-426614174333",
      "association": [
        {
          "loyaltyRule": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "name": "<string>"
          },
          "loyaltyBadge": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "name": "<string>"
          },
          "loyaltyRuleGroup": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "name": "<string>"
          },
          "loyaltyCurrency": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "name": "<string>"
          },
          "loyaltyLeaderboardView": {
            "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
            "name": "<string>"
          }
        }
      ],
      "loyaltyCurrencyId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "csvUrl": "https://example.com/file.csv"
    }
  ],
  "loyaltyBadgeUsers": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174333",
      "userId": "123e4567-e89b-12d3-a456-426614174222",
      "websiteId": "123e4567-e89b-12d3-a456-426614174111",
      "organizationId": "123e4567-e89b-12d3-a456-426614174222",
      "status": "active",
      "loyaltyBadgeId": "123e4567-e89b-12d3-a456-426614174333",
      "progress": "<any>"
    }
  ],
  "loyaltyRules": [
    {
      "id": "123e4567-e89b-12d3-a456-426614174333"
    }
  ]
}

Authorizations

X-API-KEY
string
header
required

Body

application/json

Body

Schema for creating a new badge.

Response

200
application/json

200

Response returned upon successful creation of the badge.