# Limits

> How many calls a key may make, how many machines an account may hold, the largest request, file, command and output, and what happens when the money runs out.

What the API takes at once, and how fast. Every answer says how many calls the key has left.

On every answer:

```http
HTTP/1.1 200 OK
RateLimit-Policy: "key";q=600;w=60
RateLimit: "key";r=59;t=1
```

## Calls a minute

Each key may make 600 calls a minute, unless it was made with another `rate_per_minute` (1 to 6000, and never more than the key that made it). It may make up to a tenth of them at once, and at least 10; after that, calls are let through at the key's pace.

Every answer carries two headers:

- `RateLimit-Policy`: `q` is the key's calls a minute, over a window `w` of 60 seconds.
- `RateLimit`: `r` is how many calls can be made at once now, and `t` the seconds until all of them are back.

A call over the limit answers [`429 rate_limited`](https://docs.wheelmachine.ai/errors/rate_limited.html), with `Retry-After`: the seconds until the next call is let through. The libraries and `wm` wait and try again by themselves. An address that keeps calling with keys that do not work is held to about 30 tries a minute.

## Machines

An account holds up to 100 machines made through the API, deleted ones aside. One more answers [`429 limit_reached`](https://docs.wheelmachine.ai/errors/limit_reached.html): delete one first. An account may also have a limit on the machines it has running or kept at once; reaching it answers the same code, and pausing, archiving or deleting a machine makes room.

## Sizes

| What | Limit |
|---|---|
| A request's JSON | 1 MiB |
| A file written in one call | 5 GiB |
| A command's run | 10 minutes |
| A command's output | 8 MiB each for stdout and stderr; cut there, and `truncated` says so |
| A command's words (`command`) | 4096 |
| A line of shell (`shell`) | 131072 characters |
| Environment variables | 256 a command |
| A path in a machine | 1024 characters |
| A name (machine, project or key) | 80 characters |
| Labels | 32 a machine; a name up to 63 characters, a value up to 200 |
| A snapshot's note | 200 characters |
| A wait (`wait_s`, `timeout_s`) | 0 to 600 seconds a call |
| Idle before a machine pauses (`idle_after_s`) | 60 to 86400 seconds |
| A page of a list (`limit`) | 1 to 200; 50 when not said |
| An `Idempotency-Key` | 255 printable characters; its answer is kept 24 hours |
| A key's calls a minute (`rate_per_minute`) | 1 to 6000; 600 when not said |

## Money

Machines run while the account can spend. When it cannot - its limit for the month is reached, or the account is held - its running machines are paused within about half a minute, with their memory kept, and making, starting or copying machines, running commands and reaching files answer [`402 payment_required`](https://docs.wheelmachine.ai/errors/payment_required.html). Once it can again, `start` brings the machines back where they were. `wm me` says whether the account can spend, and what is left this month.
