HTTP API

Loyalty

GET/api/v1/loyalty/campaigns
GET
/api/v1/loyalty/campaigns

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Query Parameters

q?string

Full-text search query applied to campaign description

page?integer

1-indexed page number

Formatint64
Range0 <= value
page_size?integer

Page size

Formatint64
Range0 <= value
sort_by?string

Sort field (created_at, updated_at, start_date, end_date)

sort_order?string

Sort order (asc or desc)

Value in

  • "asc"
  • "desc"
filter?array<string>

Additional filter expressions in the form field:operator:value

active_only?boolean

Only return active campaigns

Response Body

application/json

curl -X GET "https://example.com/api/v1/loyalty/campaigns"
{  "campaigns": [    {      "active": true,      "campaign_id": "string",      "campaign_type": "referral",      "created_at": "2019-08-24T14:15:22Z",      "description": "string",      "end_date": "2019-08-24T14:15:22Z",      "rewards": {        "referee_reward": null,        "referrer_reward": null      },      "rules": {        "allow_self_referral": true,        "attribution_window_days": 0,        "block_same_ip": true,        "custom_rules": [          "string"        ],        "max_referrals_per_user": 0,        "min_purchase_amount": 0,        "require_email_verification": true      },      "start_date": "2019-08-24T14:15:22Z",      "triggers": [        {          "action": "complete_referral",          "event_name": "string",          "filters": null        }      ],      "updated_at": "2019-08-24T14:15:22Z"    }  ],  "pagination": {    "has_more": true,    "page": 0,    "page_size": 0,    "total": 0  }}
POST/api/v1/loyalty/campaigns
POST
/api/v1/loyalty/campaigns

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to create a new campaign

Response Body

application/json

curl -X POST "https://example.com/api/v1/loyalty/campaigns" \  -H "Content-Type: application/json" \  -d '{    "campaign_id": "string",    "campaign_type": "referral",    "description": "string",    "rewards": {},    "rules": {      "attribution_window_days": 0    },    "triggers": [      {        "action": "complete_referral",        "event_name": "string"      }    ]  }'
{  "campaign": {    "active": true,    "campaign_id": "string",    "campaign_type": "referral",    "created_at": "2019-08-24T14:15:22Z",    "description": "string",    "end_date": "2019-08-24T14:15:22Z",    "rewards": {      "referee_reward": null,      "referrer_reward": null    },    "rules": {      "allow_self_referral": true,      "attribution_window_days": 0,      "block_same_ip": true,      "custom_rules": [        "string"      ],      "max_referrals_per_user": 0,      "min_purchase_amount": 0,      "require_email_verification": true    },    "start_date": "2019-08-24T14:15:22Z",    "triggers": [      {        "action": "complete_referral",        "event_name": "string",        "filters": null      }    ],    "updated_at": "2019-08-24T14:15:22Z"  }}
GET/api/v1/loyalty/campaigns/{campaign_id}
GET
/api/v1/loyalty/campaigns/{campaign_id}

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

campaign_id*string

Campaign ID

Response Body

application/json

curl -X GET "https://example.com/api/v1/loyalty/campaigns/string"
{  "campaign": {    "active": true,    "campaign_id": "string",    "campaign_type": "referral",    "created_at": "2019-08-24T14:15:22Z",    "description": "string",    "end_date": "2019-08-24T14:15:22Z",    "rewards": {      "referee_reward": null,      "referrer_reward": null    },    "rules": {      "allow_self_referral": true,      "attribution_window_days": 0,      "block_same_ip": true,      "custom_rules": [        "string"      ],      "max_referrals_per_user": 0,      "min_purchase_amount": 0,      "require_email_verification": true    },    "start_date": "2019-08-24T14:15:22Z",    "triggers": [      {        "action": "complete_referral",        "event_name": "string",        "filters": null      }    ],    "updated_at": "2019-08-24T14:15:22Z"  },  "stats": null}
PATCH/api/v1/loyalty/campaigns/{campaign_id}
PATCH
/api/v1/loyalty/campaigns/{campaign_id}

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

campaign_id*string

Campaign ID

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to update campaign configuration

Response Body

application/json

curl -X PATCH "https://example.com/api/v1/loyalty/campaigns/string" \  -H "Content-Type: application/json" \  -d '{}'
{  "campaign": {    "active": true,    "campaign_id": "string",    "campaign_type": "referral",    "created_at": "2019-08-24T14:15:22Z",    "description": "string",    "end_date": "2019-08-24T14:15:22Z",    "rewards": {      "referee_reward": null,      "referrer_reward": null    },    "rules": {      "allow_self_referral": true,      "attribution_window_days": 0,      "block_same_ip": true,      "custom_rules": [        "string"      ],      "max_referrals_per_user": 0,      "min_purchase_amount": 0,      "require_email_verification": true    },    "start_date": "2019-08-24T14:15:22Z",    "triggers": [      {        "action": "complete_referral",        "event_name": "string",        "filters": null      }    ],    "updated_at": "2019-08-24T14:15:22Z"  }}
DELETE/api/v1/loyalty/campaigns/{campaign_id}
DELETE
/api/v1/loyalty/campaigns/{campaign_id}

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

