Skip to content

Log In

Log in to receive an account token (also called the user token). Pass this token as a Bearer token in subsequent requests. A new account verifies its email first: opening the emailed link signs it in the first time, and every later sign-in is this one.

Password sign-in is for the web client: each request carries the answer of the human check the web client shows by its form. A script or a bot gets its token through OAuth instead; see Scripting needs Premium.

Endpoint

POST /api/v1/token/login/

Request

import httpx
response = httpx.post(
"http://localhost:8731/api/v1/token/login/",
json={
"email": "[email protected]",
"password": "yourpassword",
"turnstile_token": "the-token-from-the-widget",
},
)
token = response.json()["auth_token"]

Response

{
"auth_token": "your-token-here"
}

The human check

Sign-in, registration, email verification and a new verification link each carry a turnstile_token: the answer of the Cloudflare Turnstile widget the web client shows by the form. The widget usually passes by itself, with no puzzle to solve. A token works once, only on the form it was made for and only on this game’s own site. The server checks it with Cloudflare before it looks at the password, and changes nothing for a token that does not pass.

AnswerWhen
422turnstile_token is missing, empty or longer than 2,048 characters. Cloudflare is not asked.
400 The human check did not pass. Complete it again, then resubmit.Cloudflare did not accept the token: it was used already, it expired, or it was made on another form or another site.
503 The human check could not be confirmed right now. Try again in a few seconds.Cloudflare did not answer in time. The answer carries Retry-After: 5.

A request over a rate limit is answered 429 first, and its token is never sent to Cloudflare. The web client asks the widget for a new token after every attempt, whatever the answer.

Against a local development server (one running with DEBUG=true and no Turnstile keys), Cloudflare’s test token XXXX.DUMMY.TOKEN.XXXX passes in place of a widget’s, and nothing else does. A real deployment accepts only a token from its own widget.

Using the Token

Include the token in all authenticated requests:

Authorization: Bearer your-token-here

Tokens expire after 30 days. A free account may hold 5 tokens at a time; a premium or creator entitlement raises that to 25. Expired tokens are cleared automatically and never count.

Signing in never fails because you hold too many tokens. At the limit, the new token replaces your oldest one, and that token stops working at once, with 401 Unauthorized. “Oldest” means issued earliest, regardless of when it was last used. Tokens an agent holds (the ones from the OAuth flow) are replaced only when you have no other token to give up: the oldest account or realm token goes first, even if an agent’s token is older. A realm login never replaces the account token it is called with.

A browser sign-in mints two tokens (your password login, then the realm login), so on a free account a third device’s realm login revokes ONE token: the first device’s account token. The first device keeps playing on its realm token until it makes an account call (listing your players, a realm login), which answers 401; sign in there again. If something of yours keeps using an old token, sign in once per session and reuse the token rather than signing in over and over, or you cycle your older tokens out.

Sign-in is rate limited, per client address and per account: over the limit you get 429 Too Many Requests with a Retry-After header. An address you signed in from in the last 30 days (your 16 most recent addresses) skips the per-account limit, so nobody else can lock you out of it. Sign in once and keep the token rather than signing in for every session.

Keep this token: it is the only one that can do account-level actions — listing, creating and deleting your players, realm login and listing your tokens. A realm token or an agent’s OAuth token gets 403 Forbidden there. See the three token kinds.

Where the token works

On a free account, this token and the realm token you exchange it for work only in the web client, in a current browser. Playing there never requires an entitlement. Anywhere else (a script, a bot, a command line), every endpoint that takes a token refuses them:

AnswerWhen
403 Scripting needs Premium. The tokens of a free account work only in the web client, in a current browser. A script, a bot or an agent needs a premium or creator entitlement and gets its own token through OAuth: see Scripting needs Premium in the docs.A free account’s account or realm token, sent from outside the web client.

That detail is the code a client branches on. A 401 still comes first (a token that does not exist, has expired, or belongs to an unverified or deactivated account). The 403 signs nothing out: the same token keeps working in the web client. To script, get a premium or creator entitlement and a token through OAuth (Scripting needs Premium). On a premium or creator account the account and realm tokens work outside the web client too. The MCP endpoint and the OAuth token exchange require the entitlement whatever the token.

Unverified email

An account whose email is not verified yet cannot sign in. Once the password checks out, the login answers 403 Forbidden with exactly:

{
"detail": "Email address not verified. Open the link we emailed you, or ask for a new one."
}

A wrong password is still 400 Bad Request with Invalid credentials., so only someone who knows the password sees the 403. Open the link from your registration email (it verifies the address and signs you in), or ask for a new one with POST /api/v1/users/verify-email/resend/. The login on the MCP consent page refuses the same way, with a button that mails a new link. See Verify Your Email.

Until the address is verified, no token of the account works either: should it hold one (only an older Restfall release could have issued it), it answers 401 Unauthorized with Invalid token., exactly as a token that does not exist, on every endpoint and on the MCP endpoint’s tool calls, and an agent cannot exchange an authorization code issued to it (invalid_grant, with the Email address not verified. text above). Verifying the address makes those tokens work again.

Deactivated accounts

An account the operator has deactivated cannot sign in: the login answers 400 Bad Request with User account is not active., and so does the login on the MCP consent page. Every token it already holds (account, realm and agent tokens alike) answers 401 Unauthorized with Invalid token., exactly as a token that does not exist, on every endpoint and on the MCP endpoint’s tool calls. An agent cannot exchange an authorization code for such an account either (invalid_grant). The web client signs out on that 401.

Log Out

POST /api/v1/token/logout/

import httpx
httpx.post(
"http://localhost:8731/api/v1/token/logout/",
headers={"Authorization": "Bearer your-token-here"},
)

Destroys the token the request carries, whatever its kind.