Rate limits
A rate limit allows a maximum number of requests in a time window. Clients that go over the limit get 429 Too Many Requests until they slow down.

What you can configure
| Setting | Description |
|---|---|
| Limit | Maximum number of requests allowed |
| Window | The time window, e.g. 1 minute |
| Counted per | Per client address, per client+route, per route, or per signed-in user (token's subject) |
| Routes | Apply to all routes, or only named ones |
| Conditions | Only count requests that match (same conditions as rules) |
| When over the limit | Refuse with 429, or Challenge (send a browser to the proof-of-work check first) |
| Count GraphQL operations | Count each operation in a batch separately |
| Only this GraphQL operation | Only count a named operation (e.g. login) |
Persistence
Rate limit counts are kept across configuration changes and gateway restarts. A client at its limit stays limited for the rest of the window, even after a restart. Only when you change the limit itself (number, window, what is counted, routes or conditions) does the counter start from zero.
Example: protect a login page
Use the preset Protect a login page (Templates and presets), or add a rate limit manually:
- Limit: 10 requests
- Window: 1 minute
- Counted per: client address
- Routes: the route for your login page
- Conditions: method =
POST, path =/login
This allows 10 login attempts per minute per address. The 11th gets 429.
Example: fair use limit for a public API
Add a rate limit:
- Limit: 300 requests
- Window: 1 minute
- Counted per: client address
- When over the limit: Challenge
Bots that exceed the limit are sent to the proof-of-work check. Real browsers pass it without user action; bots that cannot solve it are refused.