Make a port public or private, and name it
Sets the port's visibility and its chosen name, and keeps its token.
Sets the port's visibility and its chosen name, and keeps its token. A port is private by default: its URL opens for an API key with sandboxes:exec, the port's token, a share link or the browser session one of them gave. A public port opens for anyone. A chosen name gives the port a second URL, https://{name}--{cell tag}.{content domain}, the cell tag being the sandbox's (the three characters after sbx_): the name is 3 to 40 lowercase letters, digits and single hyphens, starting with a letter and not reserved, and never holds --. It is unique across the sandbox's cell, so its label carries the cell's tag; a name another port of the cell holds is conflict. null or no name removes it. A sandbox made with no_save refuses making a port public to every caller but its creator (saves_refused), as it refuses tokens and share links.
A key with the sandboxes:write scope.
Request
curl -X PUT "https://api.pod.mapier.ai/v1/sandboxes/sbx_3ahrz6dmv29gqy5ckt18fpx4b/ports/1" \
-H "Authorization: Bearer $POD_API_KEY" \
-H "Content-Type: application/json" \
-d '{"visibility":"private"}'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. |
Idempotency-Key | header | string | No | Makes a repeat of this call safe for 24 hours. |
Body
| Field | Type | Required | What it is |
|---|---|---|---|
visibility | "private" | "public" | No | private (the default): opened by a key, the port's token, a share link or their session. public: opened by anyone. |
name | string | null | No |
Answer
200. The port.
{
"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, conflict, 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.set(sandboxId, port, { … }) |
| Python | pod.ports.set(sandbox_id, port, …) |