Loyalty API
Loyalty API allows for building advanced gamification strategies that reward sustained engagement, thus driving retention and boosting app usage.
Loyalty API (part of the Audience API) is a high-throughput public RESTful API designed to support advanced gamification strategies. It helps track and reward specific audience behaviours aligned with key performance indicators tailored to your business needs.
Returns list of rewards, challenges and missions available to the authenticated user
GET /api/loyalty/config HTTP/1.1
Host: your.space.domain
Accept: */*
{
"message": "OK",
"data": {
"metrics": [
{
"id": "text",
"title": "text",
"media": "text",
"defaultValue": 1,
"minimumValue": 1,
"maximumValue": 1
}
],
"inventory": [
{
"id": "text",
"title": "text",
"items": [
{
"id": "text",
"title": "text",
"media": "text"
}
]
}
],
"challenges": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "text",
"subtitle": "text",
"notification": {
"display": "none",
"title": "text",
"message": "text"
},
"showInProfile": true,
"showInRail": true,
"time": {
"showInUI": true,
"from": 1,
"to": 1
},
"missions": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "text",
"type": "text",
"notification": {
"display": "none",
"title": "text",
"message": "text"
}
}
],
"rewards": [
{
"type": "metric",
"metricId": "text",
"metricQuantity": 1,
"inventorySetId": "text",
"inventoryItemId": "text"
}
]
}
]
}
}
Get user's metrics and inventory, as well as completed missions and challenges. If the profile doesn't exist, empty one will be created.
GET /api/loyalty/profile HTTP/1.1
Host: your.space.domain
Authorization: Bearer JWT
Accept: */*
{
"message": "OK",
"data": {
"metrics": {
"<metric_id>": 100
},
"inventory": {
"<inventory_set_id>": [
"<inventory_item_id>"
]
},
"challenges": {
"<challenge_id>": {
"isCompleted": false,
"missionsCompleted": [
"<mission_id>"
]
}
}
}
}
Returns an array of unread notifications for the autheticated user
GET /api/loyalty/notifications HTTP/1.1
Host: your.space.domain
Authorization: Bearer JWT
Accept: */*
{
"message": "OK",
"data": [
{
"id": "text",
"timestamp": 1,
"type": "challengeCompleted",
"display": "toast",
"title": "text",
"message": "text",
"payload": {
"challengeId": "123e4567-e89b-12d3-a456-426614174000",
"missionId": "123e4567-e89b-12d3-a456-426614174000",
"metricChanges": {
"<metric_id>": {
"oldValue": 100,
"newValue": 200
}
},
"inventoryChanges": {
"received": [
{
"setId": "<inventory_set_id",
"itemId": "<inventory_item_id>"
}
],
"lost": [
{
"setId": "<inventory_set_id",
"itemId": "<inventory_item_id>"
}
]
},
"milestoneChanges": {
"<milestone_set_id>": {
"oldValue": "<milestone_id>",
"newValue": "<milestone_id>"
}
}
}
}
]
}
Returns paginated transaction history of all achievements (challenges and missions) and rewards (metrics and inventory) for the authenticated user
GET /api/loyalty/history HTTP/1.1
Host: your.space.domain
Authorization: Bearer JWT
Accept: */*
{
"message": "OK",
"data": [
{
"id": "text",
"timestamp": 1,
"type": "challengeCompleted",
"payload": {
"challengeId": "123e4567-e89b-12d3-a456-426614174000",
"missionId": "123e4567-e89b-12d3-a456-426614174000",
"metricChanges": {
"<metric_id>": {
"oldValue": 100,
"newValue": 200
}
},
"inventoryChanges": {
"received": [
{
"setId": "<inventory_set_id",
"itemId": "<inventory_item_id>"
}
],
"lost": [
{
"setId": "<inventory_set_id",
"itemId": "<inventory_item_id>"
}
]
},
"milestoneChanges": {
"<milestone_set_id>": {
"oldValue": "<milestone_id>",
"newValue": "<milestone_id>"
}
}
}
}
]
}
ID of the coupon
GET /api/loyalty/coupons/{couponId} HTTP/1.1
Host: your.space.domain
Authorization: Bearer JWT
Accept: */*
{
"message": "OK",
"data": {
"id": "text",
"title": "text",
"link": "text",
"coupon_id": "text",
"coupon_type": "text",
"coupon_code": "text",
"showOnNotification": true
}
}
Use this method to report a rewardable action
<action_name>
POST /api/loyalty/action HTTP/1.1
Host: your.space.domain
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 140
{
"action": "<action_name>",
"data": {
"<prop_string>": "arbitrary string up to 1024 characters long",
"<prop_number>": 1000,
"<prop_boolean>": true
}
}
No content
Last updated
Was this helpful?