On this page
  1. Control plane
    1. Conventions
    2. Endpoints
    3. Inboxes
    4. Example: a CI job that waits for a webhook
  2. Edge
  3. Local inspector

HTTP APIs

Three HTTP surfaces:

  1. Control plane — https://connect.<domain>: the REST API used by the console, the CLI, the MCP server and your scripts. The machine-readable schema is served at /api/v1/openapi.json.
  2. Edge — https://<subdomain>.<domain>: public traffic to tunnels, and webhook ingest for inboxes.
  3. Local inspector — http://127.0.0.1:4040, served by the client on the developer's machine.

The tunnel wire protocol is in Protocol.

Control plane

Conventions

  • JSON in and out; timestamps are ISO-8601 UTC.
  • Auth: Authorization: Bearer tnx_… (API token) or the console cookie tunnex_session. A cookie-authenticated request that changes state must come with the console's own Origin (CSRF protection; browsers send it).
  • Scopes: a token carries a subset of tunnels, listen, inboxes:read, inboxes:write, account. Console sessions and tunnex login tokens carry all of them. A missing scope is 403 insufficient_scope.
  • Team roles (member < admin < owner) apply on top of scopes: 403 not_a_member / insufficient_role.
  • Errors: {"error": {"code": "<stable slug>", "message": "<text for humans>"}} with 400 (invalid input), 401, 403, 404, 409 (conflict), 410 (gone), 413, 422, 428 (pending, device flow), 429 (with Retry-After), 503.
  • Lists return {"items": [...]}; long lists page backwards with before_id and limit (≤ 200).
  • Every response has X-Request-Id (yours is kept if you send one), also present in server logs.

Endpoints

