Skip to main content
Karta uses conventional HTTP status codes. Agent runtime routes return the body under a detail key - a string for simple errors, or an object carrying an error code and message for structured ones. The session-token mint endpoint returns those same fields flat, without the detail wrapper.

Status codes

402 - budget exhausted

When an org hits a budget cap, the agent runtime returns 402 before running the turn. The payload sits under detail:
Minting a session token is gated the same way: POST /api/agents/{slug}/session_tokens returns 402 when the org is over budget, so an over-budget org cannot hand a fresh token to its browser clients. That endpoint returns the same fields flat (no detail wrapper):
The fields are identical on both paths: a stable error code, a human message, and a reason machine code naming what tripped: credits_exhausted (a managed org’s prepaid balance is empty), total_tokens_cap_reached (a configured token cap), or subscription_past_due. Match on the 402 status; treat error as the stable code and reason as diagnostic detail. A per-instance or per-seat cap returns 402 with a different error code - instance_spend_cap_exceeded - rather than budget_exhausted.

Errors during a stream

Once an SSE stream has started (200 already sent), failures arrive as an error event rather than an HTTP status - because the status line is already on the wire:
So a client must handle two failure channels: the HTTP status for pre-stream problems (auth, budget, validation), and error events for mid-stream problems (provider rejection, harness failure).

429, 503, and retries

For 429, back off and retry. If a Retry-After header is present, honor it; otherwise use exponential backoff with jitter. A 503 means Karta is temporarily unable to serve the request (for example, the harness is briefly unavailable). It carries a Retry-After header - back off and retry, honoring Retry-After. For support or correlation, keep the request timestamp, route, agent slug, session id, and any response headers your client receives.