Skip to content

Limits and rate limits

Every count, size and rate limit lives in the Limits schema component — one machine-readable home, each value pinned with const to what the database guards actually enforce. Read them from there; they are deliberately not repeated in prose, because a second copy would drift. The length of a single field, such as a label or a key, is the maxLength on that field’s own schema instead. Exceeding a limit answers 400 validation-failed (1 MB body → 413, rate limit → 429).

GET /me returns those same values in its limits member, generated from the same constant — so a client that does not want to parse this document can read every limit at runtime from the call it makes first anyway. Your key’s own rate limit is rate_limit_per_min on that response, which overrides limits.default_rate_limit_per_min.

A body over 1 MB answers 413 payload-too-large. The cap is enforced on the way in, before a key is even resolved: it is measured from Content-Length when you send one and from the stream otherwise, and its problem body carries no errors[], since no field was reached. The oversized upload is drained before the response is written, so you receive the 413 rather than a reset connection.

Per-key fixed window of one minute. The restaurant Owner sets a key’s limit when minting it, and left blank it is 120 requests/minute. No route changes the limit of an existing key, so a different limit means a new key (see Getting a key); GET /me reports yours as rate_limit_per_min. The window opens with the first request of a burst and resets a minute later, not on the clock minute, so a burst that straddles a reset can spend up to twice the limit in a short span. POST /batch consumes one token per item — a 100-item batch costs 100 tokens. A batch the current window cannot fit answers 429 and costs one token, not its item count; one longer than your key’s limit could never fit a window, so it answers 400 validation-failed instead. A replay of a batch under its Idempotency-Key writes nothing and costs one token, like any other request. POST /loyalty/members/import consumes one token per member by the same rules, a dry run included (see Loyalty club members). POST /definitions/proposals costs 10 tokens; one the window cannot fit answers 429 and costs one.

On 429: read Retry-After (seconds) and X-RateLimit-*, wait, then retry the same request. X-RateLimit-Reset is the Unix time, in seconds, at which the window resets. The body carries the same wait as retry_after, so a client that parses only JSON is not stranded:

{
"type": "https://ninetables.io/problems/rate-limited",
"title": "Too Many Requests",
"status": 429,
"detail": "Rate limited. Retry after 37s.",
"code": "RATE_LIMITED",
"retry_after": 37
}

On a 429, X-RateLimit-Remaining is 0, except on a POST /batch, a POST /loyalty/members/import or a POST /definitions/proposals refused because its cost did not fit, where it is the tokens still left in the window (for a batch or an import, the most items or members it could still carry).

The unauthenticated flood ceiling. A second limit governs only the requests that never reach an authenticated key: 3000 requests per 5 minutes. It answers the same rate-limited 429 as the per-key limit — same type, same retry_after member, same Retry-After and X-RateLimit-* headers — so you need no second handler for it. Tell the two apart by X-RateLimit-Limit: the ceiling reports 3000, the per-key limit reports your key’s own limit (which GET /me gives you as rate_limit_per_min).

Which address does it count? None. It reads no CF-Connecting-IP, no X-Forwarded-For and no peer address, because every one of those is a value the sender chooses at this hop — a limit keyed on one can be evaded by rotating it, and worse, spent under your own egress address by someone who has never held your key. So this API does not key on an address at all. A fleet of workers behind one NAT is therefore sized by the per-key limit, not by this one, and your budget is never shared with a stranger who happens to route through the same gateway.

What it counts instead is two separate counters, each shared by everyone in its class:

  • no Authorization header — one counter, covering every path.
  • an Authorization header that does not resolve to an active key — one counter, shared across every rejected credential. A retry loop against a revoked key is governed here and nowhere else, and past the ceiling it answers 429 in place of 401. Rotating the token does not open a new budget.

A request that authenticates is never counted here and cannot be refused by it. Present a working key and the only limit you meet is your own.

Its headers appear on its own 429 and nowhere else: unlike the per-key limit, it reports no running balance on success, so you cannot track this budget continuously. Stay well under it rather than steering by it. Do not treat it as your protection against a volumetric flood either: it stops one from reaching dispatch, nothing more.

X-RateLimit-Limit, -Remaining and -Reset ride on every response for a request that was charged a token — 2xx, 429, and every error in between — so you can track quota continuously without ever provoking a 429.

The exceptions are the rejections that happen BEFORE the charge, which cost you nothing and therefore report nothing:

  • 401 — no key resolved, so there is no bucket to report.
  • 403 app-not-installed — the restaurant has the Customer Data app uninstalled, and the key is refused as it resolves, ahead of the scope gate.
  • 403 insufficient-scope for a scope the operation is “required by” — the scope gate runs ahead of the charge. A scope the ApiScope component lists as “also required” depends on the request, not the route, so it is checked inside the handler: every such 403 is charged and does carry the headers.
  • 400 for a body that is missing, not JSON-typed, or not parseable JSON — the request-body contract, checked before the charge.
  • 413 payload-too-large — the 1 MB cap is enforced on the way in, before a key is even resolved.

So: headers present ⇒ a token was spent; headers absent ⇒ none was. X-NT-API-Version is on every response regardless.