How do I read Unison error responses?

Understand the Unison error envelope: every error is a JSON object with a snake_case code and a human-readable message.

My request failed. What does the error response look like?

Every Unison API error uses the same envelope format:

{
  "error": {
    "code": "snake_case_error_code",
    "message": "Human-readable description of what went wrong."
  }
}

The HTTP status code tells you the category; the code field tells you the specific cause.

Common codes

HTTPcodeMeaning
400invalid_requestMalformed JSON or a missing required field.
401unauthorizedMissing or invalid Authorization header.
403forbiddenKey doesn't have permission for this operation or path.
404not_foundThe page or resource doesn't exist.
409conflictOptimistic-concurrency conflict — re-read and retry.
422unprocessable_entityRequest is syntactically valid but semantically wrong (e.g., invalid path format).
429rate_limitedToo many requests — back off and retry.
500internal_errorSomething went wrong on Unison's side. Retry with exponential backoff.

Handling errors in code

const res = await fetch('https://brain.unisonlabs.ai/v1/brain/context?q=foo', {
  headers: { Authorization: `Bearer ${token}` },
});

if (!res.ok) {
  const { error } = await res.json();
  console.error(`[${error.code}] ${error.message}`);
}

Branch on error.code for recoverable errors (429, 409, 500); surface the message for debugging.

See also: Handling 429s, Concurrency conflicts.

On this page