Errors
A refusal from the service is JSON with one field, error, a sentence written to be read by a person and to say what to change:
{ "error": "unknown profile `base`; driving, walking, cycling or rail" }Match on the status code, not on the sentence. The wording is for people and may be improved; the status is the contract. The one exception with more than error in it is a batch job's 409, which adds the job's progress.
Every status
| Status | Means | Retry? |
|---|---|---|
400 | The request was admitted and the route could not answer it: a parameter out of range, a coordinate that does not parse, an unknown profile, or a data layer that is not loaded. | No — change the request. |
401 | No key, or one the service does not know: never issued, revoked, or its account suspended. | No. |
403 | The key's plan does not include this route's product, or the request is larger than the plan allows. The body names the plan that would answer. | No — it is an upgrade. |
404 | A batch job id this key's account never issued. Also, with an empty body, a path that does not exist. | No. |
405 | A method the path does not have, with an empty body. | No. |
409 | Batch results asked for before the job is done. The body carries done, rows and remaining_s. | Yes, after remaining_s. |
413 | A body over the limit: 64 MiB for a batch file, 2 MB for any other body. | No — split it. |
415 | A JSON body sent without Content-Type: application/json. | No — set the header. |
422 | A JSON body whose fields have the wrong types. On the keyless /demo/v1, also a point outside its city, as JSON. | No. |
429 | This product's bucket is empty: faster than the plan's sustained rate. Carries Retry-After. | Yes, after Retry-After seconds. |
500 | Something failed that should not have. | Yes, with backoff. |
503 | The pod cannot reach its control plane and its entitlements are too old to trust. | Yes. |
JSON from the service, plain text from the framework
Some requests are refused before any route runs, by the HTTP framework parsing them — and those refusals areplain text, not JSON. A client that always parses an error body as JSON will throw on them. Both official clients handle this; if you parse bodies yourself, check Content-Type first.
- A query parameter that does not parse as its type —
limit=three— is400,Failed to deserialize query string: …. - A path segment that does not parse — a tile
zthat is not a number — is400,Invalid URL: …. - A JSON body without its content type is
415; malformed JSON is400; well-formed JSON with a field of the wrong type is422. - A body over the limit is
413.
A parameter that does not parse
Failed to deserialize query string: limit: invalid digit found in stringA real response, captured from the service at commit b8f4bde-dirty.
A JSON body without its content type
Expected request with `Content-Type: application/json`A real response, captured from the service at commit b8f4bde-dirty.
Unknown parameters are ignored, not refused
A parameter the route does not take is dropped silently. That keeps an old client working when a parameter is retired, and it is also the source of the most confusing failure there is: a misspelt parameter behaves exactly as if it had not been sent. /v1/validate?q=… is refused because q is not one of its parameters — text is — so validation saw no address at all:
HTTP/1.1 400 Bad Request
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 292
ratelimit-reset: 1
{
"error": "give `text`, or at least `street`"
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
When an answer looks as though a parameter was ignored, check its spelling against thereference first.
Bounds are clamped, not refused
A numeric parameter with a range — limit, seconds, level,radius_m, samples — is clamped to it. limit=500 on geocoding answers 50, because asking for more than the most there is to give is not an error. The range of every parameter is on its reference page. The exceptions are counts that define the request itself — the number of points in a matrix or a trace, rows in a batch file, beacons in a locate — which are refused when out of range, because clamping them would answer a different question.
A missing layer is a 400; an empty answer is not an error
Each route answers from a data layer — roads, transit, rasters, vessels. Where the layer a route needs is not loaded, the route says so: 400, no roads layer loaded. Where the layer is loaded and simply has nothing at that place, most routes answer 200 with an empty result rather than an error, because "nothing here" is an answer:
/v1/geocode,/v1/reverseand/v1/nearbyanswer an emptyresults./v1/timezoneanswers with every fieldnullwhere no zone holds the point./v1/routeanswersfound: falsewhen the two points are not connected;/v1/snapanswerssnapped: nullbeyond 9 km of any road./v1/conditionsanswers an empty list when no station is within the radius, and/v1/vesselanswerslatest: nullfor a vessel never seen./v1/herenever fails for a missing layer; the layer just contributes nothing.
Where an input names something that does not exist, the refusal lists what does:
HTTP/1.1 400 Bad Request
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 296
ratelimit-reset: 1
{
"error": "no raster layer `solar_ghi`; loaded: elevation, ecmwf_10u, ecmwf_10v, ecmwf_2t, ecmwf_msl, ecmwf_tp"
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
The refusals, as the service sends them
401 — no key
HTTP/1.1 401 Unauthorized
content-type: application/json
{
"error": "an API key is required: Authorization: Bearer sk_live_…"
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
403 — a plan without the product
HTTP/1.1 403 Forbidden
content-type: application/json
{
"error": "the free plan does not include routing; Routing ($299/mo) does"
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
429 — faster than the plan's rate
HTTP/1.1 429 Too Many Requests
content-type: application/json
ratelimit-limit: 2
ratelimit-remaining: 0
ratelimit-reset: 1
retry-after: 1
{
"error": "address is limited to 2 requests a second, burst 2; try again in 1 s. There is no monthly quota."
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
400 — an input the route does not accept
HTTP/1.1 400 Bad Request
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 299
ratelimit-reset: 1
{
"error": "unknown profile `base`; driving, walking, cycling or rail"
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
404 — a job id nobody issued
HTTP/1.1 404 Not Found
content-type: application/json
ratelimit-limit: 20
ratelimit-remaining: 97
ratelimit-reset: 1
{
"error": "no job with that id"
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
409 — results before the job is done
HTTP/1.1 409 Conflict
content-type: application/json
ratelimit-limit: 20
ratelimit-remaining: 99
ratelimit-reset: 1
{
"done": 0,
"error": "that job is queued",
"remaining_s": 5,
"rows": 5
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
In the clients
Both clients raise one class per refusal, all subclasses of GeoError, each carrying the status, the message, the parsed body, the headers and the rate-limit values:
| Status | Class |
|---|---|
400 | BadRequest |
401 | AuthError |
403 | PlanError |
404 | NotFound |
429 | RateLimited |
503 | Unavailable |
| no answer | TransportError (status 0): a timeout, a refused connection. |
| anything else | GeoError |