Errors and Rate Limits
Apira returns structured JSON errors so agents can decide whether to revise the request, retry later, or stop and ask for operator action.
Error envelope
Errors use this shape:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "query is required",
"status": 400
}
}Validation errors may also include a details array with field-level information.
Common status codes
| Status | Code | Meaning | Agent behavior |
|---|---|---|---|
400 | VALIDATION_ERROR | Request body or parameters failed validation. | Revise the tool arguments before retrying. |
401 | AUTH_ERROR | The API key is missing or invalid. | Stop and ask the operator to configure a valid key. |
403 | FORBIDDEN or INSUFFICIENT_CREDITS | The authenticated user is not allowed to perform the request, or the account has no available credits. | Stop retrying; report the permission or credit issue. |
404 | NOT_FOUND | The requested resource does not exist. | Check the endpoint or URL. |
429 | RATE_LIMIT_EXCEEDED | The request exceeded a configured rate limit. | Back off until Retry-After; preserve task state. |
500 | INTERNAL_ERROR | An unexpected server error occurred. | Retry with jitter if the user task can wait, otherwise degrade gracefully. |
502 | EXTERNAL_SERVICE_ERROR | An upstream service failed. | Retry with jitter or explain the upstream failure. |
503 | RATE_LIMIT_UNAVAILABLE | The rate-limit backend is temporarily unavailable when configured to fail closed. | Retry later; do not spin in a tight loop. |
Rate limits
Default public limits are:
30requests per minute per IP, applied globally before authentication.60requests per minute per authenticated user/account for search traffic.
Authenticated search requests can therefore be constrained by both the global per-IP limit and the authenticated user/account limit.
429 RATE_LIMIT_EXCEEDED responses include:
X-RateLimit-Limit: the limit for the current window.X-RateLimit-Remaining: remaining requests in the current window.X-RateLimit-Reset: Unix timestamp when the current window resets.Retry-After: seconds to wait before retrying.
503 RATE_LIMIT_UNAVAILABLE responses are limiter-backend failures and may include only Retry-After.
Agent retry guidance
Agents should retry only when the error is likely transient:
- Retry
429,500,502, and503with backoff and a maximum attempt count. - Do not retry
400without changing the request. - Do not retry
401or403 INSUFFICIENT_CREDITS; these need operator or account action. - Preserve the user's task state so the agent can resume after waiting.
- Disclose degraded results if the agent falls back to a broader search, cached candidates, or no Apira call.
For exact status codes and schemas, use the OpenAPI JSON.