Errors
Errors are returned as JSON with an HTTP status code that reflects the problem.
Error shape
{
"message": "Add an authorization header to the request: \"bearer <token>\"",
"errorCode": "UNAUTHENTICATED"
}message is human-readable; errorCode is a stable machine-readable code you
can branch on. Some validation errors include additional context fields.
Common status codes
| Status | Meaning | When |
|---|---|---|
400 | Bad Request | Malformed input — e.g. a partial SharePoint filter on /index/progress. |
401 | Unauthorized | Missing or invalid bearer token (UNAUTHENTICATED / FORBIDDEN). |
404 | Not Found | Unknown id, e.g. GET /documents/{id}. |
409 | Conflict | Synchronous indexing requested while the docset is already indexing. |
422 | Unprocessable Entity | Request was well-formed but couldn’t be acted on — e.g. a source that can’t be reached. |
503 | Service Unavailable | A required server-side capability is disabled. |
Handling auth errors
const res = await fetch(`${process.env.API_URL}/ask`, options)
if (res.status === 401) {
const { errorCode } = await res.json()
// UNAUTHENTICATED → no token sent; FORBIDDEN → wrong token
throw new Error(`Auth failed: ${errorCode}`)
}