Skip to content

Errors & rate limits

Understand error response shapes, HTTP status codes, captcha failure codes, and rate limit handling.

All DraxonCloud customer APIs return structured JSON errors with consistent codes and helpful context.

Error response format

When a request returns HTTP status 400 or higher, the response body contains an error object:

{
  "error": {
    "code": "insufficient_balance",
    "message": "Not enough balance. This costs $0.008 and you have $0.004. Add funds to continue.",
    "details": {
      "required_micros": 8000,
      "available_micros": 4000
    },
    "request_id": "req_8f1b2c3d4e5f"
  }
}
  • code: Machine-readable error name.
  • message: Human-readable description.
  • details: Contextual numbers or field validation issues.
  • request_id: Trace identifier. Always quote this ID when contacting support.

Common error codes

Status Error Code What it means What to do
400 bad_request Malformed JSON or invalid syntax Check payload format
400 price_missing No active price configured for this item Contact support
401 invalid_api_key Key is missing, mistyped, or revoked Verify key in dashboard
401 unauthorized Missing API key in request header Supply Authorization: Bearer or X-Api-Key
402 insufficient_balance Not enough available funds Add funds in dashboard under Billing
402 spend_cap_reached Daily spending limit reached Increase daily cap in dashboard or wait for UTC reset
403 scope_denied Key cannot use this product Update allowed products for the key in dashboard
403 ip_not_allowed Requesting IP not on key allowlist Add IP to key or leave allowlist empty
404 not_found Resource does not exist or not yours Check resource ID
409 conflict Resource state conflict Check existing items before retrying
422 validation_error Missing or invalid field values Fix fields listed in details.fields
429 rate_limited Request rate exceeded Respect Retry-After header
500 internal_error Server error Retry with exponential backoff or report request_id

Captcha task failure codes

When checking a captcha task (GET /api/captcha/v1/tasks/{id}), the task status may be failed or expired.

  • solve_failed: The challenge could not be completed. You are not charged; you may submit a new task.
  • expired: The task was not solved before the timeout (~3 minutes). You are not charged.
  • invalid_task: Parameters or target URL were rejected. Check input fields.
  • Any other code: We could not finish the task on our side. You are not charged. Submit a new task, and contact support with the task id if it keeps happening.

Rate limits and retry backoff

When you make too many requests in a short window, the API returns HTTP 429 rate_limited.

Check the Retry-After response header, wait that many seconds, then retry.

Python retry snippet

import time
import requests

def request_with_retry(url: str, headers: dict, max_retries: int = 5):
    for attempt in range(max_retries):
        resp = requests.get(url, headers=headers)
        if resp.status_code == 429:
            retry_after = int(resp.headers.get("Retry-After", 2 ** attempt))
            time.sleep(retry_after)
            continue
        return resp
    raise RuntimeError("Too many retries; rate limit persists.")

JavaScript retry snippet

async function fetchWithRetry(url, options = {}, maxRetries = 5) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    const res = await fetch(url, options);
    if (res.status === 429) {
      const waitSec = Number(res.headers.get("Retry-After") || Math.pow(2, attempt));
      await new Promise((resolve) => setTimeout(resolve, waitSec * 1000));
      continue;
    }
    return res;
  }
  throw new Error("Too many retries; rate limit persists.");
}

Reporting a problem

If an unexpected error occurs, provide the request_id from the error JSON to support. It maps directly to server logs so we can inspect what went wrong.