REST API Reference

The Spanlens REST API backs the dashboard and is stable for direct use. All authenticated endpoints require a Supabase JWT in Authorization: Bearer …. Proxy endpoints use a Spanlens API key.

Authentication

Two security schemes are used:

SchemeHeaderUsed for
BearerJWTAuthorization: Bearer <jwt>All /api/v1/* dashboard endpoints
ApiKeyAuthorization: Bearer sl_live_…Proxy endpoints (/proxy/*) and SDK ingest (/ingest/*)

JWTs are obtained from Supabase Auth (supabase.auth.getSession()) and expire after 1 hour. Spanlens API keys (sl_live_…) are created at /projects by clicking + New Spanlens key on the project card; they never expire (revoke explicitly via the toggle when rotating). For the cryptographic details + the per-SDK auth-header mapping, see Keys & encryption and Direct proxy.

Base URLs

EnvironmentBase URL
Production (hosted)https://server.spanlens.io
Local devhttp://localhost:3001
Self-hostedhttps://your-spanlens.example.com

Endpoint groups

GroupPrefixAuth
HealthGET /healthNone
Organizations/api/v1/organizationsJWT
Projects/api/v1/projectsJWT
API keys/api/v1/api-keysJWT
Provider keys/api/v1/provider-keysJWT
Requests/api/v1/requestsJWT
Stats/api/v1/statsJWT
Traces/api/v1/tracesJWT
Prompts/api/v1/promptsJWT
Anomalies/api/v1/anomaliesJWT
Security/api/v1/securityJWT
Alerts/api/v1/alertsJWT
Recommendations/api/v1/recommendationsJWT
Evals/api/v1/evaluatorsJWT
Datasets/api/v1/datasetsJWT
Experiments/api/v1/experimentsJWT
Prompt experiments (A/B)/api/v1/prompt-experimentsJWT
Prompt playground/api/v1/prompts-playground/runJWT
Human evals/api/v1/human-evalsJWT
Annotation queue/api/v1/annotation/queueJWT
Webhooks/api/v1/webhooksJWT (admin/editor for writes)
Audit logs/api/v1/audit-logsJWT
Saved filters/api/v1/saved-filtersJWT
Exports/api/v1/exports/*JWT
Members/api/v1/organizations/:orgId/membersJWT (admin for writes)
Invitations/api/v1/organizations/:orgId/invitationsJWT (admin)
Proxy, OpenAI/proxy/openai/v1/*API key
Proxy, Anthropic/proxy/anthropic/v1/*API key
Proxy, Gemini/proxy/gemini/v1/*API key
Proxy, Azure OpenAI/proxy/azure/*API key
SDK Ingest/ingest/*API key

For the full interactive spec, request/response schemas, try-it-out, example curl commands, open the Swagger UI.

Plan-gated responses to know about

A few endpoints respond with HTTP 402 Payment Required when a plan limit is hit, so your client can distinguish "you ran out of headroom" from a generic 400/403:

  • POST /api/v1/organizations returns 402 with { "code": "workspace_limit_reached", "error": "…", "owned": N, "limit": M, "effectivePlan": "…" } when the caller already owns the maximum workspaces their effective plan allows (Free 1, Pro 2, Team 5, Enterprise unlimited). Upgrade any owned workspace and retry. See Billing & quotas for the full per-plan table.