Error Handling
Understand BrowserSolver API error responses and learn how to handle each case gracefully.
Every request to the BrowserSolver API returns a standard HTTP status code. This guide covers what each code means, when credits are consumed, and how to handle failures in your integration.
Response format
Successful responses return a JSON object with the data for that endpoint. Error responses follow a consistent structure:
{
"error": "Human-readable description of what went wrong"
}Always check the HTTP status code before reading the body. The search endpoints under /finder/ are the exception: they put the message in a detail field instead of error.
Status codes
200 Success
Billed. The request completed successfully. Credits are deducted from your balance.
const res = await fetch(url, { headers: { "x-api-key": API_KEY } })
if (res.status === 200) {
const data = await res.json()
// process data
}201 Async Job Completed
Billed. An asynchronous job finished successfully. You never receive 201 as an HTTP response — it is the final status recorded in your request logs for an async call, and this is the moment the job is billed. Your balance is checked before the job is queued, so a job never starts without the credits to pay for it.
202 Accepted (Async)
Not billed. The async request was accepted and queued for processing. Poll GET /v1/jobs/{job_id} for the result. Polling is free. The job is billed when it ends: on success (recorded as 201 in your request logs), or when it ends in 404 unless the endpoint is set not to charge not-found results. Failed jobs (400, 500) are never billed.
400 Bad Request
Not billed. Your request contains invalid or missing parameters.
Common causes:
- A required query parameter is missing
- A parameter value has the wrong type or format
- The request body is malformed
What to do: Re-read the endpoint documentation and verify every required parameter. Log the full request URL to spot typos.
if (res.status === 400) {
const { error } = await res.json()
console.error("Bad request:", error)
// do not retry, fix the parameters first
}401 Unauthorized
Not billed. Returned for authentication issues and rate limiting. Check the error message to distinguish between them.
Your x-api-key header contains an unrecognized value (Invalid API Key), or the request has no key at all (No X-API-Key header or Authorization token provided).
Fix: Copy your key from API → API keys in your dashboard and make sure the x-api-key header is present on every request.
402 Payment required
Not billed. The request was not executed. The error string tells you why:
Payment required— API quota and credits cannot cover the callYou have open invoices: …— an unpaid invoice is blocking the workspaceInsufficient credits: X required, Y available— a per-row endpoint would return more rows than you can afford
What to do:
- Purchase a pack or upgrade your plan from Billing → Subscription in your dashboard, or pay open invoices: the same page lists them under Unpaid invoice(s).
- Or enable Auto Top-Up to prevent balance exhaustion from happening again.
Auto Top-Up only triggers when your balance is below the configured threshold. The balance is checked periodically rather than on every request, so a burst of calls can still get 402 before the next check. A built-in 72-hour cooldown also prevents multiple charges in a short period: once a top-up fires, it cannot trigger again for 72 hours regardless of how your balance moves. If a charge fails, Auto Top-Up is automatically disabled to protect your workspace.
Do not retry a 402 response immediately. The call will fail again until you add credits. Set up an alert so your team is notified when this happens.
if (res.status === 402) {
// alert your team or trigger an auto top-up flow
throw new Error("Insufficient credits. Top up at https://app.browsersolver.com")
}403 Forbidden
Not billed. The request was refused before it ran. The usual causes are an endpoint that does not exist on your plan, a deactivated workspace, or an IP temporarily blocked after repeated failed authentications.
On Stats, HTTP 403 means API Stats is not enabled for this workspace. The error field says to contact support to activate it.
What to do: Check the endpoint path against the reference, then confirm your workspace is active in the dashboard. For API Stats, open a support ticket and ask us to enable it. Contact support if you believe this is a mistake.
404 Not Found
Billed, unless the endpoint is set not to charge not-found results. The request ran but found nothing for your input. Handle it as an empty result rather than an error.
if (res.status === 404) {
// handle "no result" gracefully, not as a fatal error
return null
}500 Internal Server Error
Not billed. An unexpected error occurred on our side.
What to do: Retry with exponential backoff. If the issue persists, contact support.
async function fetchWithRetry(url: string, options: RequestInit, maxRetries = 3) {
for (let attempt = 0; attempt <= maxRetries; attempt++) {
const res = await fetch(url, options)
if ((res.status !== 500 && res.status !== 503) || attempt === maxRetries) return res
const delay = 500 * 2 ** attempt
console.warn(`${res.status} error, retrying in ${delay}ms (attempt ${attempt + 1}/${maxRetries})`)
await new Promise(r => setTimeout(r, delay))
}
}Complete error handler
A single function that covers every status code:
interface ApiResult<T> {
data: T | null
error: string | null
status: number
retryable: boolean
}
// The credits charged for each call are listed in the request log of the dashboard.
async function apiCall<T>(url: string, apiKey: string): Promise<ApiResult<T>> {
const res = await fetch(url, {
headers: { "x-api-key": apiKey },
})
if (res.status === 200) {
return { data: (await res.json()) as T, error: null, status: 200, retryable: false }
}
const body = await res.json().catch(() => ({}))
const error: string = body?.error ?? body?.detail ?? "Unknown error"
let retryable = false
switch (res.status) {
case 400:
console.error("[400] Bad request, fix your parameters:", error)
break
case 401:
if (error.startsWith("Rate limit exceeded:")) {
console.warn("[401] Plan rate limit, back off and retry")
retryable = true
} else if (error.startsWith("Rate limit exceeded for the API key")) {
console.error("[401] Per-key quota reached, do not retry:", error)
} else {
console.error("[401] Auth error, check your API key:", error)
}
break
case 402:
console.error("[402] No credits remaining. Top up at https://app.browsersolver.com")
break
case 403:
console.error("[403] Forbidden, check your key permissions")
break
case 404:
// billed unless the endpoint is set not to charge not-found results
console.warn("[404] Not found, no result for this request")
break
case 500:
case 503:
console.error(`[${res.status}] Server error, retry with backoff`)
retryable = true
break
default:
console.error(`[${res.status}] Unexpected status:`, error)
}
return { data: null, error, status: res.status, retryable }
}Retry strategy
| Status | Retry? | Strategy |
|---|---|---|
400 | No | Fix the request first |
401 Rate limit exceeded: … (plan) | Yes | Wait a few seconds, then retry with backoff |
401 Rate limit exceeded for the API key: … (quota) | No | Raise the key's quota or use another key |
401 (auth) | No | Fix the API key |
402 | No | Add credits or settle invoices first |
403 | No | Check permissions, or contact support to activate API Stats |
404 | No | Handle as empty result |
500 | Yes | Exponential backoff (max 3 attempts) |
503 | Yes | Exponential backoff (max 3 attempts) |
Billing summary
| Status | Billed |
|---|---|
200 (sync call) | Yes |
201 (async job completed, in request logs) | Yes |
202 (async accepted) | No. The job is billed when it ends (201 or 404 in your request logs) |
404 | Yes, unless the endpoint is set not to charge not-found results |
| All other codes | No |
See the Credits page for a full cost breakdown per endpoint. For broader integration advice, see Best Practices.
The official SDKs already handle authentication, retries and errors for you.