Skip to Content
Errors

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

StatusMeaningWhen
400Bad RequestMalformed input — e.g. a partial SharePoint filter on /index/progress.
401UnauthorizedMissing or invalid bearer token (UNAUTHENTICATED / FORBIDDEN).
404Not FoundUnknown id, e.g. GET /documents/{id}.
409ConflictSynchronous indexing requested while the docset is already indexing.
422Unprocessable EntityRequest was well-formed but couldn’t be acted on — e.g. a source that can’t be reached.
503Service UnavailableA 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}`) }