Tokens
PlaySmart issues two tokens on every successful authentication:| Token | Header claim | Expiry | Purpose |
|---|---|---|---|
access_token | Authorization: Bearer | 30 days | Authenticate API requests |
refresh_token | — | 180 days | Re-authenticate after access token expiry |
sub claim contains the player’s auth_user_id. Protected endpoints read this claim to identify the caller. The refresh token carries a kind: "refresh" claim and is used solely to issue a new access token — pass it to /auth/login or a dedicated refresh endpoint as appropriate for your integration.
Register a new player
Send aPOST request to /auth/register to create a player account. The deviceId you provide becomes the player’s permanent auth_user_id and is embedded as the JWT sub claim.
Request fields
A valid email address. Must be unique across all players.
The player’s password. Minimum 8 characters.
A stable, unique identifier for the player’s device. Stored as
auth_user_id.201 Created
Log in an existing player
Send aPOST request to /auth/login with the player’s credentials. The response structure is identical to registration.
Request fields
The player’s registered email address.
The player’s password.
200 OK
Using the access token
Pass theaccess_token in the Authorization header on every request to a protected endpoint:
X-Forwarded-Authorization header, which takes precedence over Authorization when both are present.
Error responses
| HTTP status | code | message | Cause |
|---|---|---|---|
400 Bad Request | BAD_REQUEST | invalid_payload | Request body is missing, malformed, or fails validation (e.g. password too short, invalid email) |
401 Unauthorized | UNAUTHORIZED | invalid_credentials | Email not found, or password does not match |
401 Unauthorized | UNAUTHORIZED | missing_bearer_token | Protected endpoint called without an Authorization header |
409 Conflict | CONFLICT | email_already_registered | A player with this email address already exists |
