Browse this section
API reference

Errors

Error format, codes and how to handle them.

Errors use standard HTTP status codes and a JSON body:

{
  "error": {
    "type": "permission_denied",
    "message": "User marja@example.com does not have access to knowledge base kb_01j9…",
    "request_id": "req_01j9x…",
    "doc_url": "https://www.brewmycode.com/docs/api/errors#permission_denied"
  }
}

Include request_id when contacting support.

StatustypeMeaning
400invalid_requestMalformed body or parameters; message explains which
401unauthenticatedMissing or invalid API key
403permission_deniedKey lacks a scope, or as_user lacks access
404not_foundResource doesn't exist or isn't visible to you
409conflictDuplicate name, or version already promoted
422unprocessableValid syntax but semantically invalid (e.g. approval policy references unknown tool)
429rate_limitedSee Rate limits; retry after Retry-After seconds
500internal_errorOur fault; safe to retry with backoff
503unavailableTemporary; retry with backoff

Idempotency

POST requests that create resources or trigger runs accept an Idempotency-Key header. Repeating a request with the same key within 24 hours returns the original response instead of creating a duplicate.

Retries

SDKs retry 429, 500 and 503 with exponential backoff (up to 3 attempts by default). Do not retry 4xx other than 429.