POST /v1/sandboxes/{sandbox_id}/ports/{port}/url
Returns a URL that reaches `port` inside the sandbox: `https://usercontent.b3os.org/sbx/<host_id>/<port>/<token>/`. The token in the path is signed by the node and expires after `ttl_s` (10 minutes by default, at most 24 hours); anyone with the URL reaches the port until then, with no cookie or other credential. For a public port the response is the sandbox's long-lived URL (`ports[].url`) and `ttl_s` is ignored. The port must be declared in `ports` when the sandbox is created. The app sees the URL's base path in `X-Forwarded-Prefix` on every request (token format and forwarding: `sandboxesProxyPortGet`).

Authentication

Bearer Token (b3os_sk_ API key or b3os_pat_ token) API Key (cookie: __Host-b3os_session)

Path Parameters

sandbox_id string required path
The sandbox ID (`sbx_…`).
Example: "sbx_01m5t68q1b590rj801nbzsqzkk"
port integer required path
A port declared in the sandbox's `ports`.
Example: 3000

Request Body

application/json
ttl_s integer
How long the URL works, in seconds. Ignored for public ports.

Responses

200 The URL.
application/json
object string REQUIRED
Enum: port_url
port integer REQUIRED
public boolean REQUIRED
url string (uri) REQUIRED
`https://usercontent.b3os.org/sbx/<host_id>/<port>/<token>/`; the token is in the path.
expires_at string (date-time) REQUIRED
When the token in `url` expires.
400 The request failed validation (`invalid_request`, `invalid_url`).
401 Missing, malformed, expired or revoked credentials (`unauthorized`).
403 Authenticated but not allowed (`forbidden`, `egress_denied`).
404 The port is not declared in `ports` (`port_not_exposed`).
409 The sandbox is paused or stopped (`sandbox_not_running`).
413 The request body exceeds this operation's limit.
415 The Content-Type is not accepted by this operation.
429 A rate, concurrency or quota limit applies (`rate_limited`, `concurrency_limited`, `quota_exceeded`).
500 Something failed inside B3OS (`internal`). Retry with backoff.
503 The node or the product is not available right now (`node_unavailable`, `product_unavailable`, `capacity_unavailable`).
curl -X POST 'https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/ports/3000/url' \  -H 'Authorization: Bearer YOUR_API_TOKEN' \  -H 'Content-Type: application/json' \  -d '{  "ttl_s": 600}'
const response = await fetch('https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/ports/3000/url', {  method: 'POST',  headers: {      "Authorization": "Bearer YOUR_API_TOKEN",      "Content-Type": "application/json"  },  body: JSON.stringify({    "ttl_s": 600  })});const data = await response.json();console.log(data);
import requestsheaders = {    'Authorization': 'Bearer YOUR_API_TOKEN'}response = requests.post('https://beta-api.b3os.org/v1/sandboxes/sbx_01m5t68q1b590rj801nbzsqzkk/ports/3000/url', headers=headers, json={  "ttl_s": 600})print(response.json())
200 Response
{  "object": "port_url",  "port": 3000,  "public": false,  "url": "https://usercontent.b3os.org/sbx/sbx-01m5t68q1b590rj801nbzsqzkk/3000/pt1.n1.1792955460.tjsgjiRC3sSYEwneW62TSvNqd-Jo_zzFI5zFYkB_YQBNl0CiBzI9xgoV6EJD_5YEmh3HbzSmb3acL8mY1LmYCg/",  "expires_at": "2026-10-25T19:11:00.000Z"}
Ask a question... ⌘I