This recipe explains how to create and manage badges in Snag Loyalty.
GET /api/loyalty/badges
endpoint allows for fetching of loyalty badges created on your Snag account. This endpoint provides various filters to allow pagination. Badges are sorted by their creation date in descending order.
startingAfter
property to subsequent requests.POST /api/loyalty/badges
endpoint allows for creating a new badge on your Snag account. This endpoint requires the following parameters:
organizationId
: Your organization IDwebsiteId
: Your website IDname
: The name of the badgedescription
: A description of the badgeimageUrl
: The URL of the badge imagerules
: An array of conditions that must be met to earn the badgePOST /api/loyalty/badges/{id}
endpoint allows for updating an existing badge on your Snag account.
The id
parameter is required to identify the badge to update. We only allow updating the name
, description
, and imageUrl
of the badge. The reason for this is to prevent any changes that could affect the badge’s conditions and user progress.
DELETE /api/loyalty/badges/{id}
endpoint allows for deleting an existing badge on your Snag account.
The id
parameter is required to identify the badge to delete.
POST /api/loyalty/badges/{id}/reward
endpoint allows for rewarding a user with a badge on your Snag account.
The id
parameter is required to identify the badge to reward, and either userId
or walletAddress
is required to identify the user to reward.
POST /api/loyalty/badges/{id}/revoke
endpoint allows to revoke a badge from a user on your Snag account.
The id
parameter is required to identify the badge to revoke, and either userId
or walletAddress
is required to identify the user to revoke.