> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a tunnel

> Creates a public tunnel to a sandbox port

Creates a public tunnel to a sandbox port

### Path parameters

<ParamField path="sandboxId" type="string (uuid)" required>
  Unique sandbox identifier
</ParamField>

### Request body

`CreateTunnelRequest`

<ParamField body="port" type="integer" required>
  Port to expose
</ParamField>

<ParamField body="protocol" type="string">
  Protocol (http or https)
</ParamField>

<ParamField body="expires_in" type="integer">
  TTL in seconds
</ParamField>

<ParamField body="public" type="boolean">
  When true, no token is required
</ParamField>

### Response

`Tunnel`

<ResponseField name="tunnel_id" type="string" />

<ResponseField name="sandbox_id" type="string" />

<ResponseField name="port" type="integer" />

<ResponseField name="protocol" type="string" />

<ResponseField name="url" type="string" />

<ResponseField name="expires_at" type="string (date-time)" />

<ResponseField name="token" type="string" />

### Status codes

| Code  | Meaning        |
| ----- | -------------- |
| `200` | Tunnel created |
| `400` | —              |
| `401` | —              |
| `404` | —              |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.sandbox.stateset.app/api/v1/sandbox/{sandboxId}/tunnels' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "port": 1,
    "protocol": "http",
    "expires_in": 1,
    "public": true
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "tunnel_id": "string",
    "sandbox_id": "string",
    "port": 1,
    "protocol": "string",
    "url": "string",
    "expires_at": "2026-07-24T12:00:00Z",
    "token": "string"
  }
  ```
</ResponseExample>
