E-commerce Integration
An online shop can sign its customers up for a loyalty card at checkout or in its customer account, and give them a link that adds the card to Apple Wallet or Google Wallet. One request does both: POST /api/v1/customers/enroll returns the card's permanent wallet link and a QR code of it.
How the shop fits in
- The shop is a location — Create the online shop as a location of the merchant, like a branch. Every enrollment is recorded against that location, so sign-ups from the shop show up separately from those in your stores.
- The shop picks the card — Send the card_id of the card (card template) the customer joins. The card's data collection settings decide which customer fields are required.
- One token per shop — Use the shop location's system-user token. It fixes the merchant and the location, so the shop cannot enroll at another location.
Which token to use
| Token | location_id in the body | Result |
|---|---|---|
| Location system user (recommended) | Omit it, or send the token's own location | The token's location is used. A different location_id answers 403 LOCATION_NOT_AUTHORIZED. |
| Merchant owner | Required | The location must belong to one of the owner's merchants. Without it: 400 MISSING_LOCATION_ID. |
Get a token from POST /api/v1/auth/login, as for every other endpoint (see Authentication). The card and the location must belong to the token's merchant.
Enrolling a customer
Send the customer's details with the card_id. Phone numbers are validated for the merchant's country and stored in E.164 format.
Request body
card_id— Required. UUID of the card to join.name— Required. Customer name, 1–100 characters.phone, email, birthday, gender— As the card's data collection settings require. A missing required field, a phone that is not valid for the merchant's country, or a gender the card does not offer answers 400 VALIDATION_ERROR with one entry per field in error.details.errors.location_id— UUID of the shop location. Required with an owner token (see above).locale— The customer's language: en, es, fr, tr or ru. Any other value is 400 VALIDATION_ERROR. Default en.marketing_consent— Stored on the customer's profile. Default true.send_welcome_email— Default true: a new customer with an email gets the welcome email with a link to their card. Send false if the shop sends its own message.
POST /api/v1/customers/enroll
Content-Type: application/json
Authorization: Bearer <shop_location_access_token>
{
"card_id": "3f6c1b2e-8d4a-4f6e-9b1c-2a7d5e8f0c41",
"name": "Aysel Mammadova",
"phone": "+994501234567",
"email": "aysel@example.com",
"locale": "en"
}HTTP/1.1 201 Created
{
"success": true,
"data": {
"customer_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"card_instance_id": "67fcc4ce-f05a-423c-96bc-ab07b2d25000",
"created": true,
"wallet_url": "https://cards.forloy.com/w/1~67fcc4ce-f05a-423c-96bc-ab07b2d25000~kDdbwdda3fxIUZyEvC2ztz6sOmCeTufBQPgH7icrl_E",
"qr_png_base64": "iVBORw0KGgoAAAANSUhEUgAAAQ4AAAEOCAYAAAB4sfml..."
},
"meta": {
"request_id": "req_abc123",
"timestamp": "2026-11-03T10:30:00.000Z"
}
}Response fields
customer_id— The customer.card_instance_id— The customer's card.created— true for a new card (201), false for an existing one (200).wallet_url— The card's permanent wallet link (see below).qr_png_base64— A PNG of a QR code of wallet_url, base64 without the data: prefix. null if the image could not be drawn; wallet_url is still valid.
Repeating a request
A repeat returns 200 with created: false and the same wallet_url only when the request carries a stable identifier that the card uses: an email, or a phone on a card that collects phone (a phone sent to a card that does not collect it is ignored). The customer is matched by phone first, then by email. Nothing is overwritten: only profile fields that are still empty are filled in, and no welcome email is sent. Without an email or such a phone, every call creates a new customer and a new card. So always send the customer's email (or phone), and treat a timeout as an unknown outcome, not as a safe retry: retry only with the same email or phone.
HTTP/1.1 200 OK
{
"success": true,
"data": {
"customer_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"card_instance_id": "67fcc4ce-f05a-423c-96bc-ab07b2d25000",
"created": false,
"wallet_url": "https://cards.forloy.com/w/1~67fcc4ce-f05a-423c-96bc-ab07b2d25000~kDdbwdda3fxIUZyEvC2ztz6sOmCeTufBQPgH7icrl_E",
"qr_png_base64": "iVBORw0KGgoAAAANSUhEUgAAAQ4AAAEOCAYAAAB4sfml..."
},
"meta": {
"request_id": "req_def456",
"timestamp": "2026-11-03T10:31:00.000Z"
}
}The wallet link
wallet_url (https://cards.forloy.com/w/…) is permanent: it never expires and is the same for every call for this card. Send it in the order confirmation email, show it on the thank-you page or in the customer's account.
What the link does
- On an iPhone it opens the card in Apple Wallet.
- On an Android phone it opens Google Wallet to save the card.
- On a computer it shows a page with the card and a QR code of the same link, so the customer can scan it with their phone.
- In the in-app browsers of Instagram, Facebook and similar apps on iPhone, it shows that page with an Add to Apple Wallet button.
Treat the link as the customer's key
Anyone with the link can add this customer's card to a wallet. Show or send it only to that customer, and do not put it in analytics, URLs of public pages or logs.
Showing the QR code
qr_png_base64 is a PNG drawn at 6 px per module (scale 4). Its size is not fixed: the number of modules depends on the length of wallet_url. The PNG has no built-in quiet zone. Phones scan it reliably only if you follow these rules:
- Put it on a solid white background. The light squares of the PNG are transparent, so on a dark or coloured page the code cannot be scanned.
- Keep a white quiet zone of at least 4 modules on every side: 24 px at the natural size, or 4 × 6 px × your scale factor if you scale it.
- Do not crop it, recolour it, round its corners or put a logo on it.
- If you scale it, use whole multiples (2×, 3×) and image-rendering: pixelated, so the edges stay sharp.
<!-- Natural size (6 px per module), white background, quiet zone of 4 modules (24 px) on every side -->
<div style="display:inline-block; background:#fff; padding:24px">
<img
src="data:image/png;base64,{qr_png_base64}"
style="display:block"
alt="QR code: scan to add your loyalty card"
>
</div>
<p><a href="{wallet_url}">Add the card to your wallet</a></p>Rate limits
Per authenticated user (the principal behind the token, so all tokens of one user share it) and location: 30 requests per minute and 2000 per 24 hours. Both are fixed windows; the 24-hour window starts with the first counted request. The counters are kept per running server instance, so this is not a global bound across instances. Over the limit the answer is 429 RATE_LIMITED, and the message says when to retry. Every accepted request counts, repeats included.
Errors
Errors use the standard error format. A missing card and another merchant's card give the same 404, and so do a missing and a foreign location, so the endpoint does not reveal which ids exist.
| Code | HTTP Status | Meaning |
|---|---|---|
| VALIDATION_ERROR | 400 | The body or a field does not meet the card's requirements. See error.details.errors. |
| INVALID_JSON | 400 | The body is not valid JSON. |
| MISSING_LOCATION_ID | 400 | An owner token was used without location_id. |
| UNAUTHORIZED, TOKEN_EXPIRED | 401 | The token is missing, invalid or expired. |
| LOCATION_NOT_AUTHORIZED | 403 | location_id is not the token's location, or the location belongs to another system user. |
| ENROLLMENT_LOCATION_NOT_IN_SCOPE | 403 | The card is not offered at this location. |
| CARD_TEMPLATE_NOT_ACTIVE | 403 | The card is not active. |
| MERCHANT_NOT_ACTIVE | 403 | The merchant is not active. |
| OWNER_SELF_ENROLLMENT | 403 | The email belongs to the merchant owner's account. An owner cannot join their own card. |
| ENROLLMENT_TARGET_NOT_FOUND | 404 | The card or the location was not found for this token's merchant. |
| RATE_LIMITED | 429 | Too many requests for this user and location. Retry later. |
| WALLET_LINK_NOT_CONFIGURED | 503 | Enrollment is temporarily unavailable. Nobody was enrolled; retry later. |
Only POST (and the OPTIONS preflight) is served on /api/v1/customers/enroll. GET, HEAD, PATCH and DELETE on this path answer 405.