Appearance
Errors
Error responses
Every API error has a 4xx or 5xx status and the same JSON body:
json
{
"code": "VALIDATION_FAILED",
"message": "The request is invalid.",
"fields": {
"input.message": ["a non-empty string is required"]
},
"requestId": "7b4e0c1a-…"
}| Field | Meaning |
|---|---|
code | stable, machine-readable code: branch on this |
message | English description for logs and developers; may change |
params | values filled into the message, e.g. { "scope": "runs:read" } (when the code has any) |
fields | per-field messages for invalid bodies (VALIDATION_FAILED, INPUT_INVALID); keys are dotted paths, _ for the whole body |
requestId | the request's id, also in the x-request-id header: include it when you contact support |
The complete list of codes with their statuses: Error codes.
Statuses at a glance
| Status | Typical codes | What to do |
|---|---|---|
| 400 | VALIDATION_FAILED, INPUT_INVALID, INPUT_REJECTED, INPUT_TOO_LONG, FILE_TYPE_NOT_ACCEPTED, ASYNC_STREAM_CONFLICT, AGENT_TYPE_MISMATCH | fix the request; do not retry unchanged |
| 401 | INVALID_API_KEY | check the key (missing, revoked, expired) |
| 402 | QUOTA_EXCEEDED, STORAGE_LIMIT_REACHED | spend cap or storage limit reached |
| 403 | MISSING_SCOPE, AGENT_NOT_ALLOWED (the key is restricted to other agents), ORG_SUSPENDED | change the key's scopes or agents |
| 404 | NOT_FOUND, FILE_NOT_FOUND, VERSION_NOT_FOUND, APPROVAL_NOT_FOUND | check ids and slugs (scoped to the key's project) |
| 409 | AGENT_NOT_PUBLISHED, IDEMPOTENCY_IN_PROGRESS, IDEMPOTENCY_KEY_REUSED, RUN_NOT_CANCELLABLE, EVENT_NOT_EXPECTED | state conflict: read the message |
| 413 | FILE_TOO_LARGE | smaller file |
| 415 | FILE_TYPE_NOT_SUPPORTED | unsupported file type |
| 429 | RATE_LIMITED, REALTIME_SESSION_LIMIT | wait retry-after seconds, then retry |
| 5xx | INTERNAL, PROVIDER_ERROR, DOC_WORKER_UNAVAILABLE | retry with backoff |
Resources of other projects are invisible to a key: they answer 404, never 403.
Failed runs are not HTTP errors
Problems found before a run starts are HTTP errors (the run is not created or not executed). Problems during execution (the provider fails, a tool breaks, the output does not match the schema, a workflow node fails) are recorded on the run, and the request still answers 200:
json
{
"runId": "…",
"status": "failed",
"output": null,
"usage": { "inputTokens": 1200, "outputTokens": 0, "priceMicros": 410 },
"latencyMs": 30211,
"error": { "code": "PROVIDER_ERROR", "message": "The model provider failed: timeout" }
}Always check status (or error) in a RunResult. The same error object appears in GET /v1/runs/{id}, in run.failed stream events and in run.failed webhooks. Run error codes include the HTTP codes above (PROVIDER_ERROR, MODEL_OUTPUT_INVALID, ...) and the workflow codes (WORKFLOW_NO_OUTPUT, NODE_TIMEOUT, CHILD_RUN_FAILED, ...), whose catalog status (500) is not used as an HTTP status. Cancelled runs carry RUN_CANCELLED.
Retrying
Retry 429, 502, 503, 504 and network errors with exponential backoff, honouring retry-after. Retry POST /v1/agents/{slug}/runs only with an Idempotency-Key, so a run that did start is not executed twice. The SDK does all of this for you (see SDK retries).
In the SDK
Every error is a HevkarError with status, code, message, params, fields and requestId, with subclasses per status for instanceof checks:
ts
import { HevkarError, RateLimitError, ValidationError } from '@hevkar/sdk';
try {
await hevkar.agents.run('triage', { input });
} catch (err) {
if (err instanceof ValidationError) console.error(err.code, err.fields);
else if (err instanceof RateLimitError) console.log(`retry in ${err.retryAfter}s`);
else if (err instanceof HevkarError) console.error(err.code, err.message, err.requestId);
else throw err;
}See SDK errors for the class list.