# Rate limits

> How many requests a token and an account can make, the headers that say how much is left, and what to do with a 429.

Source: https://docs.clouduxe.com/api/rate-limits/

The limits are sized for automation: bulk listing, polling and
managing many services at once. Each response tells you how much of the tightest limit is
left, so your code can slow down before it is refused.

## The limits

| Limit | How much |
| --- | --- |
| Reads per token | 1,200 a minute |
| Writes per token | 240 a minute |
| Reads per account, all tokens together | 3,000 a minute |
| Writes per account, all tokens together | 600 a minute |
| Failed authentications from one address | 30 a minute, then that address is refused for 10 minutes |
| Services ordered per account | 120 an hour |
| Power actions per service | 30 in 10 minutes |
| Reinstalls per service | 5 an hour |
| Root password resets per service | 5 an hour |
| Plan change requests per service | 1 in 10 minutes |
| Tickets per account | 20 opened, 120 replies and 60 uploads an hour |

If you need more services an hour, ask support to raise your account's order
limit.

## Read the headers

Every response carries four headers for the limit nearest to running out:

| Header | What it says |
| --- | --- |
| `RateLimit-Limit` | How many requests the limit allows. |
| `RateLimit-Remaining` | How many are left. |
| `RateLimit-Reset` | Seconds until a request frees up. |
| `RateLimit-Policy` | The limit and its window, such as `1200;w=60`. |

## When you are refused

A request over a limit answers `429` with a `Retry-After` header, in seconds,
and one of three codes:

- [`rate_limited`](https://docs.clouduxe.com/api/errors/#rate_limited): a request limit is spent.
- [`action_limit_reached`](https://docs.clouduxe.com/api/errors/#action_limit_reached): a per-service
  limit on power actions, reinstalls or password resets is spent.
- [`order_limit_reached`](https://docs.clouduxe.com/api/errors/#order_limit_reached): the account has
  ordered its hourly maximum of services.

Wait for `Retry-After`, then send the same request again. For a write, keep the
same `Idempotency-Key` (see [Idempotency](https://docs.clouduxe.com/api/idempotency/)). The SDKs do this
for you, honouring `Retry-After`.

If the limits cannot be checked for a moment, a write is refused with `503`
[`limits_unavailable`](https://docs.clouduxe.com/api/errors/#limits_unavailable) and a read goes
through. Retry the write.

## Polling

Read an action at most once every 2 seconds while you wait for it, or skip
polling and listen for the `action.completed` webhook. See
[Long-running actions](https://docs.clouduxe.com/api/actions/).
