The REST endpoint your server calls to mint a short-lived session token. Request, response, error codes, and an OpenAPI reference.
This is the single REST endpoint behind the SDK's getSessionToken flow. Call
it from your server with your secret API key; return the token to the SDK.
For the end-to-end setup and per-stack backend examples, see
Authentication.
The browser never holds your API key and never calls this endpoint directly.
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer token using your secret API key (af_live_*). |
Content-Type | Yes | application/json |
Body
| Field | Type | Required | Description |
|---|---|---|---|
avatarId | string | Yes | The avatar to start a session for. Use "default" for the public demo avatar, or one of your published avatar IDs. |
200 OK
The token is short-lived and single-use — the SDK requests a fresh one on each connect and reconnect.
| Status | Meaning | Fix |
|---|---|---|
400 | Bad Request | Missing or malformed avatarId. |
401 | Unauthorized | Missing or invalid API key — check the Authorization header. |
403 | Forbidden | Your plan isn't allowed to use this avatar (e.g. a premium avatar on a free plan). |
429 | Too Many Requests | Rate limit exceeded — retry after a short delay with backoff. |
Building the backend now? Authentication has copy-paste implementations for cURL, Node/Express, Next.js, and Python.