Rate limits

Per-key request limits, X-RateLimit headers, 429 responses with Retry-After, plan quotas (X-Quota) and how to retry with backoff.

There are two kinds of limits: the rate limit (how many calls you can make per unit of time) and plan quotas (how many resources you can create, for example invoices per year).

Rate limit

Each API key has a per-minute request limit: by default 3,000 requests per minute, more than enough for a normal integration. It may be adjusted to protect the service, so don't hard-code it: read it from the headers.

Every response to an API key request includes:

HeaderDescription
X-RateLimit-LimitRequests allowed in the current window.
X-RateLimit-RemainingRequests left in the window.
X-RateLimit-ResetWhen the window resets (seconds since epoch, UTC).
HTTP/1.1 200 OK
X-RateLimit-Limit: 3000
X-RateLimit-Remaining: 2987
X-RateLimit-Reset: 1793527260
X-Request-Id: req_01JBQ8A1B3C5D7E9F1G3H5J7K9
HTTP

If you exceed it, the API answers 429 Too Many Requests with a Retry-After header (seconds) and the same value in the body:

{
  "detail": "Has superado el límite de peticiones. Vuelve a intentarlo en 12 segundos.",
  "code": "rate_limited",
  "retry_after": 12,
  "request_id": "req_01JBQ8B2C4D6E8F0G2H4J6K8M0"
}
JSON

The limit applies per key: two integrations with different keys don't share the same allowance.

Plan quotas

Some resources have a plan maximum (invoices per year, customers, document scans, storage…). Requests that consume quota include:

HeaderDescription
X-Quota-FeatureResource consuming quota (e.g. invoices_per_year).
X-Quota-LimitPlan maximum for the period.
X-Quota-UsedUsed in the period.
X-Quota-RemainingAvailable.
X-Quota-PeriodQuota period (e.g. the current year).
X-Quota-Hard-Limittrue if creation is blocked when the maximum is reached.

When a hard quota runs out, the API answers 402 with "code": "quota_exceeded". Retrying makes no sense: upgrade the plan or wait for the next period. If a resource belongs to a module the organization doesn't have, the response is 403 module_not_available.

Retrying with backoff

  1. On 429, wait exactly Retry-After seconds.
  2. On 500, 502, 503 or 504, or a network error, wait with exponential backoff with jitter: 0.5 s, 1 s, 2 s, 4 s… (capped at about 30 s) times a random factor.
  3. Cap the number of attempts (4–6) and log the X-Request-Id of every failure.
  4. On POST and PATCH reuse the same Idempotency-Key on every attempt.
import { setTimeout as sleep } from "node:timers/promises";
 
export async function billoraFetch(url, init = {}, maxAttempts = 5) {
  for (let attempt = 1; ; attempt++) {
    let res;
    try {
      res = await fetch(url, { ...init, signal: AbortSignal.timeout(30_000) });
    } catch (err) {
      if (attempt >= maxAttempts) throw err;
      await sleep(jitter(attempt));
      continue;
    }
    if (res.status !== 429 && res.status < 500) return res;
    if (attempt >= maxAttempts) return res;
    const retryAfter = Number(res.headers.get("Retry-After"));
    await sleep(res.status === 429 && retryAfter ? retryAfter * 1000 : jitter(attempt));
  }
}
 
const jitter = (attempt) => Math.min(30_000, 500 * 2 ** (attempt - 1)) * (0.5 + Math.random() / 2);
JavaScript

Best practices

  • Request large pages (page_size=200) when syncing instead of many small pages.
  • Use incremental sync with updated_after and webhooks instead of polling everything.
  • For bulk jobs, limit concurrency (for example 4–8 parallel requests) and watch X-RateLimit-Remaining.
  • Cache data that hardly changes: series, taxes, categories, payment methods.