Skip to Content
TryItOn
DocsAPI ReferenceSDKsResources

Live Try-On Sessions API

Start, list, inspect and stop real-time virtual try-on sessions from your server, and how the backup stream keeps a shopper connected.

A session is one shopper's live stream. Your server starts it with the API key and sends the whole start response to the browser, where tryiton-live connects. Your server can also list, inspect and stop sessions. What a session costs is on Live Try-On Billing.

Before you start one

  • Open the camera first. The session holds a credit from the moment it starts, and a permission prompt can take a while.
  • Send the whole response to the browser, unchanged, and pass it to connectLiveTryOn. Don't pick fields out: tryiton-live reads clientSecret, connection and garment. The media token in it can only start a connection within 60 seconds.
  • Send end_user_id for signed-in shoppers. Each shopper then gets one stream: a reload or a second tab ends the previous session with endReason: "superseded", charged like any other end. Use an opaque id, not an email.
  • Send allowed_origin on the web. It locks the media token to pages on your site. Leave it out for native apps.
  • Send garment_id when you know the first garment. Its stream input comes back in the response, so the first frame doesn't wait on another call. Without it, the browser names a garment when it connects.

The order of the start checks. The first one that fails is the error you get:

  1. Parameters: 400, or 404 for an unknown garment_id.
  2. Live try-on switched off: 503 LiveTryonUnavailable.
  3. Account disabled: 403 Forbidden.
  4. At capacity, for accounts that haven't bought credits or a plan: 503 LiveTryonUnavailable.
  5. Already maxConcurrentSessions streams, not counting the shopper's own session that this start replaces: 429 LiveTryonBusy.
  6. Fewer than minCredits usable credits, or the first credit can't be held: 429 OutOfCredits.
  7. With end_user_id, the shopper's previous session is ended. A start refused above leaves it running.
  8. Two racing starts for the same end_user_id: 409 LiveSessionActive. Retry once.
  9. Starts racing past the stream cap: 429 LiveTryonBusy. The hold is returned.
  10. The media token or first garment couldn't be loaded: 503 LiveTryonUnavailable. The hold is returned.

Live starts never return ConcurrencyLimitExceeded: running photo try-ons don't block them.

Start a session

POST
/live/sessions

Authorization

bearerAuth
headerAuthorizationBearer <token>

Your API key from https://tryiton.now/app/developer, sent as Authorization: Bearer YOUR_API_KEY. Keep it on your server. A missing, malformed or unknown key is rejected with 403 Forbidden.

Request Body

application/json
  1. body
garment_id?|

A prepared garment to start with. Its stream input comes back in the response, so the first frame doesn't wait on another call. Without it, the device names a garment when it connects.

max_seconds?|

Cap for this session, from 10 to maxSeconds in GET /live/config (180 by default). Defaults to maxSeconds.

Range10 <= value <= 180
end_user_id?|

Your id for the end user: 1-100 letters, digits and _ . - @ :. One stream per end user: starting again ends their previous session.

Match^[\w.@:-]{1,100}$
allowed_origin?|

The browser origin the media token is locked to, e.g. https://shop.example.com (scheme matched case-insensitively, no path). Recommended for web integrations; leave it out for native apps.

Match^https?://[^/\s]+$
providers?array<>|

The streams the device's client can play; must include decart. Left out, the session starts on the primary stream and has the backup during connect. [decart, vidu] (tryiton-live 0.4+) may also start on the backup while the primary is down. [decart]: primary only, no backup.

Items1 <= items

Response Body

Session started. Hand this body to the device.

application/json
  1. response
ok*boolean
session*
clientSecret*string

Session-scoped secret for the device's calls. Never log or store it.

Match^[a-f0-9]{48}$
connection*

How the device reaches the media network. tryiton-live reads it; treat it as opaque.

secondsPerCredit*integer

Tick length for this session, fixed at start.

maxSeconds*integer

This session's cap.

secondsLeft*integer

Seconds this session can stream now, the lower of the credit balance and the session cap.

Range0 <= value
garment*|

The first garment with its stream input when garment_id was given, else null.

