API Reference

Build against PreviewBox with a simple JSON REST API.

Base URL

Base URL
https://server.previewbox.dev

All endpoints return JSON. The service health check at /health is public; everything else requires authentication.

Authentication

Authenticate with either your session token (from the CLI or dashboard) or a scoped API key. Generate API keys in Dashboard → Settings → API Keys.

Bearer token
curl -H "Authorization: Bearer YOUR_TOKEN" \
  https://server.previewbox.dev/api/tunnels
API key
curl -H "X-API-Key: pb_YOUR_API_KEY" \
  https://server.previewbox.dev/api/tunnels

Endpoints

MethodEndpointDescription
GET/healthService health check
POST/api/auth/registerCreate an account
POST/api/auth/loginSign in
GET/api/tunnelsList your tunnels
POST/api/tunnelsCreate a tunnel
GET/api/tunnels/:idTunnel details
DELETE/api/tunnels/:idDelete a tunnel
GET/api/active-tunnelsCurrently active tunnels
GET/api/tunnels/:id/statsTunnel request statistics
GET/api/tunnels/:id/logsTunnel request logs
GET/api/tunnels/:id/uptimeTunnel uptime history
GET/api/tunnels/:id/alertsSmart alert rules
POST/api/tunnels/:id/alertsCreate an alert rule
GET/api/tunnels/:id/recordTraffic recording
POST/api/tunnels/:id/replayReplay a recorded request
GET/api/tunnels/:id/snapshotsTunnel snapshots
GET/api/tunnels/:id/access-tokensTunnel access tokens
GET/api/tunnels/:id/ip-allowlistIP allowlist
PUT/api/tunnels/:id/basic-authBasic auth credentials
PUT/api/tunnels/:id/rate-limitRate limit config
GET/api/statsPlatform statistics
GET/api/analytics/endpointsEndpoint analytics
GET/api/apikeysList API keys
POST/api/apikeysCreate an API key
POST/api/apikeys/:id/rotateRotate an API key
GET/api/webhooksList webhooks
POST/api/webhooksCreate a webhook
POST/api/webhooks/:id/testSend a test delivery
GET/api/auditAudit log
GET/api/exportExport your data
GET/api/usageUsage quotas
GET/api/teamsTeam memberships
GET/api/changelogProduct changelog
GET/api/sse/statsReal-time stats stream (SSE)

Many tunnel sub-resources follow the same pattern — see the backend's route list for the full set (throttle, custom-404, metadata, share, snapshots, schedules, OpenAPI and more).

Example

List active tunnels
curl -s -H "Authorization: Bearer YOUR_TOKEN" \
  https://server.previewbox.dev/api/tunnels | jq .

Want real-time events instead of polling? See webhooks.