Authentication
Goal: authenticate a request against /v1 with the right key for the job.
- Pick your environment —
sandbox(https://sandbox.usetessera.io/v1) while building,production(https://api.usetessera.io/v1) once you’re live. See Tenancy & environments. - Pick your key:
- A secret key (
sk_test_…/sk_live_…) for anything running server-side — it can call every endpoint. Never expose it to a browser or mobile client. - A publishable key (
pk_test_…/pk_live_…) only if you need to read the catalogue or the tier ladder from somewhere untrusted — it can callGET /v1/rewardsandGET /v1/tiers, and make a generic earn preview (POST /v1/earn/previewwithoutexternal_id), and nothing else.
- A secret key (
- Send it as a bearer token on every request:
curl https://sandbox.usetessera.io/v1/rewards \ -H "Authorization: Bearer $TESSERA_SECRET_KEY"import { TesseraClient } from '@tesseraloyalty/sdk';
const tessera = new TesseraClient({ secretKey: process.env.TESSERA_SECRET_KEY, environment: 'sandbox',});Common errors
Section titled “Common errors”code | Status | Cause |
|---|---|---|
unauthorized | 401 | Missing, malformed, unrecognized, or revoked credential. |
publishable_key_forbidden | 403 | A publishable key called an endpoint that requires a secret key. |
insufficient_scope | 403 | The credential doesn’t carry the scope the endpoint requires. |
The SDK’s PublishableKeyForbiddenError is thrown pre-network when you try a secret-only
call with a publishable key — it never even reaches the wire.
See Errors & the envelope for the full code catalogue.