Testing your integration

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 GET endpoints except User data, which emails a data export (see below).
  • Product Potential Points and its authenticated version (v3.0). They use POST but only calculate.

Calls with side effects

EndpointWhat happensHow to test it safely
Create/Update Customer RecordsCreates 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 OrderRecords 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 RefundRecords 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 ActionAwards the points of the matching Custom Action campaign.Use test customers. Correct balances with Adjust Points.
Adjust a Customer's Point BalanceAdds 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 RedemptionDeducts 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 CancellationCancels a redemption and returns its points to the customer.Use redemptions you created for the test.
Upload Coupon CodesAdds 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 ReferrerCreates the customer (if new) and their referral code.Use example.com addresses.
Send Referral EmailsEmails 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 AnniversaryOverwrites or removes the stored date that birthday and anniversary campaigns use.Use test customers.
Add Customer Tags, Remove Customer TagsChanges 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 dataEmails a data export to your Loyalty account's email address.Run it only when you mean to.
Anonymize userAnonymizes 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.com email 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: true on Create/Update Customer Records) if you'll test Adjust Points: it returns 422 for 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

  1. Delete the coupons your test redemptions created in your ecommerce platform's admin.
  2. Anonymize each test customer with Anonymize user.
  3. 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-Token is generated on your server.
  • The live GUID and API key (and store ID and API secret) come from configuration.
  • Your code backs off on 429 and retries reads on 500, but checks before retrying writes that award or deduct points (see Errors).
  • Your code logs X-Request-Id (or exception_id) for failed calls.
  • Customer identifiers match what your platform sends to Yotpo (customer_id is your platform's customer ID).
  • action_name values 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.