MileCheck
MileCheck API › Reference

What do MileCheck API errors and rate limit headers mean?

Every /v1 response has a request id. Errors have a code you can match on. Keys with a daily limit get the limit headers on every call.

Headers on every response

HeaderMeaning
X-Request-IdUnique to this call, like req_9f2c…. Error bodies repeat it as request_id. Send it to info@milecheckapp.com and we can find the call.
X-RateLimit-LimitCalls allowed per UTC day on this key. Not sent for keys with no daily limit.
X-RateLimit-RemainingCalls left today, after this one.
X-RateLimit-ResetWhen the count resets, in epoch seconds. Always the next UTC midnight.
Retry-AfterOn a 429 only: seconds until the reset.

Browsers can read all of these headers across origins. To check your numbers without spending a call, use GET /v1/usage.

Error body

The old error text is still there. New clients should match on code.

HTTP/1.1 401
X-Request-Id: req_9f2c41d07a3b5e8c1d20

{
  "error": "Invalid API key.",
  "code": "invalid_api_key",
  "message": "Invalid API key.",
  "docs": "https://milecheckapp.com/api/errors/#invalid_api_key",
  "request_id": "req_9f2c41d07a3b5e8c1d20"
}

Error codes

CodeStatusCause and fix
missing_api_key401No key sent. Use ?apikey=, an x-api-key header, or Authorization: Bearer.
invalid_api_key401The key is not one we issued. Check for a trailing space or a rotated key.
key_inactive402The key was turned off, usually a cancelled subscription. Email sales@milecheckapp.com.
key_expired403A test key ended (14 days) or a key passed its end date. Email sales@milecheckapp.com to start a plan. GET /v1/usage still works and shows the end date.
state_not_available403This source is not available for that state or province. The body names the state and the reason.
forbidden403The call is not allowed for this key.
unsupported_state404The state or province code is not one we cover. The body lists the supported codes.
not_found404No such endpoint or record.
method_not_allowed405Wrong HTTP method. The message says which to use.
invalid_parameter400 or 422A parameter is missing or out of range, such as lat without lon. The message names it.
bad_request400The request could not be read.
rate_limit_exceeded429The daily limit for this key is used up. Wait for Retry-After seconds, or ask for a higher limit.
upstream_unavailable502 or 503The source feed (a state DOT, CBP and so on) is not answering. Retry in a minute. Feed health is also in source_status on successful responses.
internal_error500Our side failed. Retry once; if it repeats, send the request id.

What counts against your limit

Every authenticated call that reaches the limit check counts, including ones that then return a 4xx for a bad parameter. Unauthenticated calls, /v1/health and GET /v1/usage do not. A call refused with 429 is not counted again.

Retry on 429 and 5xx with a pause. Do not retry other 4xx errors; they will fail the same way.

Our mission

Become the trusted source for road information across North America, from today’s closures to next season’s roadwork.

What we do

We put every state’s Department of Transportation data in one place, on your phone, in your car and in your browser.

Our values

More in our privacy policy and our story.