POST /auth/register creates a new account and returns tokens immediately, and POST /auth/login does the same for returning players. Both return the same response shape, so your token-handling code only needs to be written once.
Register a new player
Call A successful registration returns HTTP
POST /auth/register with the player’s email address, a password of at least 8 characters, and a deviceId that uniquely identifies their device. The deviceId becomes the player’s auth_user_id and is used as the JWT sub claim on every subsequent request.201 with the following body:Store tokens securely
Save both tokens on the device immediately after registration or login.
access_token— valid for 30 days. Include this in theAuthorizationheader on every authenticated request.refresh_token— valid for 180 days. Use this to obtain a newaccess_tokenwhen the current one expires.
PlayerPrefs.Log in returning players
For a player who already has an account, call A successful login returns HTTP
POST /auth/login with their email and password. No deviceId is needed here.200 with the same response shape as registration:Error handling
| HTTP status | Error code | Meaning |
|---|---|---|
409 CONFLICT | email_already_registered | An account with that email already exists. Prompt the player to log in instead. |
401 UNAUTHORIZED | invalid_credentials | The email and password combination does not match any account. |
400 BAD_REQUEST | invalid_payload | The request body failed validation — for example, the password is fewer than 8 characters or the email is malformed. Check the details field in the response for specifics. |