campaign_id*string

Campaign ID

Response Body

curl -X DELETE "https://example.com/api/v1/loyalty/campaigns/string"
Empty
GET/api/v1/loyalty/campaigns/{campaign_id}/analytics
GET
/api/v1/loyalty/campaigns/{campaign_id}/analytics

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

campaign_id*string

Campaign ID

Response Body

application/json

curl -X GET "https://example.com/api/v1/loyalty/campaigns/string/analytics"
{  "campaign_id": "string",  "end_date": "2019-08-24T14:15:22Z",  "start_date": "2019-08-24T14:15:22Z",  "stats": {    "conversion_rate": 0.1,    "total_conversions": 0,    "total_participants": 0,    "total_referrals": 0,    "total_rewards_distributed": 0.1  }}
POST/api/v1/loyalty/codes
POST
/api/v1/loyalty/codes

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to create a referral code

Response Body

application/json

curl -X POST "https://example.com/api/v1/loyalty/codes" \  -H "Content-Type: application/json" \  -d '{    "campaign_id": "string"  }'
{  "campaign_id": "string",  "referral_code": "string",  "referral_link": "string",  "user_id": "string"}
POST/api/v1/loyalty/events
POST
/api/v1/loyalty/events

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to track a loyalty event

Response Body

application/json

curl -X POST "https://example.com/api/v1/loyalty/events" \  -H "Content-Type: application/json" \  -d '{    "event_name": "string",    "user_id": "string"  }'
{  "event_id": "string",  "matched_campaigns": [    "string"  ],  "payouts": [    {      "beneficiary": "referrer",      "campaign_id": "string",      "created_at": "2019-08-24T14:15:22Z",      "paid_at": "2019-08-24T14:15:22Z",      "payout_id": "string",      "referral_id": "string",      "reward_type": "credit",      "status": "pending",      "transaction_id": "string",      "user_id": "string",      "value": 0.1    }  ],  "points_granted": 0,  "processed": true,  "referral": null}
POST/api/v1/loyalty/referrals
POST
/api/v1/loyalty/referrals

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to create a referral tracking record (signup attribution)

Response Body

application/json

curl -X POST "https://example.com/api/v1/loyalty/referrals" \  -H "Content-Type: application/json" \  -d '{    "referee_id": "string",    "referral_code": "string"  }'
{  "referral": {    "campaign_id": "string",    "context": null,    "converted_at": "2019-08-24T14:15:22Z",    "created_at": "2019-08-24T14:15:22Z",    "fsm_name": "string",    "referee_id": "string",    "referral_code": "string",    "referral_id": "string",    "referrer_id": "string",    "status": "pending"  }}
POST/api/v1/loyalty/referrals/validate
POST
/api/v1/loyalty/referrals/validate

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to validate a referral

Response Body

application/json

curl -X POST "https://example.com/api/v1/loyalty/referrals/validate" \  -H "Content-Type: application/json" \  -d '{    "referee_id": "string",    "referral_code": "string"  }'
{  "reasons": [    "string"  ],  "valid": true}
GET/api/v1/loyalty/rewards
GET
/api/v1/loyalty/rewards

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Query Parameters

page?integer

1-indexed page number

Formatint64
Range0 <= value
page_size?integer

Page size

Formatint64
Range0 <= value
active_only?boolean

Only return active rewards

Response Body

application/json

curl -X GET "https://example.com/api/v1/loyalty/rewards"
{  "pagination": {    "has_more": true,    "page": 0,    "page_size": 0,    "total": 0  },  "rewards": [    {      "active": true,      "created_at": "2019-08-24T14:15:22Z",      "description": "string",      "fulfillment_data": null,      "name": "string",      "points_cost": 0,      "reward_id": "string",      "stock": 0,      "updated_at": "2019-08-24T14:15:22Z"    }  ]}
POST/api/v1/loyalty/rewards
POST
/api/v1/loyalty/rewards

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to create a reward catalog item

Response Body

application/json

curl -X POST "https://example.com/api/v1/loyalty/rewards" \  -H "Content-Type: application/json" \  -d '{    "description": "string",    "name": "string",    "points_cost": 0,    "reward_id": "string"  }'
{  "reward": {    "active": true,    "created_at": "2019-08-24T14:15:22Z",    "description": "string",    "fulfillment_data": null,    "name": "string",    "points_cost": 0,    "reward_id": "string",    "stock": 0,    "updated_at": "2019-08-24T14:15:22Z"  }}
GET/api/v1/loyalty/rewards/{reward_id}
GET
/api/v1/loyalty/rewards/{reward_id}

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

reward_id*string

Reward ID

Response Body

application/json

