Errors and status codes

A tool's error comes back inside its result, as JSON, not as an HTTP status. Only a missing or invalid credential is an HTTP error: 401.

The error envelope

Every error has the same shape. code is stable: branch on it, never on message.

{
  "schema_version": "3.5",
  "error": {
    "code": "NOT_FOUND",
    "message": "No provision matching '999' in this title.",
    "retryable": false,
    "hint": "..."
  }
}

The error may also carry did_you_mean, candidates (for AMBIGUOUS_REFERENCE) and retry_after_seconds (for RATE_LIMITED). No error ever carries internal detail: a server fault returns a reference to quote to support instead.

The codes

CodeMeaningRetryableWhat to do
NOT_FOUNDNothing matches the requestNoCheck the id or number
PROVISION_NOT_INGESTEDThe provision is in the structure, but its text is not heldNoGive the user the Federal Register link
AMBIGUOUS_REFERENCEMore than one thing matches; candidates lists themNoCall again with one candidate's id
INVALID_ARGUMENTA value is malformed or not one the tool accepts, or the response would be too large to return; the message shows the expected form or the parameters to narrowNoCorrect the value, or narrow the request
VERSION_NOT_HELDNo text in force on the requested as_at date is heldNoUse a date the held compilations cover, or omit as_at
TITLE_NOT_IN_FORCEThe title is not in force; its text is never served, for any dateNoTell the user, show the frl_link, do not supply the text from elsewhere
COMPILATION_NOT_CURRENTA newer compilation is registered and not yet held, and withholding is onNoSay a newer compilation exists and give the link
UNAUTHENTICATEDThe call could not be tied to an account or a valid keyNoCheck the credential
FORBIDDENThe account cannot use this tool: the subscription is not active, the feature is withdrawn, or the address is outside a key's allowlistNoRead the message; renew, or check the allowlist
INSUFFICIENT_SCOPEThe connection, or a partner key's client, does not hold the scope this tool needsNoReconnect and approve the permissions, or add the scope to the client
TERMS_REQUIREDA partner organisation has not accepted the current Hansard conditions of useNoAccept them on the partner page
RATE_LIMITEDA partner key's client has used its calls for this minute or dayYesWait retry_after_seconds, then retry
INTERNAL_ERRORA fault on Advisor's sideOnly if retryable is trueRetry once if retryable; otherwise quote the reference to support

TITLE_NOT_IN_FORCE and COMPILATION_NOT_CURRENT are answers about the law, not failures. Withholding is off today, so COMPILATION_NOT_CURRENT is not returned; superseded text is served with compilation.state set to not_current.

Responses over the size limit

A tool response is limited to 8,000 tokens. A response whose items are in one list is cut to fit, keeping the first items in the tool's own order, and says so: page.truncated for a result list, or truncated and truncation_note for a list in the tool's own shape. A response that cannot be cut that way, such as a graph's nodes and edges, is refused with INVALID_ARGUMENT, naming the parameters that narrow the request.

HTTP statuses

StatusWhen
401No credential, or an invalid, revoked or expired one. The WWW-Authenticate header points to the discovery document
200Every tool call that reached a tool, including one that returns an error envelope

Note: A subscriber whose AI Pro subscription has lapsed receives plain text from a paid tool, not an error envelope: a sentence with the renewal link. renew_subscription returns the same link.

What this means for your code

Related pages