Authorization API

Melon signs devices in with sessions. Each signed-in device holds a short-lived access token and a refresh token, and shows up in the account's device list where it can be signed out.

For more information on Users, check the Melon User Guide.

Tokens


Summary of Endpoints

EndpointMethodBodyDescriptionAuthorization
/api/server/featuresGETWhat the server supports, e.g. ["stat-filters","auth-v2"].None
/auth/tokenPOST{deviceName} plus Authorization: Basic base64(username:password)Sign in and start a session.None (rate limited)
/auth/refreshPOST{refreshToken}New access and refresh token.None (rate limited)
/auth/logoutPOST{refreshToken} (optional)End that session, or the caller's. Returns 204.None
/auth/media-tokenPOST{token, expiresIn}Admin, User, Pass
/auth/registerPOST{inviteCode, username, password, deviceName}Create an account from an invite and sign this device in.None (rate limited)
/auth/device-linkPOSTOne-time code to sign in another device: {id, code, expiresAt}. Valid 2 minutes.Admin, User, Pass
/auth/device-link/redeemPOST{code, deviceName}Sign this device in with that code.None
/auth/device-link/{id}GET{redeemed, deviceName, expiresAt}, for the device showing the code.Admin, User, Pass
/auth/inviteGETCreate an invite code (?expireMinutes=, up to 30 days).Admin
/auth/checkGET200 if the access token is valid.Admin, User, Pass
/api/users/passwordPATCH{currentPassword, newPassword}Change your password. Other devices are signed out; returns a fresh accessToken for this one.Admin, User, Pass
/api/users/sessionsGETYour signed-in devices (admins: ?userId= for anyone's).Admin, User, Pass
/api/users/sessions/revokePOST{sessionId}Sign a device out. Returns 204.Admin, User, Pass

Token responses look like {accessToken, refreshToken, expiresIn, sessionId, user: {id, username, role}}.


Sign in

POST /auth/token
Authorization: Basic am9obmRvZTpzZWNyZXQ=
Content-Type: application/json

{"deviceName": "Galia on DESKTOP"}

401 means the username or password is wrong. After 5 wrong passwords for one username from one address, the server answers 429 with Retry-After (15 seconds, doubling up to 15 minutes).


Invites

An admin creates a code with auth/invite (or from MelonCLI / MelonGUI) and shares it with the server address, for example as https://your-server/auth/join?code=<code>. Galia reads that link from a QR code or paste. The new user calls auth/register, which checks the code, creates the account and signs the device in. Each code works once.


A signed-in device calls auth/device-link and shows https://your-server/auth/link?code=<code> as a QR code. The new device calls auth/device-link/redeem. The code holds no password, works once and expires after 2 minutes.

Opening /auth/join or /auth/link in a browser shows a short page explaining what to do in the app.