# Rate limits

> Koil's per-Organization and per-Profile request budgets, and how they differ from platform limits.

Every request with an API key Koil accepts is charged to the sliding-window budget of the Organization that owns the key, however many keys and addresses you send from. That budget grows with the active Profiles you have, so it keeps pace as you add customers. A request Koil could not check the key for (`503 service_unavailable`) counts against nothing, and no Organization can spend another's budget.

A request that acts on a Profile is also charged to that Profile's budget, in the same charge: a content request, a Profile's own routes, and a publish or backfill request once for each distinct Profile its items name. The Profile budget is smaller than the Organization's, so one of your customers' brands bursting cannot starve the others. A batch that names a spent Profile is refused whole and counts against nothing, so resubmit it without that Profile's items or after `Retry-After`.

Requests with no key, and keys Koil rejects, are charged to the client address, in separate budgets. Keyless requests never block a valid key sent from the same address. A rejected key counts once however often it is retried, and is answered `401` again without being checked until its window passes, so a revoked key still in use somewhere never blocks your valid key. An address that has sent its budget's worth of different rejected keys is refused (`429`) before Koil checks a new one, valid ones included, until its window frees a request.

| Budget | Default |
| --- | --- |
| Per Organization, across its keys | 1,000 requests per minute, plus 5 for each active Profile |
| Per Profile, for requests that act on it, across the keys | 120 requests per minute |
| Per client address, for requests with no key or a rejected key | 60 requests per minute |

These are defaults, and Koil may raise them. Pace your integration by the `RateLimit-*` headers and `Retry-After`, never by numbers copied from this table.

Authenticated responses carry `RateLimit-Limit`, `RateLimit-Remaining`, and `RateLimit-Reset` (seconds until a request is freed). They describe whichever budget the request was charged to has the fewest requests left: the Organization's, or that of a Profile it acts on. A request over budget answers `429` with `rate_limit_exceeded` and a `Retry-After` header: the seconds until every spent budget frees a request. The error's `meta.budgets` names each spent budget (`organization`, `profile`, or `client_address`; Koil may add others, so treat an unknown one as covering the whole Organization), and `meta.profileIds` the spent Profiles, so you can hold back one brand's requests rather than all of them. If Koil cannot check its budgets at all, a request with a valid key still runs, without the `RateLimit-*` headers, and a request with no key answers `503` with `service_unavailable` and a `Retry-After` header; nothing was attempted, so retry it.

## Platform limits

These budgets protect Koil's API. Platforms enforce their own limits on your app and on each account, and a platform throttle surfaces separately as `platform_rate_limit`, with `Retry-After` when the platform gives one. A publish request waits out a short platform throttle before it fails; see [When a publish fails](https://docs.koil.co/guides/publishing#when-a-publish-fails). YouTube's daily quota, for example, is per Google Cloud project; see [YouTube](https://docs.koil.co/platforms/youtube).
