There's no sandbox, so every call reaches a real Loyalty program. How to test without changing real customers' points, sending emails or issuing live coupons.
The Loyalty API has no sandbox or test mode. Every request reaches a real Loyalty program, including requests sent from Try It on the reference pages, which use whatever GUID, API key or token you enter.
Use a separate test store
Test against a store you keep only for testing, with its own Loyalty GUID and API key (and, for v3.0 endpoints, its own store ID and API secret). To get one, contact your Yotpo Customer Success Manager or Yotpo support. Don't test against your live store: some calls change customers' point balances, issue real coupon codes in your ecommerce platform or send emails, and some can't be undone.
Keep the credentials in configuration, not in code, so you can switch from the test store to the live store without changing code.
Calls that are safe to repeat
These only read data:
- All
GETendpoints except User data, which emails a data export (see below). - Product Potential Points and its authenticated version (v3.0). They use
POSTbut only calculate.
Calls with side effects
| Endpoint | What happens | How to test it safely |
|---|---|---|
| Create/Update Customer Records | Creates a loyalty customer or updates an existing one. opted_in: true opts them in to the program. | Use example.com addresses. Remove test customers with Anonymize user when you're done. |
| Create Order | Records an order and awards points against your active campaigns (asynchronously). The spend and purchase count toward VIP tiers. There's no API to delete an order. | Use test customers. Reverse an order with Create Refund. |
| Create Refund | Records a refund and deducts the points the order earned. The API doesn't stop a refund larger than the order. | Refund test orders only. |
| Record Customer Action | Awards the points of the matching Custom Action campaign. | Use test customers. Correct balances with Adjust Points. |
| Adjust a Customer's Point Balance | Adds or removes points. Nothing stops a deduction from taking the balance below zero. | Use test customers, and re-check the balance with Fetch Customer Details. |
| Create Redemption | Deducts points (now, or when the coupon is used if you send delay_points_deduction) and creates a real, usable coupon in your ecommerce platform. | Use the test store. Coupons can't be deleted through the API; remove them in your ecommerce platform's admin. |
| Approve Redemption Cancellation | Cancels a redemption and returns its points to the customer. | Use redemptions you created for the test. |
| Upload Coupon Codes | Adds codes to a redemption option's pool; customers who redeem that option receive them. There's no API to remove codes. | Upload test codes only to an option in the test store. |
| Identify Referrer | Creates the customer (if new) and their referral code. | Use example.com addresses. |
| Send Referral Emails | Emails a referral invitation to each address. | Send only to example.com addresses, or to an inbox you own. |
| Set Customer Birthday, Set/Update Customer Anniversary, Remove Customer Anniversary | Overwrites or removes the stored date that birthday and anniversary campaigns use. | Use test customers. |
| Add Customer Tags, Remove Customer Tags | Changes the customer's tags. | Use test customers. |
| Remove a Customer from an Action Based VIP Tier, Push Customer to Tier (v3.0) | Changes the customer's VIP tier. With AWARD_ENTRY_REWARDS, Push Customer to Tier also grants the tier's entry rewards. | Use test customers. |
| User data | Emails a data export to your Loyalty account's email address. | Run it only when you mean to. |
| Anonymize user | Anonymizes the customer's personal data. After this, the customer can't be found by email. | Only use addresses you created for the test. |
Points changes can also trigger the loyalty webhooks your store has set up (see Intro to Webhook Events) and anything that listens to them, such as emails from an email integration.
Test data rules
- Use
example.comemail addresses. The domain is reserved, so mail sent there is never delivered. When you need to receive an email, use an inbox you own. Never use real customers' addresses or IDs. - Opt test customers in (
opted_in: trueon Create/Update Customer Records) if you'll test Adjust Points: it returns422for customers who aren't opted in. - Points from orders and custom actions are awarded asynchronously. Wait a few seconds, then check with Fetch Customer Details and
with_history=true. - Keep a list of everything you create (customers, orders, coupon codes, redemptions) so you can clean up.
Clean up after a test
- Delete the coupons your test redemptions created in your ecommerce platform's admin.
- Anonymize each test customer with Anonymize user.
- Uploaded codes can't be removed through the API, so upload only codes you're happy to leave in the test store's pool.
Rate limits apply during tests
Test traffic counts against the same limits as live traffic. Run load tests against the test store, not the live one, and handle 429 responses as described in Errors.
Before you go live
- Your API key, GUID, API secret and access tokens are used only on your server and never reach the browser.
X-Customer-Tokenis generated on your server. - The live GUID and API key (and store ID and API secret) come from configuration.
- Your code backs off on
429and retries reads on500, but checks before retrying writes that award or deduct points (see Errors). - Your code logs
X-Request-Id(orexception_id) for failed calls. - Customer identifiers match what your platform sends to Yotpo (
customer_idis your platform's customer ID). -
action_namevalues match the Custom Action campaigns in the live store. - Test customers, orders and coupons were never created in the live store, or have been cleaned up.