---
title: "Expose a port on a public preview URL"
method: POST
path: "/sandboxes/{id}/ports"
tags: ["Ports"]
---

# Expose a port on a public preview URL

`POST /sandboxes/{id}/ports`

## Request

- Base URL: `https://sandbox-as-a-service.com/v1`
- URL: `https://sandbox-as-a-service.com/v1/sandboxes/{id}/ports`
- Auth: HTTP bearer

Returns an https URL that reaches the given port inside the sandbox. The server does not need to bind a public interface — listening on localhost is enough, exactly as on a laptop. The URL carries an unguessable token and stops working the moment the sandbox does. Asking twice for the same port returns the same URL.

## Path parameters

- `id` string, required

## Request body

- object
  - `port` integer, required

## Response `201`

The preview URL.

- object
  - `object` string
  - `sandbox_id` string
  - `port` integer
  - `url` string, uri
  - `created_at` string, date-time

## Other responses

- `400`: The port is not a valid, exposable port.
- `404`: No sandbox with that id for this account.

---

[API](https://skmtc.dev/sandbox-as-a-service/apis/sandbox-as-a-service-api.md) · [All operations](https://skmtc.dev/sandbox-as-a-service/apis/sandbox-as-a-service-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sandbox-as-a-service/apis/sandbox-as-a-service-api/revisions/4f1ea2cf8333?raw)
