Preview what an event would earn
POST /earn/preview
What would this event earn, now? Evaluates the published programme version in force against the event you describe and returns the points per rule, without booking anything: nothing is written, no Idempotency-Key is needed, and an unknown member is previewed as a new one. Publishable key OK for a generic preview (no external_id), which is privately cacheable for 60 seconds; naming a member needs a secret key and is never cached. A matched rule whose input you did not send is listed in skipped, never guessed, and accrues_as_sent is false when booking this exact event would not accrue as sent. An overwrite campaign the input cannot decide is 422 preview_input_required, because answering could misstate what the member earns.
Authorizations
Section titled “Authorizations ”Request Body
Section titled “Request Body ”What would this event earn? The body is a POST /v1/events body with every field optional, so an event you are about to book can be previewed as it is. Send at least one of amount, items or units. source_ref, idempotency_key, order_ref, email and phone are accepted and have no effect. type must be purchase if sent (anything else is 422 event_type_not_earnable). Naming a member (external_id, which needs the channel it lives on) previews that member and requires a secret key; an unknown member is previewed as a new one. channel and/or sales_channel without external_id is a generic preview, routed to a programme exactly as an event with those fields would be. occurred_at is honoured for a secret key (the rules are judged at that instant); a publishable key is always judged at the server’s now. tenant, if sent, must be the key’s own tenant. trigger narrows the preview to one trigger; omitted, every trigger the programme hooks is summed.
object
The sales channel this order came through, for programme routing. A key such as shopify:web: lower-case letters, digits and : . _ -, starting with a letter or digit, up to 64 characters. Optional. An order with none is keyed by its channel: a channel that already fits the key shape is the key as it is (acme:pos stays acme:pos); any other channel is lower-cased, each run of characters outside a-z 0-9 . _ - (a space or a : included) becomes one -, leading characters that are not a letter or digit are dropped, the result is cut to 64 characters and trailing - characters are dropped; if nothing is left the key is unknown. It does not name a programme, and a refund ignores it (a refund follows its order).
object
object
object
The programme to act in: its handle (for example vv) or its lower-case id. Optional on a workspace with one programme; on a workspace with several, a call that names none is refused with 400 program_required. A programme that is not this workspace’s is 404 not_found.
Responses
Section titled “ Responses ”The preview.
object
The programme that was previewed.
The instant the rules were judged at.
True when a member was named (secret key): their tier and cap headroom were applied.
The tier applied to a personalised preview; null for a generic one, or a member with none.
The sum of the listed rules.
object
Only rules that contributed. A rule an active overwrite campaign suppresses is not listed.
object
The rule’s name. A publishable key can see the names of the rules live now, so name them as you would show a customer.
The event trigger this rule hooks.
Spendable points this rule contributes (after the tier multiplier, for a member, and the cap).
Qualifying credits this rule contributes.
True when a cap reduced this rule’s earn. A generic preview, an unknown member and a member new to the programme are capped at the rule’s whole cap; a known member at what is left of it.
Matched rules that could not be evaluated for want of an input. Never guessed.
object
The input the rule reads that the request did not carry.
False when booking this exact event would be refused, stuck or credited differently: no channel was sent (an ingested event requires one; a member’s channel counts), a matched rule was skipped, no trigger was sent, the member would not be enrolled (opt-in programme), program names a programme other than the one ingest would route the event to (the claimant of the sales channel, else the default programme), or a publishable key sent an occurred_at that was ignored. A generic preview (no member) assumes the booker can earn: under opt_in enrollment, that they have joined. Not a promise of the exact figure: an order already pinned to another programme, a concurrent earn against a cap, an already-booked source_ref and a catalog channel’s collection data can still differ.
A malformed body, none of amount / items / units, an external_id without a channel, the program is malformed (not a lower-case programme id or a programme handle), or a workspace with several programmes was given no program and no routing input (channel / sales_channel) (program_required).
object
object
Example
not_foundExample
req_9f8e7d6c5b4a3210Missing or invalid API key or OAuth credential.
object
object
Example
not_foundExample
req_9f8e7d6c5b4a3210A publishable key named a member (publishable_key_forbidden), or an OAuth token lacks the loyalty:read scope needed to name one (insufficient_scope).
object
object
Example
not_foundExample
req_9f8e7d6c5b4a3210No published programme version is in force (program_not_published), tenant is not this credential’s tenant, or the program names no programme of this workspace (not_found).
object
object
Example
not_foundExample
req_9f8e7d6c5b4a3210type is not purchase (event_type_not_earnable), an overwrite campaign cannot be decided from the input sent (preview_input_required, details.needs names the input), or a value is malformed (the rule’s own code).
object
object
Example
not_foundExample
req_9f8e7d6c5b4a3210