Method Path Scope / role Notes
GET /healthz — Liveness: {"status":"ok","version"}
GET /readyz — Readiness: 503 while the database is down or the server drains
GET /api/v1/meta — Domain, version, protocol, features (signup, anonymous_tunnels, github, sso, tcp, webhooks), plan limits
POST /api/v1/auth/signup, /api/v1/auth/login — {"email","password"} → user + session cookie; rate limited
POST /api/v1/auth/logout, /api/v1/auth/logout-all session logout-all invalidates every session of the account
GET /api/v1/me any User, plan limits, today's usage
POST /api/v1/me/password account Set or change the password ({"current_password"?, "password"})
GET /api/v1/sessions, /api/v1/usage any Tunnel sessions and daily usage
GET, POST /api/v1/tokens account Create: {"name","scopes"?,"expires_in_days"?} → the token, shown once
DELETE /api/v1/tokens/{id} account Revoke; clients using it are disconnected
POST /api/v1/device/code, /api/v1/device/token — tunnex login device flow (the CLI polls token: 428 while pending)
GET, POST /api/v1/device/{code}, …/approve, …/deny session The console's approval page
GET, POST, DELETE /api/v1/domains, /api/v1/domains/{sub} account to change Reserved subdomains within the plan quota
GET, DELETE /api/v1/tunnels, /api/v1/tunnels/{sub} tunnels to disconnect Your live tunnels; DELETE disconnects one
GET, POST /api/v1/teams account Create: {"slug","name"?}; you become owner
GET, PATCH, DELETE /api/v1/teams/{slug} member / admin / owner Details (member); rename (admin); delete (owner)
PATCH, DELETE /api/v1/teams/{slug}/members/{user_id} owner / admin Change role (owner); remove (admins remove members, anyone may leave)
GET, POST /api/v1/teams/{slug}/invites admin Create: {"role"} → one-time link valid 7 days
DELETE /api/v1/teams/{slug}/invites/{id} admin Revoke
GET, POST /api/v1/invites/{code}, …/accept any Invite details; accept
GET, POST /api/v1/inboxes inboxes:read / inboxes:write + admin Create: see below
GET, PATCH, DELETE /api/v1/inboxes/{sub} read / write + admin Settings, listeners online; change; delete (disconnects listeners with inbox_deleted)
GET /api/v1/inboxes/{sub}/events inboxes:read ?before_id&limit&verified=true\|false&q=<substring of path or body>
GET /api/v1/inboxes/{sub}/events/{id} inboxes:read Headers, body, every delivery attempt
POST /api/v1/inboxes/{sub}/events/{id}/replay inboxes:read {"subscription_id"?}; members replay to their own listeners, admins to any → {"queued": n}
GET /api/v1/inboxes/{sub}/subscriptions inboxes:read Listener subscriptions: name, user, cursor, filters, online
DELETE /api/v1/inboxes/{sub}/subscriptions/{id} its user, or an admin Forget a subscription and its cursor
GET /api/v1/audit account; team admin for ?team= ?team&before_id&limit
GET /sso/authorize, /auth/github/* — Browser flows (tunnel SSO, GitHub sign-in)

Inboxes

Create (POST /api/v1/inboxes) and change (PATCH /api/v1/inboxes/{sub}) take:

{
  "subdomain": "acme-stripe",            // create only
  "team": "acme",                        // create only; default: your first team (created if needed)
  "name": "Stripe (test mode)",
  "provider": "stripe",                  // none | stripe | github | slack | shopify | standard | telegram
  "secret": "whsec_…",                   // write-only; "" removes it
  "reject_invalid": true,
  "ack_status": 200, "ack_body": "{\"ok\":true}", "ack_content_type": "application/json",
  "retention_days": 7,
  "allow_ips": ["203.0.113.0/24"]
}

An inbox reads back as {subdomain, url, name, team, role, provider, has_secret, reject_invalid, ack, retention_days, allow_ips, listeners, created_at, updated_at} — the secret is never returned.

An event is {id, type, received_at, method, path, query, content_type, size, remote_ip, verified, verify_error, delivered, deliveries, last_status} — type is the provider's event name when one is found (json.type for Stripe and Standard Webhooks, X-GitHub-Event + action, Slack's event.type, X-Shopify-Topic, the Telegram update kind); the detail adds headers, body, body_encoding (utf8 or base64) and delivery_log entries {id, subscription, user, kind, attempt, status, error, duration_ms, resigned, delivered_at, response_body}.

Example: a CI job that waits for a webhook

TOKEN=tnx_…   # tunnex tokens create ci --scope inboxes:read --expires-in 30
curl -fsS -H "Authorization: Bearer $TOKEN" \
  "https://connect.tunnex.org/api/v1/inboxes/acme-stripe/events?limit=1&verified=true"

Edge

Tunnels (<sub>.<domain> with a live tunnel): requests are forwarded as they are, after the tunnel's policies. Errors generated by the edge (offline tunnel, IP or path not allowed, rate limited, busy) are an HTML page for browsers and {"error": {"code", "message"}} otherwise. When the client cannot reach the local app it answers 502 with X-Tunnex-Error: local_unreachable. Paths under /_tunnex/ are reserved (SSO callback, the anonymous-tunnel warning acknowledgement).

Inboxes (<inbox>.<domain>): any method and path is accepted and stored.

Response When
the configured acknowledgement (default 200 {"ok":true}) + X-Tunnex-Event-Id stored and delivered
200 {"challenge": …} Slack URL verification (not delivered)
401 invalid_signature bad or missing signature and the inbox rejects invalid events (stored, not delivered)
403 ip_not_allowed the sender is outside the inbox's IP allowlist
413 payload_too_large body over webhooks.max_body_bytes
429 rate_limited + Retry-After over webhooks.events_per_minute

Local inspector

Served by tunnex http, tunnex listen and tunnex start on 127.0.0.1:4040 (next free port if busy). Requests must use an allowed Host (127.0.0.1:<port>, localhost:<port>, plus --inspector-host/TUNNEX_INSPECTOR_HOSTS values), a foreign Origin is rejected, and writes need X-Tunnex-Dashboard: 1.

Method Path Notes
GET /api/state Tunnels and listeners running on this machine
GET /api/requests Recorded requests: ?tunnel=<name>[,<name>…]&source=tunnel\|inbox&method&status_class&path&q&since_minutes&before_id&limit
GET /api/requests/{id} Full exchange: headers, bodies (first 1 MiB), timing, delivery facts for inbox events
DELETE /api/requests Clear the local history
POST /api/requests/{id}/replay Send the request again to the tunnel's or listener's local target, optionally edited ({method, url, headers, body})
WS /ws Live stream of new and updated requests

Edit this page on GitLab