Skip to main content
Every Agntix endpoint returns a consistent error envelope:
{
  "error": {
    "code": "SESSION_NOT_FOUND",
    "message": "The session you requested does not exist or has expired.",
    "requestId": "req_01J2K…"
  }
}
requestId lets support trace a specific call — include it in any bug report.

HTTP status codes

StatusMeaningTypical cause
200 / 201Success
204Success, no bodyDELETE, idempotent updates
400 Bad RequestMalformed inputMissing required field, bad JSON
401 UnauthorizedMissing or invalid authNo x-api-key, expired JWT
403 ForbiddenAuth OK, permission deniedKey lacks the required scope
404 Not FoundResource missingWrong id, deleted resource
409 ConflictIdempotency or uniqueness violationDuplicate name, concurrent modification
422 UnprocessableValidation failedTool config invalid, model not supported for org
429 Too Many RequestsRate limit hitSee Rate limits
500 Internal Server ErrorBug on our sideOpen a support ticket with the requestId
502 / 503 / 504Upstream / overloadRetry with backoff

Application error codes

These appear in error.code and are stable — safe to switch on in client code.

Sessions

CodeMeaningFix
SESSION_NOT_FOUNDThe session id is unknown or expiredVerify the id; sessions auto-expire after the configured idle timeout
SESSION_EXPIREDThe session is past its inactivity windowOpen a new session
SESSION_CREATION_ERRORCould not allocate a sessionOften a downstream model availability issue — retry
INVALID_SESSIONThe session is not valid for the requested operationMake sure the session is in OPEN state
MESSAGES_HISTORY_ERRORCould not fetch message historyRetry; persistent failures are bugs

Models & tools

CodeMeaningFix
MODELS_NOT_FOUNDRequested model is not enabled for your orgPick a different model from GET /v1/chat/models
TOOLS_NOT_FOUNDOne of the tool ids on the agent is missingRe-attach a valid tool
CONFIG_NOT_FOUNDAgent config is missing required fieldsRe-PATCH the agent with a complete config

Auth & permissions

CodeMeaningFix
UNAUTHORIZEDMissing or invalid auth headerSee Authentication

Generic

CodeMeaningFix
ABORT_ERRORThe request was aborted (client disconnected)No fix needed — informational
GENERIC_ERRORUnclassified server-side errorRetry; if it persists, file a ticket with the requestId

Handling errors well

async function call(path, init) {
  const res = await fetch(`https://api.agntix.ai${path}`, init);
  if (res.ok) return res.json();

  const body = await res.json().catch(() => ({}));
  const code = body.error?.code ?? "UNKNOWN";

  if (res.status === 429) {
    const retryAfter = Number(res.headers.get("Retry-After")) || 1;
    await new Promise((r) => setTimeout(r, retryAfter * 1000));
    return call(path, init);
  }

  if (res.status === 401) {
    throw new Error("Auth failed — refresh your API key or JWT");
  }

  throw Object.assign(new Error(body.error?.message ?? `${res.status}`), {
    status: res.status,
    code,
    requestId: body.error?.requestId,
  });
}
Always log requestId along with the error. It’s the single most useful field for debugging.

When to retry

StatusRetry?Strategy
408, 429, 500, 502, 503, 504YesExponential backoff + jitter, max 5 attempts
400, 401, 403, 404, 409, 422NoFix the request and try again