Rate Limits
Restfall runs on modest hardware, so the server limits how fast a client may call it. The limits sit far above normal play: the web client never meets them, and neither does an agent or a script that polls its state and acts. They exist to stop one client from crowding out everyone else, and to make password guessing slow.
The limits
Each limit is a burst you may spend at once, refilled at a steady rate. Spend the burst and you can carry on at the refill rate; pause and the burst comes back.
| What is limited | Counted per | Burst | Then |
|---|---|---|---|
Every /api/ and /mcp request that carries a bearer token | token | 40 | 10 per second |
Sign-in: POST /api/v1/token/login/, the login on the MCP consent page, and verifying an email (POST /api/v1/users/verify-email/) | client address | 20 | 1 every 3 seconds |
| Sign-in, as above | IPv6 /48 (IPv6 clients only) | 100 | 1 a second |
| Sign-in, as above | client address and account together | 10 | 1 a minute |
| Sign-in, as above, from an address that is not one of the account’s 16 most recent sign-in addresses of the last 30 days | account (the email) | 100 | 1 every 30 seconds |
Registration: POST /api/v1/users/ and “Create a new account” on the MCP consent page | client address | 5 | 1 every 5 minutes |
| Registration, as above | IPv6 /48 (IPv6 clients only) | 25 | 1 a minute |
A new verification link: POST /api/v1/users/verify-email/resend/ and the MCP consent page’s “send me a new verification link” | client address | 5 | 1 every 5 minutes |
| A new verification link, as above | IPv6 /48 (IPv6 clients only) | 25 | 1 a minute |
| A new verification link, as above | email address asked for | 3 | 1 every 15 minutes |
MCP client registration: POST /oauth/register | client address | 10 | 1 every 10 minutes |
These are the defaults. An operator can tune each one, so a deployment may
differ; the Retry-After header (below) is always the truth.
Requests without a token (the web client’s pages and images, the realm list, the health check) are not limited.
Over the limit: 429 and Retry-After
A request over a limit is answered 429 Too Many Requests with a
Retry-After header, the whole number of seconds until it would be accepted:
HTTP/1.1 429 Too Many RequestsRetry-After: 2Content-Type: application/json
{"detail": "Too many requests. Retry after the number of seconds in the Retry-After header."}Wait at least that long before you send it again. A refused request costs you
nothing: it is not counted, so retrying early does not push your wait further
out. It just gets another 429.
import time
import httpx
def get_with_backoff(client: httpx.Client, path: str) -> httpx.Response: while True: response = client.get(path) if response.status_code != 429: return response time.sleep(int(response.headers["Retry-After"]))
client = httpx.Client( base_url="http://localhost:8731", headers={"Authorization": "Bearer your-realm-token"},)state = get_with_backoff(client, "/api/v1/state/").json()# curl retries a 429 on its own and honours Retry-After.curl --retry 5 http://localhost:8731/api/v1/state/ \ -H "Authorization: Bearer your-realm-token"const BASE_URL = "http://localhost:8731";
async function getWithBackoff(path: string, token: string): Promise<Response> { for (;;) { const response = await fetch(BASE_URL + path, { headers: { Authorization: `Bearer ${token}` }, }); if (response.status !== 429) return response; const seconds = Number(response.headers.get("Retry-After")); await new Promise((resolve) => setTimeout(resolve, seconds * 1000)); }}
const state = await (await getWithBackoff("/api/v1/state/", "your-realm-token")).json();Per token
The token limit counts every request that carries your bearer token, whatever kind of token it is. It is per token, not per account: each of your tokens (the web client’s, an agent’s, a script’s) has its own count. Forty requests at once cover a client’s start-up (the web client opens with a dozen to twenty); ten a second after that is about forty times what a player uses while playing.
Over MCP, one tool call counts once. The /mcp request that carries a
tool call is counted, and the API call it makes for you is not counted again.
The other MCP messages (initialize, listing the tools) count like any
request.
Poll GET /api/v1/state/ at an interval rather than in a
tight loop; the web client polls it about every twelve seconds. The game
resolves marches, battles and timers on its own clock, so polling faster
does not make anything happen sooner.
Sign-in and registration
Sign-in is limited three ways at once (four over IPv6, which also counts
your /48: see client addresses). Every attempt counts
against each of them, successful or not, except as
your known addresses describes.
- Per address keeps one machine from guessing quickly at many accounts. A household or an office behind one address shares it.
- Per address and account keeps one machine from guessing one password.
- Per account keeps many machines from guessing one password together. It counts by the email you sign in with, whether or not an account exists for it, and the answer is the same either way, so the limit never tells anyone whether an email is registered.
Registration is limited per client address (over IPv6, per /48 as well),
never per account.
Verifying your email is a sign-in: it checks your password and signs you in, so it counts against the sign-in limits above, the same counts a log in spends. The client address is counted before the link is even read; the account (the one the link is for) before the password is checked.
Asking for a new verification link
is limited per client address (over IPv6, per /48 as well) and per email
address asked for, whether or not an account uses it, so the limit tells
nobody whether an address is registered, and nobody can fill an inbox with
links. The email address is counted under a keyed hash, never stored as
written.
Your known addresses
When you sign in successfully, the address you signed in from becomes known to your account for 30 days, as long as a token lasts (counted again from every successful sign-in there). From a known address the per-account limit does not apply.
So someone who knows your email can use up the per-account limit and slow
down sign-ins to your account from new addresses, but not from the addresses
you sign in from: there, only what is sent from your own address (over IPv6,
your own /48) counts. The exception is someone who shares your address, on
your home network or behind the same office, campus or mobile-carrier
address: they count against the same per-address limits as you. They can
also find out whether your email signed in from that shared address in the
last 30 days, because the per-account limit then skips their attempts from
it too. That comes with exempting known addresses at all.
An account remembers at most its 16 most recent addresses. The server keeps them as security data, for this purpose only: each one is a keyed hash of the account and the address (never the address itself), and each expires 30 days after its last successful sign-in. The per-address limits count under the same kind of keyed hash, so the limiter stores no client address at all.
Tokens you already hold are not affected either way (they last 30 days), so sign in once and keep the token rather than signing in for every session. A free account holds at most 5 tokens at once, and a sign-in at that cap revokes your oldest token (an agent’s OAuth token last), so reusing one also keeps your older tokens alive (see Log In).
503: busy, or the limiter is down
Checking a password takes the server a noticeable moment of work, and it
checks only a few at once. When a flood of sign-ins keeps it busy, a sign-in
or registration may be answered 503 Service Unavailable with
Retry-After: 1 rather than waiting in a queue. Retry after that second; the
answer says nothing about the email or the password. The attempt has already
counted against the limits above (they are checked first), so do not retry
it in a tight loop.
If the server’s limiter is unavailable, sign-in, registration and MCP client
registration answer 503 Service Unavailable with a Retry-After of a few
seconds instead of going ahead unlimited. Everything else, including play
with the tokens you hold, carries on.
These limits are checked before the human check:
an attempt over a limit is answered 429 without asking Cloudflare. When
Cloudflare does not answer the check in time, the request is answered 503
with Retry-After: 5: the password was not checked and nothing changed, but
the attempt has counted against the limits.
Client addresses
An IPv4 address counts on its own. An IPv6 address counts together with every
other address in its /64, because one subscriber usually has a whole /64
to choose from. Sign-in and registration also count every IPv6 /48 (one
site’s allocation) as one, with a larger limit, so a client cannot multiply
its budget by moving through the /64s of its /48. An X-Forwarded-For
header you send is ignored unless the operator runs Restfall behind proxies
they told it to trust.
Request size
A request body may be at most 64 KiB (65,536 bytes). A larger one is
answered 413 Content Too Large before it is processed:
{"detail": "Request body too large: at most 65536 bytes."}No legitimate request comes near it: the longest message you can send is 2,000 characters.
MCP client registration
POST /oauth/register accepts at most 10 redirect_uris, each at most
2,048 characters, and a client_name of at most 64; more is a 422,
and so is a redirect URI that breaks the
redirect rules (https; http only on a loopback
host; a native app’s own scheme, but never one the browser runs, such as
javascript:; no fragment). See MCP for the registration flow.