code and next_action for
program behavior. Show error and next as plain text. Do not match the
wording of error or next.
Some responses add fields, such as
limit, reset_at, or
retry_after_seconds. The sections below name them.
Handle an error response
- Read the HTTP status.
- Make sure that the body is JSON before you read
code. - Use the status and
codetogether to select the client branch. - Show
errorandnextas plain text. Do not render them as HTML or run them as commands. - Use
next_actionfor automatic recovery. If the client does not recognize the action, stop and show the error. - Before you retry, use the retry rules.
code. A proxy or network failure can
produce this result.
For logs, record the HTTP status and code. Do not log the full body,
credentials, or recovery tokens.
Error codes
The samecode can occur on more than one route. The next text and the
next_action values can change by route. Use the returned values.
An unknown ID and an ID that you cannot access can return the same response.
Do not use error text to find which account owns an ID.
Retry rules
Use the code and the operation to decide on a retry. The status alone is not sufficient.- Do not retry
validation_failed,invalid_json,unauthorized,ingest_key_invalid,forbidden,not_found, ormethod_not_allowedwithout a change. Correct the request or the credential first. - For
rate_limited, wait forretry_after_secondsor theRetry-Afterheader when present. Then use exponential backoff with jitter. Do not start parallel retries for one failed request. - For
usage_limit_exceeded, stop ingestion untilreset_ator until the plan changes. A fast retry loop cannot change an allowance. - For
request_timeoutand5xxresponses, you can send a read again with the same scope. A timeout does not prove that the result is empty.
429. Keep their fields separate. Read the
current allowance from the account API.
Writes
A timeout, a5xx response, or a network failure does not prove that a write
failed. Before you send a write again:
- If the route supports an idempotency key, send the same key and the same body again. Use a new key only for new work.
- If the route has no idempotency key, read the resource first. Send the write again only if the change is not present.
- If you cannot find the result, stop automatic retries and tell the user.
idempotency_conflict means that the key belongs to a different request. Do
not change the body of a retry that uses the original key.
Examples
These examples show the envelope shape. Theerror and next text can be
different on each route.
Authentication failure
Unsupported method
Rate limit
usage_limit_exceeded response adds limit and reset_at. limit is
events or bytes.
Account recovery available
This response addsdeleted_at and a short-lived recovery_token. Keep the
token in protected client state. Do not put it in logs, URLs, screenshots,
support reports, or agent prompts.
