Errors and rate limits
A failed request gets a 4xx or 5xx status and a JSON body with a stable code, the HTTP status and a readable message:
{ "defined": false, "code": "UNSUPPORTED_MEDIA_TYPE", "status": 415, "message": "Unsupported file type. Send a JPEG, PNG, WebP, GIF, TIFF, BMP or AVIF image."}Branch on status or code. The message text may change.
Error codes
Section titled “Error codes”| Status | code |
When it happens | What to do |
|---|---|---|---|
| 400 | BAD_REQUEST |
No image; both file and url; an empty file; an invalid URL or one that is not http(s); invalid parameters. |
Fix the request. Validation errors include details in data.issues. |
| 401 | UNAUTHORIZED |
Missing, invalid or revoked API key. | Check the Authorization: Bearer header and the key. See below. |
| 402 | PAYMENT_REQUIRED |
The free image checks are used up (they do not renew), the last payment failed, or a spending cap was reached. | Read data.reason and data.next. See below. |
| 403 | INSUFFICIENT_SCOPE |
The API key lacks the permission this endpoint needs. | Ask an owner or admin to change the key’s permissions. See below. |
| 404 | NOT_FOUND |
No detection with that id for your organization. | Check the id. |
| 413 | PAYLOAD_TOO_LARGE |
An upload over 25 MB. | Send a smaller image. |
| 415 | UNSUPPORTED_MEDIA_TYPE |
The file is not a JPEG, PNG, WebP, GIF, TIFF, BMP, AVIF or MPO image. HEIC is not supported. | Convert the image to one of these formats. |
| 429 | TOO_MANY_REQUESTS |
More than 120 requests in a minute from your organization, across all of its API keys. | Wait for the Retry-After time (60 seconds), then retry. |
| 5xx | INTERNAL_SERVER_ERROR and others |
A failure on our side. | Retry with backoff. |
A validation error looks like this:
{ "defined": false, "code": "BAD_REQUEST", "status": 400, "message": "Input validation failed", "data": { "issues": [ { "code": "too_big", "maximum": 100, "path": ["limit"], "message": "Too big: expected number to be <=100" } ] }}Missing or invalid key
Section titled “Missing or invalid key”A 401 carries a WWW-Authenticate header that points to the API’s metadata (RFC 9728), and data.next says how to get a key:
HTTP/1.1 401 UnauthorizedWWW-Authenticate: Bearer resource_metadata="https://api.ringingbytes.com/.well-known/oauth-protected-resource"{ "defined": false, "code": "UNAUTHORIZED", "status": 401, "message": "Missing API key. Send it as `Authorization: Bearer <key>`. No key yet? See the agent guide at /auth.md.", "data": { "next": { "action": "get_api_key", "docs_url": "https://api.ringingbytes.com/auth.md", "resource_metadata_url": "https://api.ringingbytes.com/.well-known/oauth-protected-resource", "device_authorization_url": "https://api.ringingbytes.com/v1/agent/device/code" } }}An agent can follow device_authorization_url to ask a person for a key. See Agents.
Payment required
Section titled “Payment required”A 402 always has code: "PAYMENT_REQUIRED". data.reason says why:
data.reason |
When it happens | Who can fix it |
|---|---|---|
free_checks_exhausted |
On Free, the free image checks are used. | Anyone: choose a plan, or an agent asks for a checkout link. |
payment_failed |
The last payment for the plan didn’t go through. | A person, by updating the payment method. |
key_cap_reached |
The check would take the key over its monthly spending cap. | An owner or admin, by raising the cap. Otherwise it resets with the next billing period. |
org_cap_reached |
The check would take the organization over its monthly spending cap. | An owner or admin, by raising the cap. Otherwise it resets with the next billing period. |
data.free_checks_remaining is the number of free image checks left, data.cap describes the cap that was reached (scope, monthly_cap_usd, spend_usd, resets_at; otherwise null), and data.next has the next step and the links for it. Agents has a full example.
Missing permission
Section titled “Missing permission”Keys an agent got through the device flow carry only the permissions a person granted. Calling an endpoint without its permission gets 403, with error="insufficient_scope" in the WWW-Authenticate header:
HTTP/1.1 403 ForbiddenWWW-Authenticate: Bearer resource_metadata="https://api.ringingbytes.com/.well-known/oauth-protected-resource", error="insufficient_scope", scope="billing:checkout"{ "defined": false, "code": "INSUFFICIENT_SCOPE", "status": 403, "message": "This API key does not have the \"billing:checkout\" permission. An owner or admin can change the key's permissions in the dashboard.", "data": { "required_scopes": ["billing:checkout"], "granted_scopes": ["checks:create", "account:read"], "next": { "action": "ask_human", "dashboard_url": "http://localhost:4101/api-keys", "docs_url": "https://api.ringingbytes.com/auth.md" } }}Failed detections
Section titled “Failed detections”If the API accepted a check but could not analyse the image, the response is still 200, with status: "failed", an error object and credits: 0. You are not charged.
{ "status": "failed", "error": { "code": "download_failed", "message": "..." }, "credits": 0}error.code is one of:
error.code |
Meaning |
|---|---|
download_failed |
The URL could not be fetched. |
too_large |
The image is over 25 MB or 120 megapixels. |
unsupported_media |
The file is not a decodable image. |
bad_request |
The URL is not allowed (a private address, or a port other than 80 or 443). |
inference_unavailable |
The detector is not available right now. Retry later. |
inference_timeout |
The detector took too long. Retry later. |
interrupted |
The check was interrupted. Retry. |
internal |
A failure on our side. Retry later. |
Rate limits
Section titled “Rate limits”The API allows 120 requests per minute per organization, shared by all of its API keys and counted across every /v1 endpoint. Creating more keys does not raise the limit. Over the limit, you get HTTP 429 with Retry-After: 60 and { "code": "TOO_MANY_REQUESTS", … }.
To stay under it:
- On
429, wait for theRetry-Aftertime before you retry. Retry5xxresponses with exponential backoff and jitter, for example after 1, 2, 4 and 8 seconds. - Spread batch jobs over time.