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
NO_ACCESS403The key cannot reach this company or this action.
INVALID_FIELD400Body validation failed — see `issues`.
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.
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