Make a ticket that lets a browser open a command's stream

Answers a short-lived, single-use ticket for this command's stream (`streamExec`), for a browser that cannot send `Authorization` on a WebSocket.

POST/v1/sandboxes/{sandbox_id}/exec/{operation_id}/stream-ticket

Answers a short-lived, single-use ticket for this command's stream (streamExec), for a browser that cannot send Authorization on a WebSocket. Call it over HTTPS where the key or token lives. The dashboard's page calls it itself, from the browser with the person's token, whenever the sandbox is in a customer cell: it calls the cell's endpoint, which accepts the dashboard's origin, because the dashboard's server cannot reach that cell and never fetches its data, and api.pod.mapier.ai answers in_other_cell without forwarding. For a sandbox in one of Pod's own cells the dashboard's server may instead call it with the person's token, and a customer's own server with an API key; either hands only the ticket and stream_url to its page. The ticket is bound to this stream (the sandbox and the operation), to the key or person that asked, to the organization and project, to origin, and to an expiry of at most 60 seconds. It opens the stream once. A person's token may name only Pod's own clients' origins (forbidden otherwise); an API key may name any origin of the pattern. If the call itself carries an Origin header, as it does from a browser, it must equal origin (forbidden otherwise). The answer is a secret: it is sent with Cache-Control: no-store, never logged and never stored for a replay, so the call takes no Idempotency-Key; one sent anyway is ignored and never stored. Pod stores only the ticket's SHA-256 hash. A caller holds at most 20 unused tickets; one more is rate_limited, with retry_after_s until the oldest of them expires.

A key with the sandboxes:exec scope.

Request

curl -X POST "https://api.pod.mapier.ai/v1/sandboxes/sbx_3ahrz6dmv29gqy5ckt18fpx4b/exec/op_3ahrz6dmv29gqy5ckt18fpx4b/stream-ticket" \
  -H "Authorization: Bearer $POD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"origin":"example"}'

Parameters

NameInTypeRequiredWhat it is
sandbox_idpathstringYes
operation_idpathstringYes
Pod-End-UserheaderstringNoNarrows a project key to one of its end users: the call sees only that end user's sandboxes and usage, any other answering not_found, and a create is labelled with it. An end user of another project, or one that is not there, is not_found; a suspended one refuses creates and wakes (account_restricted).

Body

FieldTypeRequiredWhat it is
originstringYesThe origin of the page that will open the stream. The upgrade's Origin must equal it.
ttl_sintegerNoHow long the ticket lives. A page should open the stream at once. Default 30. From 1 to 60.

Answer

201. The ticket.

201
{
  "ticket": "pod_3ahrz6dmv29gqy5ckt18fpx4bjs07enw3ahrz6dm",
  "stream": "exec",
  "sandbox": "sbx_3ahrz6dmv29gqy5ckt18fpx4b",
  "operation": "op_3ahrz6dmv29gqy5ckt18fpx4b",
  "organisation": "org_3ahrz6dmv29gqy5ckt18fp",
  "project": "prj_3ahrz6dmv29gqy5ckt18fp",
  "origin": "example",
  "stream_url": "wss://api.pod.mapier.ai/v1/sandboxes/sbx_3ahrz6dmv29gqy5ckt18fpx4b/exec/op_3ahrz6dmv29gqy5ckt18fpx4b/stream",
  "expires_at": "2026-11-23T12:00:00.000Z"
}
FieldTypeAlwaysWhat it is
ticketstringYesSingle use, for one stream, for at most 60 seconds. Stored by Pod only as a SHA-256 hash.
stream"exec" | "screen"YesThe stream a ticket opens. The screen's has its own ticket, ScreenStreamTicket.
sandboxstringYes
operationstringYes
organisationstringYes
projectstringYes
originstringYesA browser origin as the browser sends it in Origin (RFC 6454): scheme, host and port, no path and no default port. https://, or http:// on loopback for development.
stream_urlstringYesThe stream to open, the same address as the operation's stream_url.
expires_atstringYesAfter this the ticket opens nothing.

Errors

The refusals this call is known for: invalid, forbidden, not_found, in_other_cell, rate_limited. Any call can also answer unauthorized, rate_limited, unavailable or internal; the error list says what each means and when to send the call again.

In the SDKs

ClientCall
TypeScriptpod.sandboxes.execStreamTicket(id, opId, { origin })
Pythonsandbox.exec_stream_ticket(op_id, origin=…)
mpodmpod sandboxes commands ticket <sandbox> <operation> --origin <origin>