Getting started
This walks the full earn → read → redeem journey against the sandbox environment
(https://sandbox.usetessera.io/v1), first with curl, then with the TypeScript SDK.
-
Get a sandbox key
Section titled “Get a sandbox key”Every tenant has two key pairs — one for sandbox, one for production — and each pair has a secret key (
sk_test_…/sk_live_…) and a publishable key (pk_test_…/pk_live_…). Your Tessera contact provisions these for your tenant; grab your sandbox secret key before continuing. Keep it server-side — never ship a secret key to a browser. See Tenancy & environments for the full key model.Terminal window export TESSERA_SECRET_KEY=sk_test_... -
Install the SDK (optional — skip if you’re calling
Section titled “Install the SDK (optional — skip if you’re calling /v1 directly)”/v1directly)Terminal window npm i @tesseraloyalty/sdkimport { TesseraClient } from '@tesseraloyalty/sdk';const tessera = new TesseraClient({secretKey: process.env.TESSERA_SECRET_KEY,environment: 'sandbox',}); -
Browse the reward catalogue
Section titled “Browse the reward catalogue”Non-personalized and cacheable — a publishable key can call this too.
Terminal window curl https://sandbox.usetessera.io/v1/rewards \-H "Authorization: Bearer $TESSERA_SECRET_KEY"200 {"points_label": "points","data": [{ "id": "b2b1...", "type": "value_fixed", "label": "$5 off", "mechanism": "function", "cost_points": 500, "...": "..." }]}const { pointsLabel, data: rewards } = await tessera.rewards.list(); -
Identify (or enroll) the member
Section titled “Identify (or enroll) the member”Create-or-update, keyed on
(channel, external_id)—channeldefaults to"api"if omitted.Terminal window curl -X POST https://sandbox.usetessera.io/v1/customers \-H "Authorization: Bearer $TESSERA_SECRET_KEY" \-H "Content-Type: application/json" \-d '{"external_id": "cust_5512","email": "ada@example.com","name": "Ada Lovelace"}'201 (first creation) {"customer_uuid": "c0ffee00-0000-4000-8000-000000000001","channel": "api","external_id": "cust_5512","created": true,"updated_at": "2026-07-24T12:00:00.000Z"}const customer = await tessera.customers.upsert({externalId: 'cust_5512',email: 'ada@example.com',name: 'Ada Lovelace',});console.log(customer.created ? 'enrolled' : 'updated', customer.customerUuid); -
Send an earning event
Section titled “Send an earning event”POST /v1/eventsrequires a signed request — the SDK signs it for you with your connector’ssigningSecret; a raw HTTP caller must compute the same HMAC. See Request signing for the header details.Terminal window curl -X POST https://sandbox.usetessera.io/v1/events \-H "Authorization: Bearer $TESSERA_SECRET_KEY" \-H "Content-Type: application/json" \-H "X-Loyalty-Signature: v1=<computed — see Request signing>" \-H "X-Loyalty-Timestamp: 1721000000" \-H "X-Loyalty-Nonce: 7c9e6679-7425-40de-944b-e07fc1f90ae7" \-H "Idempotency-Key: shopify:ord_9001-purchase" \-d '{"channel": "shopify","external_id": "cust_5512","type": "purchase","source_ref": "ord_9001","idempotency_key": "shopify:ord_9001-purchase","occurred_at": "2026-07-24T12:00:00Z","trigger": "payment_captured","amount": { "net_of_tax_shipping": 4200, "currency": "USD" }}'201 (accepted) {"event_id": "evt_...","customer_id": "c0ffee00-0000-4000-8000-000000000001","channel": "shopify","source_ref": "ord_9001","type": "purchase","status": "accepted","customer_created": false,"linked_via": "shopify","enqueued": true}const event = await tessera.events.ingest({type: 'purchase',channel: 'shopify',externalId: 'cust_5512',sourceRef: 'ord_9001',idempotencyKey: 'shopify:ord_9001-purchase',occurredAt: new Date(),trigger: 'payment_captured',amount: { netOfTaxShipping: 4200, currency: 'USD' },});console.log(event.status); // 'accepted' | 'duplicate'enqueued: truemeans the event was accepted and handed to the earn engine — accrual happens asynchronously, so the balance below may take a moment to reflect it. -
Read the member’s standing
Section titled “Read the member’s standing”Terminal window curl https://sandbox.usetessera.io/v1/customers/shopify/cust_5512/balance \-H "Authorization: Bearer $TESSERA_SECRET_KEY"200 {"customer_uuid": "c0ffee00-0000-4000-8000-000000000001","points_label": "points","spendable_balance": 42,"pending_spendable": 0,"qualifying_balance": 42,"active_holds": 0,"clawbacks_outstanding": 0,"available": 42}const member = tessera.member('cust_5512', { channel: 'shopify' });const balance = await member.balance();console.log(`${balance.available} ${balance.pointsLabel} available`); -
Redeem — place a hold, then finalize it
Section titled “Redeem — place a hold, then finalize it”POST /v1/redemptionsrequires anIdempotency-Keyheader.Terminal window curl -X POST https://sandbox.usetessera.io/v1/redemptions \-H "Authorization: Bearer $TESSERA_SECRET_KEY" \-H "Idempotency-Key: 3f29b6b0-9e0a-4b0e-8f0a-6a0d5e6c7b8a" \-H "Content-Type: application/json" \-d '{"option_id": "b2b1...","customer_channel": "shopify","customer_external_id": "cust_5512","requested_points": 500,"cart": { "channel": "api", "lines": [{ "line_id": "l1", "product_id": "sku_42", "collection_ids": null, "quantity": 1, "line_subtotal_cents": 4200 }] }}'201 {"redemption_id": "r3d3...","customer_uuid": "c0ffee00-0000-4000-8000-000000000001","option_id": "b2b1...","amount": 500,"discount_value_cents": 500,"mechanism": "function","state": "held","expires_at": "2026-07-27T12:00:00.000Z","created_at": "2026-07-24T12:00:00.000Z"}Then, once the order is placed:
Terminal window curl -X POST https://sandbox.usetessera.io/v1/redemptions/r3d3.../finalize \-H "Authorization: Bearer $TESSERA_SECRET_KEY" \-H "Content-Type: application/json" \-d '{ "source_channel": "shopify", "source_ref": "ord_9001" }'200 { "redemption_id": "r3d3...", "state": "finalized" }const redemption = await member.redeem({optionId: rewards.find((r) => r.kind === 'points_value')?.id,requestedPoints: 500,cart: { channel: 'api', lines: [{ lineId: 'l1', productId: 'sku_42', quantity: 1, lineSubtotalCents: 4200 }] },});// …order is placed…await redemption.finalize({ sourceChannel: 'shopify', sourceRef: 'ord_9001' });// …or, on an abandoned cart: await redemption.release();