429 can come from either.
Per API key (the application). Each API key has its own quota: by default 120 requests
per minute, in a fixed window aligned to the clock minute. Every key counts on its own, also
two keys of the same tenant, and partner keys (cufea_partner_) have their own quota too. A
request counts once its key authenticates, whatever the answer; a replay of an
Idempotency-Key also counts. A missing or invalid key gets 401 and uses no quota.
Every response of a route that takes a key, errors included (except that 401), carries:
Over the quota the answer is
429 with code rate_limited, the three headers
(X-RateLimit-Remaining: 0) and Retry-After, equal to X-RateLimit-Reset. /v1/health and
/openapi.json take no key and carry none of these headers.
429 carries only
Retry-After, without X-RateLimit-* headers or a problem body from the API.
Both limits are deployment settings and can change; read the headers instead of hard-coding
the numbers. Retry-After is in integer seconds (RFC 9110 delay-seconds, not
milliseconds): wait at least that long before the next request, rather than a fixed delay.
To avoid the 429 altogether, slow down when X-RateLimit-Remaining gets low. Retrying a
create or a send after a 429 is safe with its Idempotency-Key.