Error Handling

The Glance API uses standard HTTP status codes, and every failure carries a machine-readable code alongside a human message. Branch on the code, not on the message — the message is Hebrew and is written for a person to read.

Error Response Format

{
  "success": false,
  "error": {
    "status": 404,
    "code": "DOCUMENT_NOT_FOUND",
    "message": "המסמך לא נמצא"
  }
}

Validation failures add an issues array — the Zod issues for the fields that failed:

{
  "success": false,
  "error": {
    "status": 400,
    "code": "INVALID_FIELD",
    "message": "שדה לא תקין",
    "issues": [
      {
        "path": [
          "products",
          0,
          "price"
        ],
        "message": "price must be zero or greater"
      }
    ]
  }
}
One older shape. A few endpoints — the internal note, the execution status, and the identifier checks on document creation — answer with a bare { "error": { "code", "message", "issues" } } and no success key. Read error.code and you handle both shapes.

HTTP Status Codes

CodeMeaningDescription
200OKRequest succeeded
201CreatedResource created successfully
400Bad RequestInvalid request body or parameters
401UnauthorizedMissing or invalid API key
403ForbiddenAPI key lacks required permissions
404Not FoundResource does not exist
409ConflictIdempotency-key conflict, or a resource that already exists
429Too Many RequestsRate limit exceeded — see Rate Limits
500Internal Server ErrorSomething went wrong on our end

Common Error Codes

CodeStatusWhen
UNAUTHORIZED401Missing, unknown or expired API key.
API_KEY_OWNER_INACTIVE401The user who created the key is no longer an active member of the company. A company owner has to create a new key.
API_KEY_REQUIRED400GET /apiKeys/me was called without an API key (for example with a dashboard session).
NO_ACCESS403The key is valid but cannot reach this company or this action.
INVALID_FIELD400Validation failed — a body field (see `issues`), a non-numeric id, or a date that is not YYYY-MM-DD / ISO 8601.
DOCUMENT_NOT_FOUND404No document with that visibleId, externalId or related id.
DOCUMENT_CLOSED400The target document is already settled.
INVALID_STATUS400The operation does not apply in the document's current state.
CREDIT_LIMIT_EXCEEDED409POST /documents/create/{type}: the document would take the client past its credit limit and the company's policy is "block". `error.details` carries `creditLimit`, `totalObligation`, `documentEffect`, `excess` and `canOverride`; an owner-level key may resend with `creditLimitOverride: true`.
CLIENT_OVERDUE_DEBT409POST /documents/create/{type}: the client has an open invoice more than `overdueBlockDays` past its due date and the company blocks on it. `error.details` carries `overdueBlockDays`, `overdueAmount`, `overdueDocuments`, `maxDaysOverdue` and `canOverride`; an owner-level key may resend with `creditLimitOverride: true`.
DUPLICATE_EXPENSE409POST /expenses/create: the vendor already has an expense or supplier invoice with this `documentNumber`. Resend with `allowDuplicate: true` if it is intended.
INSTALLMENTS_EXCEED_MAX400A card charge asks for more installments than the business allows — the body carries `maxInstallments`.
INVALID_CLIENT_TYPE400Unknown `type` filter on GET /clients.
INVALID_CLIENT_IDS400A `clientIds` token on GET /documents is not a positive integer.
INVALID_DOCUMENT_TYPE400Unknown `type` filter — the response names `invalidTypes` and `supportedTypes`.
INVALID_CURSOR400The change-feed cursor was not one we issued.
INVALID_UPDATED_SINCE400`updatedSince` is not a valid ISO 8601 date.
INVALID_EXTERNAL_ID400`externalId` is empty or longer than 64 characters.
INVALID_IDEMPOTENCY_KEY400`Idempotency-Key` is not a string, or exceeds 255 characters.
IDEMPOTENCY_KEY_REUSED409The same key was already used for a different request body.
REQUEST_IN_PROGRESS409A request with this key is still being processed.
RATE_LIMITED429Over the per-key limit — the body carries `retryAfter`.
Tip: check error.issues for field-level detail before retrying a 400 — the same body will fail again.
Retrying a failed write. A 4xx or 5xx on document creation releases the Idempotency-Key, so you may fix the body and retry with the same key. Never retry a create without one — see Idempotency.

Last updated