---
title: "Create Tunnel Endpoint"
method: POST
path: "/api/v1/tunnel"
tags: ["Tunnel"]
---

# Create Tunnel Endpoint

`POST /api/v1/tunnel`

Create a new tunnel for exposing a local service.

## Request body

- CreateTunnelRequest — Request to create a new tunnel.
  - `name` string, nullable — Optional friendly name for the tunnel
  - `local_port` integer — Local port the tunnel will forward traffic to
  - `teamId` string, nullable — Team ID for team tunnels
  - `labels` string[] — Labels/tags for the tunnel
  - `httpUser` string, nullable — Username for HTTP basic auth on tunnel traffic. Setting this enables auth; the password is auto-generated server-side and returned once in the create response.

## Response `201`

Successful Response

- TunnelResponse — Response containing tunnel connection details.
  - `tunnel_id` string, required — Unique tunnel identifier
  - `hostname` string, required — Full hostname for the tunnel
  - `url` string, required — Full HTTPS URL for accessing the tunnel
  - `frp_token` string, required — Authentication token for frpc client
  - `binding_secret` string, required — Per-tunnel secret for additional authentication via frpc metadata
  - `server_host` string, required — frps server hostname
  - `server_port` integer — frps server port
  - `expires_at` string, date-time, required — Token expiration timestamp
  - `labels` string[] — Tunnel labels
  - `http_user` string, nullable — HTTP basic auth username, if auth is enabled
  - `http_password` string, nullable — Auto-generated HTTP basic auth password, if auth is enabled. Only returned at creation; stored encrypted and never retrievable afterwards.

## Other responses

- `401` — Authorization failed
- `422` — Invalid request data

---

[API](https://skmtc.net/primeintellect/apis/pi-api.md) · [All operations](https://skmtc.net/primeintellect/apis/pi-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/primeintellect/pi-api/revisions/3d3868828a78/schema)
