Skip to content

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-…"
}
FieldMeaning
codestable, machine-readable code: branch on this
messageEnglish description for logs and developers; may change
paramsvalues filled into the message, e.g. { "scope": "runs:read" } (when the code has any)
fieldsper-field messages for invalid bodies (VALIDATION_FAILED, INPUT_INVALID); keys are dotted paths, _ for the whole body
requestIdthe 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 ​

StatusTypical codesWhat to do
400VALIDATION_FAILED, INPUT_INVALID, INPUT_REJECTED, INPUT_TOO_LONG, FILE_TYPE_NOT_ACCEPTED, ASYNC_STREAM_CONFLICT, AGENT_TYPE_MISMATCHfix the request; do not retry unchanged
401INVALID_API_KEYcheck the key (missing, revoked, expired)
402QUOTA_EXCEEDED, STORAGE_LIMIT_REACHEDspend cap or storage limit reached
403MISSING_SCOPE, AGENT_NOT_ALLOWED (the key is restricted to other agents), ORG_SUSPENDEDchange the key's scopes or agents
404NOT_FOUND, FILE_NOT_FOUND, VERSION_NOT_FOUND, APPROVAL_NOT_FOUNDcheck ids and slugs (scoped to the key's project)
409AGENT_NOT_PUBLISHED, IDEMPOTENCY_IN_PROGRESS, IDEMPOTENCY_KEY_REUSED, RUN_NOT_CANCELLABLE, EVENT_NOT_EXPECTEDstate conflict: read the message
413FILE_TOO_LARGEsmaller file
415FILE_TYPE_NOT_SUPPORTEDunsupported file type
429RATE_LIMITED, REALTIME_SESSION_LIMITwait retry-after seconds, then retry
5xxINTERNAL, PROVIDER_ERROR, DOC_WORKER_UNAVAILABLEretry 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.

Hevkar public API v1