Skip to content

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.

  1. 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_...
  2. Install the SDK (optional — skip if you’re calling /v1 directly)

    Section titled “Install the SDK (optional — skip if you’re calling /v1 directly)”
    Terminal window
    npm i @tesseraloyalty/sdk
    import { TesseraClient } from '@tesseraloyalty/sdk';
    const tessera = new TesseraClient({
    secretKey: process.env.TESSERA_SECRET_KEY,
    environment: 'sandbox',
    });
  3. 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, "...": "..." }
    ]
    }
  4. Create-or-update, keyed on (channel, external_id) — channel defaults 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"
    }
  5. POST /v1/events requires a signed request — the SDK signs it for you with your connector’s signingSecret; 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
    }

    enqueued: true means the event was accepted and handed to the earn engine — accrual happens asynchronously, so the balance below may take a moment to reflect it.

  6. 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
    }
  7. POST /v1/redemptions requires an Idempotency-Key header.

    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" }