Error Codes
All errors return JSON with error and code fields, even when the request specified an image format.
Error response format
{
"error": "No credits remaining",
"code": "PAYMENT_REQUIRED",
"buy_url": "/pricing"
}Error reference
| HTTP | Code | Error | Fix |
|---|---|---|---|
| 400 | BAD_REQUEST | Missing or invalid parameters | Check the required parameters for the endpoint. |
| 400 | INVALID_REQUEST | Missing or invalid parameters on /api/v1/locations | brand is required; radius_km requires city. |
| 400 | INVALID_FORMAT | Format not served by /api/v1/locations | That route serves json and geojson only. The body returns valid_formats. |
| 400 | INVALID_COUNTRY | country is not ISO 3166-1 alpha-2 | Send the country’s own alpha-2 code. Never map a subdivision code to its prefix — CN-TW → CN returns mainland China for a Taiwan query. Taiwan is TW. |
| 401 | UNAUTHORIZED | Invalid or missing API key | Add the x-api-key header with a valid bm_live_* key. |
| 403 | INSUFFICIENT_SCOPE | Your key is not authorized for that route | The body returns required_scope and granted_scopes. Authorization is by scope, not billing model. |
| 403 | DATA_ACCESS_FORBIDDEN | A standard-tier key asked for location data | Use a data-enabled key. |
| 402 | PAYMENT_REQUIRED | No credits remaining | Purchase credits at /pricing or switch to metered billing. |
| 402 | TRIAL_EXPIRED | Trial duration ran out | Upgrade at /billing . The upgrade_url field in the error body points there. |
| 402 | TRIAL_EXHAUSTED | Trial credits ran out before duration | Same as above — convert your trial to a paid plan. |
| 402 | TRIAL_INSUFFICIENT | This request would cost more credits than your trial has left | Trim the query (filter by country/state/city), or upgrade. |
| 404 | NOT_FOUND | No locations found for brand | Check brand spelling. Must match an indexed OSM brand tag exactly. |
| 429 | RATE_LIMIT_EXCEEDED | Too many requests | Wait for the seconds given in Retry-After. See Rate Limits. |
| 500 | INTERNAL_ERROR | Server error | Retry after a few seconds. If persistent, contact support. |
On GET /api/v1/locations specifically
402 and the trial-cap headers are not reachable on that route: both formats it serves are data formats, so a trial or standard-tier key is refused at the data-access gate before any row is served, and every principal that can reach a 200 is charged nothing. See Locations API.
A 500 there never degrades to an empty success — 200 with count: 0 genuinely means zero matching rows. Treat 500 as retryable and never overwrite a good snapshot with the result of a failed call.
Handling errors in code
const res = await fetch("https://api.brandmappr.com/api/v1/locations?brand=Dutch%20Bros&country=US", {
headers: {
"x-api-key": process.env.BRANDMAPPR_KEY
},
});
if (!res.ok) {
const err = await res.json();
console.error(`${err.code}: ${err.error}`);
if (res.status === 402) {
// Redirect to purchase page
window.location.href = err.buy_url;
}
return;
}
const data = await res.json();Last updated on