- Create test users and look them up, with their points balance, tier and tags
- Grant any of your sandbox merchant’s campaigns to a test user
- Simulate a purchase so it accrues points
- Set and remove tags on a test user
- Read a test user’s rewards and points ledger
POST /users, the regular signup endpoint) works only against api.thanxsandbox.com and returns 403 in production.
Authentication
All you need is the merchant app client ID from your sandbox credentials, sent as theX-ClientId header, together with Accept-Version: v4.0:
- No user token, OAuth flow or Partner API credentials are needed.
- Do not send an
Authorization: Bearerheader. When a valid Bearer token is present, the API registers a device for that token’s user as a side effect. - Your
X-ClientIdscopes every call to your sandbox merchant. You can only see and change users who are members of that merchant.
Before you start: test users
Create test users through consumer signup,POST /users, with your X-ClientId. Signup is what makes a user a member of your merchant, and every endpoint on this page only accepts members.
A new email becomes a member in the same request. If the email already belongs to a Thanx user, that user is added to your merchant asynchronously, shortly after the call. If a call right after signup returns 404 User not found, retry using the polling schedule below.
Send phone numbers in E.164 format (for example +14157582345). Thanx normalizes phones to E.164 when it stores them and when GET /users matches them, and sending E.164 makes sure the number is parsed with the right country code.
Use the id from the POST /users response (or from GET /users) as user_id everywhere below.
Endpoints
Read flows
Look up a user
Find a test user by email, phone oruser_id. The response includes the user’s loyalty block (points balance and tier) and their tags at your merchant. Always pass a filter for lookups: listing every member is slow on merchants with many users.
Check a user’s rewards
To pass more than one state, use bracket notation (states[]=available&states[]=active):
Check a user’s points
The points ledger returns the current balance and every entry that moved points, newest first:List campaigns
GET /campaigns lists the campaigns you can grant. Sandbox provisioning seeds one granted campaign per reward template on your merchant.
Write flows
Grant a reward
Pass a campaignid from GET /campaigns and a member’s user_id. The reward is issued immediately and the response (201) contains it.
Accrue points with a purchase
POST /purchases queues a synthetic purchase and returns 201 with {}. It is processed asynchronously and can take 15 to 30+ minutes in sandbox. Points accrue according to your sandbox merchant’s points configuration.
The body needs your merchant’s ID and one of its locations. merchant_id is on every campaign returned by GET /campaigns, and location_id comes from GET /locations, which also works with your X-ClientId alone. A location from another merchant returns 404 Location not found.
If the user isn’t a member of the merchant,
POST /purchases returns 403 FORBIDDEN with the generic message, not a 404.Set and remove tags
400 key is already set by another source.
Recipes
Seed a test account with a reward
1
Create the user
POST /users with a new email. Keep the id from the response.2
Confirm membership
GET /users?user_id={id} returns the user. A new email is a member right away. If the email already existed, retry on the polling schedule.3
Pick a campaign
GET /campaigns and pick a campaign id.4
Grant it
POST /rewards/grant with that campaign_id and user_id.5
Confirm
GET /users/{user_id}/rewards?states[]=available shows the new reward.Confirm a purchase accrued points
1
Note the starting balance
GET /users/{user_id}/points_transactions and note points_balance.2
Simulate the purchase
POST /purchases for the user, with merchant_id from GET /campaigns and a location_id from GET /locations. Expect 201 and {}.3
Wait for processing
Allow 15 to 30+ minutes. Re-check on the polling schedule.
4
Confirm
GET /users/{user_id}/points_transactions shows a new Issue entry with a purchase_id, and a higher points_balance.Test tag-driven behavior
1
Set the tag
PUT /users/{user_id}/tags with the key and values your test needs.2
Confirm
GET /users?user_id={user_id} lists the tag under tags.3
Clean up
DELETE /users/{user_id}/tags?key=... when the test is done.Polling schedule
Sandbox work runs asynchronously, so some checks need a retry. When you re-check a result:- Wait at least 60 seconds before the first check.
- Back off: start at 60 seconds and double the wait, up to a 5-minute cap.
- Stop after about 45 minutes in total. If the result still isn’t there, contact Developer Support with the user
idand the time of the call.
GET /users returns 200 with an empty users array when nothing matches, so count your attempts instead of waiting for an error.