Skip to main content
PlaySmart uses JSON Web Tokens (JWT) signed with HS256 to authenticate API requests. When you register or log in, the API returns two tokens. You send the access token with every protected request, and use the refresh token to obtain new credentials when the access token expires.

Tokens

PlaySmart issues two tokens on every successful authentication: The access token’s 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.
Tokens are not revocable server-side. If a token is compromised, it remains valid until it expires. Treat both tokens like passwords: store them in secure, device-local storage and never log or transmit them in plain text.

Register a new player

Send a POST 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
string
required
A valid email address. Must be unique across all players.
string
required
The player’s password. Minimum 8 characters.
string
required
A stable, unique identifier for the player’s device. Stored as auth_user_id.
Example request
Example response201 Created

Log in an existing player

Send a POST request to /auth/login with the player’s credentials. The response structure is identical to registration. Request fields
string
required
The player’s registered email address.
string
required
The player’s password.
Example request
Example response200 OK

Using the access token

Pass the access_token in the Authorization header on every request to a protected endpoint:
The API also accepts the token in an X-Forwarded-Authorization header, which takes precedence over Authorization when both are present.

Error responses