The management REST API is the same surface theDocumentation Index
Fetch the complete documentation index at: https://langwatch.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
langwatch CLI and LangWatch dashboard use, exposed for scripts, CI pipelines, SDKs, and terraform providers. It runs on the LangWatch control plane (https://app.langwatch.ai), separately from the data-plane gateway (https://gateway.langwatch.ai).
Authentication uses existing LangWatch API tokens (Authorization: Bearer lwp_... or X-Auth-Token: lwp_...). No new token format.
The CLI (
langwatch virtual-keys ...) is built on this API. If you’re scripting from Node or Python, consider using the CLI rather than calling the REST directly — it handles pagination, JSON formatting, and error messages for you.Base
Virtual keys
List
Create
201:
Get
{ "virtual_key": {...} }. No secret.
Update
Rotate
200:
Revoke
200 with the same status.
Budgets
List
{ "data": [{...}, ...] }. Each entry has limit_usd and spent_usd as strings (decimal precision preserved).
Create
Update
name, description, limit_usd, on_breach, timezone.
Archive
Provider bindings
List
Create
201: { "provider_credential": { "id": "gpc_01HZ..." } }.
Update
Disable
Cache rules
Organization-scoped overrides that modulate cache behaviour for requests routed through the gateway. Evaluated first-match-wins by priority DESC; a matched rule wins over the per-VK default but loses to a per-requestX-LangWatch-Cache header. Full contract in Cache control.
List
gatewayCacheRules:view. Returns rules sorted priority DESC, excluding archived.
mode_enum is echoed in upper case alongside the lower-case action.mode so Prometheus / dashboards can filter by it without parsing the JSON action.
Get
gatewayCacheRules:view. Returns 404 for archived rules — use the audit log to inspect removed rules.
Create
gatewayCacheRules:create. At least one matcher is required (rules that match every request must be declared explicitly — unsupported in v1). Matchers across non-null fields are ANDed.
| field | type | semantics |
|---|---|---|
vk_id | string | Exact match against the VK’s display prefix form (lw_vk_live_...) |
vk_prefix | string | strings.HasPrefix against the same VK display prefix |
vk_tags | string[] | VK must carry EVERY listed tag (AND subset) |
principal_id | string | Exact match against the VK’s principal user |
model | string | Exact match against the resolved model name (no regex; trailing * as a glob is accepted) |
request_metadata | object | Exact-match against request headers/metadata key-by-key |
| field | type | semantics |
|---|---|---|
mode | "respect" / "force" / "disable" | Required. See Cache control for per-provider semantics |
ttl | int seconds | Optional. Clamped to [0, 86400]. Only meaningful for force on providers that support TTL (Anthropic) |
salt | string (max 64) | Optional cache-bust tag — changing this on an existing rule forces regeneration on next hit |
201: { "cache_rule": { ...full row } }.
Update
gatewayCacheRules:update. Partial update; matchers and action replace the stored value when provided (not merged field-by-field). Omitting them leaves the stored value untouched. Name, description, priority, enabled update independently.
Archive
gatewayCacheRules:delete. Soft archive: sets archivedAt. The rule stops matching new requests. Returns the archived row (200, not 204) so scripts can confirm the archivedAt timestamp.
Errors
All responses follow the OpenAI-compatible envelope:| HTTP | type | Meaning |
|---|---|---|
| 400 | bad_request | Validation / missing required field |
| 401 | unauthenticated | Missing or invalid API token |
| 403 | permission_denied | Token lacks the required RBAC scope |
| 404 | not_found | Resource doesn’t exist or isn’t visible in this project |
| 409 | conflict | Name collision on create, stale update (optimistic concurrency) |
| 422 | validation_error | Semantic error (e.g. window=MINUTE but limit_usd=100000, impossibly large per-minute cap) |
Audit
Every write emits a row in the platform-wideAuditLog (gateway shape — targetKind / targetId / before / after). Visible under /settings/audit-log with the Source = “Gateway” badge; filter by Target (virtual_key / budget / provider_binding / cache_rule) to scope. Writes via API tokens are attributed to the API token’s resolved user. See Audit log for the full schema, REST export path, and migration note from the v3.0 gateway-only table.
Rate limits
Management endpoints are rate-limited to 100 req/min/token. For bulk operations, use the--format json CLI with xargs -P4 (the CLI sleeps 250 ms between retries on 429).
Shared service layer
Both the REST API and the tRPC routers (virtualKeys.*, gatewayBudgets.*, gatewayProviders.*) call the same service classes on the server — VirtualKeyService, GatewayBudgetService, GatewayProviderCredentialService. The only difference between REST and tRPC is the DTO shape (snake_case vs camelCase). Behaviour is identical.
This matters for testing: the BDD scenarios in specs/ai-gateway/public-rest-api.feature include a parity check that asserts the two surfaces return equivalent data for the same resource after case normalization. If you rely on a field in one, it’s guaranteed to exist in the other.
OpenAPI
All REST routes are annotated withhono-openapi’s describeRoute schemas. The generated OpenAPI 3.1 spec is served at /api/gateway/v1/openapi.json and renders inside the platform’s API-reference UI. The CLI’s VirtualKeysApiService, GatewayBudgetsApiService, GatewayProvidersApiService DTOs are hand-authored against the same schemas; a v1.1 improvement is to regenerate them from the OpenAPI output so drift fails at build time.
See also
- langwatch CLI — higher-level access.
- RBAC — which scopes your token needs.
- Security — how your API tokens and resulting writes are protected.