REST API authentication and conventions
Bearer authentication, trusted-header deployments, project scoping, CSRF, envelopes, pagination, request ids, and error shapes.
These pages document the HTTP contract itself: the headers you send, the envelopes you receive, and the failure shapes you should handle before you build your own client.
Authentication modes
CALIBER supports three identity patterns, but only two make sense for direct programmatic use:
| Mode | How it works | Use it when |
|---|---|---|
| Bearer token | Authorization: Bearer <token> | normal automation and external integrations |
| Trusted header | X-CALIBER-User: <user> plus optional X-CALIBER-Proxy-Secret | only behind a trusted identity proxy in trusted_header deployments |
| Browser session | session cookie plus CSRF token | browser traffic and same-origin UI requests, not headless automation |
Personal access tokens (the calpat_ prefix) are the default automation credential. Trusted headers carry no proof by themselves and are ignored in the default session deployment mode.
A token's scopes are a ceiling: its effective authority is what it requested intersected with what its owner holds at request time, and a token cannot be issued with a scope its issuer lacks (403). A token can also be bound to one project by passing project_id when it is created (POST /auth/tokens); the issuer must already be able to see that project. A bound token that names a different project in X-CALIBER-Project or in the URL is refused with 403, and a bound token that names no project acts in its bound project. Unbound tokens, sessions and trusted-header identities are unaffected. The Workspace import routes (/projects/{project_id}/revision-imports) additionally refuse a personal access token that is not bound to that project; session callers are not affected.
Core headers
| Header | Meaning |
|---|---|
Authorization: Bearer <token> | Personal access token or session token |
X-CALIBER-Project: <project_id> | Active project/workspace scope |
X-CALIBER-CSRF: <token> | Required on POST, PATCH, PUT and DELETE when CSRF enforcement is enabled (it is off by default) |
X-Request-Id: <id> | Optional caller-supplied correlation id; CALIBER also returns request ids on responses and errors |
Accept: application/json | Preferred for management API calls |
Example:
curl -s \
-H "Authorization: Bearer $CALIBER_TOKEN" \
-H "X-CALIBER-Project: $CALIBER_PROJECT" \
"$CALIBER_BASE_URL/ajax-api/2.0/mlflow/caliber/workflows"
CSRF
CSRF enforcement is off by default (CALIBER_CSRF_ENABLED), and GET /csrf then answers enabled: false. When a deployment turns it on, every POST, PATCH, PUT and DELETE needs the header, except GET /csrf itself and the GitHub webhook route. That includes bearer-token calls: the middleware does not exempt them. The tokens are bound to the caller's identity and expire (CALIBER_CSRF_TOKEN_TTL_SECONDS), and a missing or invalid one is a 403. The SDK fetches a token and replays the write once when it sees that failure.
Fetch a token with:
curl -s \
-H "Authorization: Bearer $CALIBER_TOKEN" \
"$CALIBER_BASE_URL/ajax-api/2.0/mlflow/caliber/csrf"
The response carries enabled, token and ttl_seconds. Echo the returned token in X-CALIBER-CSRF on the write request.
Response envelopes
Most management API responses use the standard envelope:
{
"data": {
"workflow_id": "WF-123",
"name": "release-governance"
}
}
Lists usually live under data as well:
{
"data": [
{"workflow_id": "WF-123"},
{"workflow_id": "WF-456"}
]
}
A few routes answer with a bare body instead of the envelope: GET /health returns {"status", "version", "db"} at the top level, and the OpenAPI documents are the raw document. GET /health answers 503 with status: "degraded" when the database probe fails. GET /readiness does use the envelope, and answers 503 (the body is still under data) when a required dependency is not ready; that includes a database that has not been migrated to the schema this release expects (run caliber-migrate) and an unreachable MLflow tracking server.
Pagination and list conventions
Many list endpoints accept:
?limit=<n>(default 500, at most 2000 on routes that share the common helper)?offset=<n>
Invalid values fall back to defaults rather than failing request parsing, so a consumer that cares about deterministic pagination should always send explicit values. Pagination is not one shape across the API: some routes take only limit, the audit log returns its own envelope, the event streams take after, and the Workspace routes (/projects/{project_id}/revisions, .../revision-imports and similar) use limit plus an opaque cursor and return next_cursor next to data.
Error shapes
General route failures come back as:
{
"detail": "forbidden",
"status_code": 403
}
Some routes also set a machine-readable reason_code next to detail ({"detail": ..., "status_code": 409, "reason_code": "..."}). It is optional and additive: most routes do not set it yet, so treat its absence as normal and fall back to detail and the status code.
One code is always set: a route of an area that this deployment has turned off answers 404 with reason_code: feature_disabled, and detail names the variable that enables it. The preview and record-only areas (MCP servers and OpenAPI integrations, cookbooks, release-candidate signoff and Workspace releases) are off by default; Aria ships on and answers this 404 only if an operator sets CALIBER_FEATURE_ARIA=false. Read features from GET /capabilities to check before you call, and treat this 404 as "not enabled here" rather than "no such record":
{
"detail": "Aria assistant and plans is disabled in this deployment. Set CALIBER_FEATURE_ARIA=true to enable it.",
"status_code": 404,
"reason_code": "feature_disabled"
}
A 429 carries a Retry-After header. When MLflow is unreachable, the prompt routes and Apply answer 503 with a fixed message naming MLFLOW_TRACKING_URI, and nothing was changed.
Validation failures use a structured 400 body:
{
"detail": "request body validation failed",
"status_code": 400,
"errors": [
{
"loc": ["instructions"],
"msg": "instructions must reference at least one evaluation variable",
"type": "value_error"
}
]
}
Your client should treat transport failures, HTTP failures, and validation failures as three different classes of problem.