Documentation menu

Concepts

Errors & retries

The Wayline error format, which errors to retry, exponential backoff with jitter, honoring Retry-After and keeping retries safe and idempotent.

Updated Dec 1, 2026 View Markdown

Error format

Errors use one JSON envelope and a stable code:

json
{
  "error": {
    "code": "OUT_OF_COVERAGE",
    "message": "Point is outside every enabled region.",
    "field": "destination",
    "request_id": "req_01JD8Q4ZK7V3",
    "docs_url": "https://www.wayline.cloud/docs/errors#out-of-coverage"
  }
}

Branch on code, not on message — messages may change. The full list is in the error reference.

What to retry

StatusRetry?
400, 401, 402, 403, 404No — fix the request, key or account.
429Yes, after Retry-After seconds.
500, 503, network errors, timeoutsYes, with exponential backoff and jitter.

Exponential backoff with jitter

Wait random(0, min(cap, base × 2^attempt)) between attempts. A good default: base 250 ms, cap 8 s, at most 3–5 attempts. Always honor Retry-After when present.

javascript
async function withRetry(fn, { attempts = 4, base = 250, cap = 8000 } = {}) {
  for (let i = 0; ; i++) {
    const res = await fn();
    const retryable = res.status === 429 || res.status >= 500;
    if (!retryable || i === attempts - 1) return res;
    const retryAfter = Number(res.headers.get("retry-after"));
    const delay = retryAfter > 0 ? retryAfter * 1000 : Math.random() * Math.min(cap, base * 2 ** i);
    await new Promise((r) => setTimeout(r, delay));
  }
}

All official SDKs implement this for you.

Idempotency

Every Wayline endpoint is a read — calculating a distance twice has no side effects — so retries are always safe. Because errors are not billed and a retried request that eventually succeeds is billed once, retrying never double-charges you for a failure.

Timeouts

Set a client timeout (10 seconds is a sensible default). Large matrices take longer than single distances; size your timeout to your largest request.