Make a new token for a private port
Answers the port with a new `token` (`podpt_…`), shown this once; Pod keeps only its SHA-256.
Answers the port with a new token (podpt_…), shown this once; Pod keeps only its SHA-256. A program sends it in the Pod-Port-Token header; a browser opens {url}?pod_token=… once, and Pod answers with a redirect to the same URL without it and a session cookie for that host only, so the token leaves the address bar before the sandbox's page loads. A new token replaces the old one and ends every share link and session made before it: that is how a leaked link is revoked. The answer is a secret, sent with Cache-Control: no-store and never stored for a replay, so the call takes no Idempotency-Key, as a stream ticket does; each call makes a new token. Refused to all but the creator of a no_save sandbox (saves_refused).
A key with the sandboxes:write scope.
Request
curl -X POST "https://api.pod.mapier.ai/v1/sandboxes/sbx_3ahrz6dmv29gqy5ckt18fpx4b/ports/1/token" \
-H "Authorization: Bearer $POD_API_KEY"Parameters
| Name | In | Type | Required | What it is |
|---|---|---|---|---|
sandbox_id | path | string | Yes | |
port | path | integer | Yes | A TCP or UDP port number, 1 to 65535. |
Answer
201. The port, with its new token.
{
"sandbox": "sbx_3ahrz6dmv29gqy5ckt18fpx4b",
"port": 1,
"visibility": "private",
"name": null,
"url": "https://app.example.com",
"name_url": null,
"has_token": false,
"updated_at": null,
"token": "podpt_3ahrz6dmv29gqy5ckt18fpx4bjs07enw3ahrz6dm"
}| Field | Type | Always | What it is |
|---|---|---|---|
sandbox | string | Yes | |
port | integer | Yes | From 1 to 65535. |
visibility | "private" | "public" | Yes | private (the default): opened by a key, the port's token, a share link or their session. public: opened by anyone. |
name | string | null | Yes | |
url | string | Yes | https://{port}-{sandbox id without sbx_}.{content domain}; the sandbox id's body starts with its cell tag. |
name_url | string | null | Yes | https://{name}--{cell tag}.{content domain}, the cell tag being the sandbox's, when the port has a name. |
has_token | boolean | Yes | |
updated_at | string | null | Yes | |
token | string | No | Only in the answer of createPortToken, once. |
Errors
The refusals this call is known for: invalid, saves_refused, not_found, in_other_cell. 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
| Client | Call |
|---|---|
| TypeScript | pod.ports.createToken(sandboxId, port) |
| Python | pod.ports.create_token(sandbox_id, port) |