curl -X POST 'https://tryiton.now/api/v1/live/sessions' \  -H 'Authorization: Bearer YOUR_API_KEY' \  -H 'Content-Type: application/json' \  -d '{  "garment_id": "6b0827eba2f220ae7dd7c7fb",  "end_user_id": "shopper-42",  "allowed_origin": "https://shop.example.com",  "providers": [    "decart",    "vidu"  ]}'
Example Response
{  "ok": true,  "session": {    "id": "6b0828e5ed117d43a6d10ad1",    "status": "active",    "endReason": null,    "seconds": 0,    "creditsCharged": 0,    "endUserId": "shopper-42",    "apiKeyId": "6b0827eba2f220ae7dd7c7aa",    "refunded": false,    "creditsRefunded": 0,    "createdAt": "2026-11-26T12:21:57.402Z",    "endedAt": null  },  "clientSecret": "3f9c2a7b1e4d6f80a2c5e7b9d1f3a5c7e9b2d4f6a8c0e1b3",  "connection": {    "provider": "decart",    "model": "lucy-vton-latest",    "token": "ek_live_8f2b9c4d1a7e",    "backup": "vidu"  },  "secondsPerCredit": 3,  "maxSeconds": 180,  "secondsLeft": 117,  "garment": {    "id": "6b0827eba2f220ae7dd7c7fb",    "category": "clothing",    "subcategory": "tops",    "description": "a navy short-sleeve pique polo shirt",    "prompt": "Substitute the current top with a navy short-sleeve pique polo shirt shown in the reference image, matching its color, material, and fit.",    "enhancePrompt": true,    "items": null,    "createdAt": "2026-11-26T12:20:59.512Z",    "input": {      "prompt": "Substitute the current top with a navy short-sleeve pique polo shirt shown in the reference image, matching its color, material, and fit.",      "enhancePrompt": true,      "referenceImage": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBD"    }  }}

Backup stream

Sessions run on the primary stream. A backup stream steps in two ways:

  • During connect. When the primary stream fails for this shopper before the first frame, and the start response has a connection.backup, tryiton-live 0.4 or later moves the same session to the backup with failover. Same session, same id. Your server does nothing. This is on by default.
  • At start. While the primary stream is down, a start can go straight to the backup. This needs providers: ["decart", "vidu"] (your browser client is tryiton-live 0.4 or later) and a garment_id.

Send providers: ["decart"] to turn the backup off. You then get no failover, and a 503 while the primary is down. Billing is the same on both streams: a session that fails over is billed from its first backup frame, and the failed attempt is free. If your page sets a Content Security Policy, see the quickstart.

Get a session

GET
/live/sessions/{id}

Status and usage of one of your live sessions.

Authorization

bearerAuth
headerAuthorizationBearer <token>

Your API key from https://tryiton.now/app/developer, sent as Authorization: Bearer YOUR_API_KEY. Keep it on your server. A missing, malformed or unknown key is rejected with 403 Forbidden.

Path Parameters

id*string

A live session id from POST /live/sessions. Anything other than 24 hex characters is a 400.

Match^[a-fA-F0-9]{24}$

Response Body

The session.

application/json
  1. response
ok*boolean
session*
Example Request
curl -X GET 'https://tryiton.now/api/v1/live/sessions/6b0828e5ed117d43a6d10ad1' \  -H 'Authorization: Bearer YOUR_API_KEY'
Example Response
{  "ok": true,  "session": {    "id": "6b0828e5ed117d43a6d10ad1",    "status": "ended",    "endReason": "user",    "seconds": 9,    "creditsCharged": 5,    "endUserId": "shopper-42",    "apiKeyId": "6b0827eba2f220ae7dd7c7aa",    "refunded": false,    "creditsRefunded": 0,    "createdAt": "2026-11-26T12:21:57.402Z",    "endedAt": "2026-11-26T12:22:12.118Z"  }}

List sessions

GET
/live/sessions

Your account's live sessions started through the API, newest first, with the same fields as Get a session. Use it for usage reports and to reconcile billing: creditsCharged is what a session was charged, refunded and creditsRefunded show what was given back.

Pages hold up to limit sessions. When nextCursor is not null, pass it as cursor to get the next (older) page. Filters combine with AND.

Authorization

bearerAuth
headerAuthorizationBearer <token>

Your API key from https://tryiton.now/app/developer, sent as Authorization: Bearer YOUR_API_KEY. Keep it on your server. A missing, malformed or unknown key is rejected with 403 Forbidden.

Query Parameters

limit?integer

Sessions per page, from 1 to 100.

Range1 <= value <= 100
Default20
cursor?string

The nextCursor of the previous page.

Match^[a-fA-F0-9]{24}$
status?string

Only sessions with this status.

Value in"active""ended"
end_reason?string

Only sessions that ended for this reason.

Value in"user""idle""hidden""error""unload""out_of_credits""time_limit""stale""superseded""budget"
api_key_id?string

Only sessions started with this API key (its id, as in a session's apiKeyId).

Match^[a-fA-F0-9]{24}$
refunded?boolean

true: only sessions that were refunded (refunded: true). false is accepted and doesn't filter.

Response Body

One page of sessions, newest first.

application/json
  1. response
ok*boolean
sessions*array<>

Newest first.

nextCursor*|

Pass as cursor for the next (older) page; null on the last page.

Example Request
curl -X GET 'https://tryiton.now/api/v1/live/sessions?cursor=6b0828e5ed117d43a6d10ad1' \  -H 'Authorization: Bearer YOUR_API_KEY'
Example Response
{  "ok": true,  "sessions": [    {      "id": "6b0828e5ed117d43a6d10ad1",      "status": "ended",      "endReason": "user",      "seconds": 9,      "creditsCharged": 5,      "endUserId": "shopper-42",      "apiKeyId": "6b0827eba2f220ae7dd7c7aa",      "refunded": false,      "creditsRefunded": 0,      "createdAt": "2026-11-26T12:21:57.402Z",      "endedAt": "2026-11-26T12:22:12.118Z"    },    {      "id": "6b0828a1ed117d43a6d10ac4",      "status": "ended",      "endReason": "error",      "seconds": 0,      "creditsCharged": 0,      "endUserId": "shopper-17",      "apiKeyId": "6b0827eba2f220ae7dd7c7aa",      "refunded": true,      "creditsRefunded": 0,      "createdAt": "2026-11-26T12:20:51.880Z",      "endedAt": "2026-11-26T12:21:03.004Z"    }  ],  "nextCursor": "6b0828a1ed117d43a6d10ac4"}

The dashboard shows the same list under Developer API → Requests → Live. Only sessions started through the API are listed. Use end_reason=error to find streams that failed, and refunded=true for the ones given back.

Stop a session

POST
/live/sessions/{id}/stop

Ends a session from your server, for example when the end user leaves the page. Idempotent: stopping an ended session returns it unchanged. Ends with endReason: "user". No request body is needed. The held credit is charged, plus any time the server's clock says is still owed (see Start a session).

Authorization

bearerAuth
headerAuthorizationBearer <token>

Your API key from https://tryiton.now/app/developer, sent as Authorization: Bearer YOUR_API_KEY. Keep it on your server. A missing, malformed or unknown key is rejected with 403 Forbidden.

Path Parameters

id*string

A live session id from POST /live/sessions. Anything other than 24 hex characters is a 400.

Match^[a-fA-F0-9]{24}$

Response Body

The session.

application/json
  1. response
ok*boolean
session*
Example Request
curl -X POST 'https://tryiton.now/api/v1/live/sessions/6b0828e5ed117d43a6d10ad1/stop' \  -H 'Authorization: Bearer YOUR_API_KEY'
Example Response
{  "ok": true,  "session": {    "id": "6b0828e5ed117d43a6d10ad1",    "status": "ended",    "endReason": "user",    "seconds": 9,    "creditsCharged": 5,    "endUserId": "shopper-42",    "apiKeyId": "6b0827eba2f220ae7dd7c7aa",    "refunded": false,    "creditsRefunded": 0,    "createdAt": "2026-11-26T12:21:57.402Z",    "endedAt": "2026-11-26T12:22:12.118Z"  }}

Stop a session as soon as you know the shopper has left. A browser that vanishes without ending keeps the session open until it goes stale, and the server's clock bills that time.