curl -X GET "https://example.com/api/v1/loyalty/rewards/string"
{  "reward": {    "active": true,    "created_at": "2019-08-24T14:15:22Z",    "description": "string",    "fulfillment_data": null,    "name": "string",    "points_cost": 0,    "reward_id": "string",    "stock": 0,    "updated_at": "2019-08-24T14:15:22Z"  }}
PATCH/api/v1/loyalty/rewards/{reward_id}
PATCH
/api/v1/loyalty/rewards/{reward_id}

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

reward_id*string

Reward ID

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to update a reward catalog item

Response Body

application/json

curl -X PATCH "https://example.com/api/v1/loyalty/rewards/string" \  -H "Content-Type: application/json" \  -d '{}'
{  "reward": {    "active": true,    "created_at": "2019-08-24T14:15:22Z",    "description": "string",    "fulfillment_data": null,    "name": "string",    "points_cost": 0,    "reward_id": "string",    "stock": 0,    "updated_at": "2019-08-24T14:15:22Z"  }}
GET/api/v1/loyalty/users/{user_id}/codes
GET
/api/v1/loyalty/users/{user_id}/codes

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

user_id*string

User ID

Response Body

application/json

curl -X GET "https://example.com/api/v1/loyalty/users/string/codes"
{  "codes": [    {      "campaign_id": "string",      "created_at": "2019-08-24T14:15:22Z",      "id": "string",      "referral_code": "string",      "referral_link": "string",      "referrer": "string"    }  ]}
GET/api/v1/loyalty/users/{user_id}/dashboard
GET
/api/v1/loyalty/users/{user_id}/dashboard

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

user_id*string

User ID

Response Body

application/json

curl -X GET "https://example.com/api/v1/loyalty/users/string/dashboard"
{  "dashboard": {    "campaigns": [      {        "campaign_id": "string",        "referral_code": "string",        "stats": {          "conversion_rate": 0.1,          "paid_rewards": 0.1,          "pending_rewards": 0.1,          "total_clicks": 0,          "total_conversions": 0,          "total_signups": 0        }      }    ],    "recent_referrals": [      {        "campaign_id": "string",        "context": null,        "converted_at": "2019-08-24T14:15:22Z",        "created_at": "2019-08-24T14:15:22Z",        "fsm_name": "string",        "referee_id": "string",        "referral_code": "string",        "referral_id": "string",        "referrer_id": "string",        "status": "pending"      }    ],    "total_earnings": 0.1,    "total_points": 0,    "user_id": "string"  }}
GET/api/v1/loyalty/users/{user_id}/points/balance
GET
/api/v1/loyalty/users/{user_id}/points/balance

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

user_id*string

User ID

Response Body

application/json

curl -X GET "https://example.com/api/v1/loyalty/users/string/points/balance"
{  "balance": {    "balance": 0,    "lifetime_earned": 0,    "lifetime_redeemed": 0,    "updated_at": "2019-08-24T14:15:22Z",    "user_id": "string"  }}
POST/api/v1/loyalty/users/{user_id}/points/grant
POST
/api/v1/loyalty/users/{user_id}/points/grant

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

user_id*string

User ID

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to manually grant points

Response Body

application/json

curl -X POST "https://example.com/api/v1/loyalty/users/string/points/grant" \  -H "Content-Type: application/json" \  -d '{    "points": 0,    "reason": "string"  }'
{  "new_balance": 0,  "points_credited": 0,  "reason": "string",  "transaction_id": "string",  "user_id": "string"}
GET/api/v1/loyalty/users/{user_id}/points/history
GET
/api/v1/loyalty/users/{user_id}/points/history

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

user_id*string

User ID

Response Body

application/json

curl -X GET "https://example.com/api/v1/loyalty/users/string/points/history"
{  "total": 0,  "transactions": [    {      "amount": 0,      "balance_after": 0,      "campaign_id": "string",      "created_at": "2019-08-24T14:15:22Z",      "reason": "string",      "transaction_id": "string",      "transaction_type": "string",      "user_id": "string"    }  ]}
POST/api/v1/loyalty/users/{user_id}/points/redeem
POST
/api/v1/loyalty/users/{user_id}/points/redeem

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

user_id*string

User ID

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Request to redeem points

Response Body

application/json

curl -X POST "https://example.com/api/v1/loyalty/users/string/points/redeem" \  -H "Content-Type: application/json" \  -d '{    "points": 0,    "reward_id": "string"  }'
{  "fulfillment_data": null,  "new_balance": 0,  "points_spent": 0,  "redemption_id": "string",  "reward_id": "string",  "user_id": "string"}
GET/api/v1/loyalty/users/{user_id}/redemptions
GET
/api/v1/loyalty/users/{user_id}/redemptions

Authorization

bearer_token
AuthorizationBearer <token>

In: header

Path Parameters

user_id*string

User ID

Response Body

application/json

curl -X GET "https://example.com/api/v1/loyalty/users/string/redemptions"
{  "redemptions": [    {      "balance_after": 0,      "created_at": "2019-08-24T14:15:22Z",      "fulfillment_data": null,      "points_spent": 0,      "redemption_id": "string",      "reward_id": "string",      "transaction_id": "string",      "user_id": "string"    }  ]}

On this page