Look up a membership by identifier
const url = 'https://api.loyx.se/partners/v1/memberships/lookup';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"identifier":"membership_id","value":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.loyx.se/partners/v1/memberships/lookup \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "identifier": "membership_id", "value": "example" }'Find a single membership in the authenticated company by one of six identifiers. The request body is {identifier, value}. identifier must be one of membership_id, user_id, qr_code, mobile_number, email, or national_id. membership_id and user_id match top-level UUID fields; mobile_number, email and national_id match entries in required_member_fields. The value format is validated per identifier type (UUID / E.164 / email / string).
Scanning a member’s QR code: use qr_code and send the scanned string exactly as read, with no client-side parsing. Both code generations are accepted — a rotating lx1_ token (current) and a bare member UUID (legacy) — and the API tells them apart itself, so no client change is needed when the legacy form is retired. A rotating token is short-lived: if it has expired or been superseded the response is 404 qr_code_not_resolvable, which means ask the member to refresh their code, as distinct from 404 membership_not_found, which means the person is not an active member of your company.
loyalty_program_type is points, stamps, or null — for a member on no resolvable program, or on a unit whose presentation has no value in this contract yet.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Body for POST /memberships/lookup — discriminator + value.
membership_id and user_id match top-level Membership fields.
qr_code is the raw string scanned off a member’s QR code, in either
generation: a lx1_ rotating token (v2) or a bare user_id UUID
(legacy v1). mobile_number, email, and national_id match
entries in required_member_fields.
object
Which field to look up by. One of membership_id, user_id, qr_code, mobile_number, email, national_id.
Identifier value. Format depends on identifier. For qr_code, pass the scanned string unchanged — the API tells the two QR generations apart on its own.
Responses
Section titled “Responses”The matching membership, in its polymorphic detail shape.
Detail response for a membership — flat across loyalty program types.
balance is the ledger’s projection, unconditional: points balance for
a points program, stamp count in the current cycle for a stamps program.
stamps_dates is populated only for a stamp card.
object
Program-agnostic primary value: points balance for points, stamp count in the current cycle for stamps.
Whether a reward-earned UI should be shown
Current cycle number (starts at 1)
Member’s full name
Membership id
Membership status
The program’s unit — what the balance number counts and how it renders.
For a currency unit (cashback) the balance is money in minor units, so
the unit also says which currency and how to format it, the same
minor_units + locale pair every price on this API carries. All three
are null for counter and card, whose balance is a plain count.
Owning user id
Example
{ "status": "active"}missing_token, invalid_authorization_header or invalid_token: get a new access token and retry once.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}insufficient_scope: the API key lacks the scope this route needs.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}No membership matches the provided identifier (membership_not_found), or the scanned QR token is expired or invalid (qr_code_not_resolvable).
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}Validation Error
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}rate_limit_exceeded: wait Retry-After seconds.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}internal_server_error or database_error (type internal_error): our fault. Retry with backoff; quote request_id.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}qr_code only — the QR token store is temporarily unreachable. Retry; never treat this as an expired code.
Standard error response format.
object
Error detail structure (Stripe-like format).
object
Machine-readable error code
One failing field of a validation error.
object
Why the value was refused
Dotted path of the field, e.g. items.0.unit_price.value
Human-readable error message
Error type category
Example generated
{ "error": { "code": "example", "details": [ { "message": "example", "param": "example" } ], "doc_url": "example", "message": "example", "param": "example", "type": "example" }, "request_id": "example"}