Make a port public or private, and name it

Sets the port's visibility and its chosen name, and keeps its token.

PUT/v1/sandboxes/{sandbox_id}/ports/{port}

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

NameInTypeRequiredWhat it is
sandbox_idpathstringYes
portpathintegerYesA TCP or UDP port number, 1 to 65535.
Idempotency-KeyheaderstringNoMakes a repeat of this call safe for 24 hours.

Body

FieldTypeRequiredWhat it is
visibility"private" | "public"Noprivate (the default): opened by a key, the port's token, a share link or their session. public: opened by anyone.
namestring | nullNo

Answer

200. The port.

200
{
  "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"
}
FieldTypeAlwaysWhat it is
sandboxstringYes
portintegerYesFrom 1 to 65535.
visibility"private" | "public"Yesprivate (the default): opened by a key, the port's token, a share link or their session. public: opened by anyone.
namestring | nullYes
urlstringYeshttps://{port}-{sandbox id without sbx_}.{content domain}; the sandbox id's body starts with its cell tag.
name_urlstring | nullYeshttps://{name}--{cell tag}.{content domain}, the cell tag being the sandbox's, when the port has a name.
has_tokenbooleanYes
updated_atstring | nullYes
tokenstringNoOnly 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

ClientCall
TypeScriptpod.ports.set(sandboxId, port, { … })
Pythonpod.ports.set(sandbox_id, port, …)