API
API reference: account and sign-in
Every route for registering, signing in, sessions, password reset, Google sign-in and two-factor authentication.
Paths are relative to https://api.perkhost.com/api/v1. "Session" means a bearer access token from sign-in. Read "API overview" for errors and limits. A body that is not listed for a route means the route takes none.
Sign-in and sessions
| Route | Auth | Request body | Success |
|---|---|---|---|
| POST /auth/register | Public | name, email, password (no client: a native app sends it to /auth/register/confirm) | 202 and { "status": "check_email" } for every address; the outcome is emailed |
| POST /auth/register/confirm | Public, with the emailed token | token, password (the one chosen at sign-up), optional client | 201, a session: token and user; with client also expiresAt and refreshToken; 400 for an invalid, expired or used link or a wrong password |
| POST /auth/login | Public | email, password, optional client | 200, a session as for register/confirm, or mfaRequired, mfaToken and expiresAt when two-factor is on |
| POST /auth/forgot | Public | email | 200, the same message for every address |
| POST /auth/reset | Public, with the emailed token | token, password | 204 |
| POST /auth/refresh | Refresh token | refreshToken | 200, token, expiresAt and a new refreshToken |
| POST /auth/logout | Refresh token or session | optional refreshToken | 204 |
| GET /auth/me | Session | none | 200, id, email and name |
| DELETE /auth/me | Session | password | 204 |
| GET /auth/sessions | Session | none | 200, a list of id, platform, name, createdAt, lastUsedAt, current for sessions started with a client |
| DELETE /auth/sessions/{sessionId} | Session | none | 204 |
client is { "platform": "web" | "cli" | "mcp" | "api", "name": "<1 to 100 characters>" }. Registration, sign-in, password reset, refresh and account deletion are rate limited per address, per email or per user.
Google sign-in
| Route | Auth | Request body | Success |
|---|---|---|---|
| GET /auth/google/config | Public | none | 200, { "enabled": false } or enabled, clientId and authorizationEndpoint |
| POST /auth/google | Public | code, codeVerifier, nonce, redirectUri | 200, a session, as for login |
Two-factor authentication
| Route | Auth | Request body | Success |
|---|---|---|---|
| GET /auth/mfa | Session | none | 200, enabled, totpEnabled, emailEnabled, emailPending, pending, enabledAt, recoveryCodesRemaining, requiredBy, daysLeft |
| POST /auth/mfa/verify | Sign-in challenge | mfaToken and one of code, recoveryCode, emailCode | 200, a session, as for login |
| POST /auth/mfa/enrol | Session | password | 200, secret and otpauthUri |
| POST /auth/mfa/enable | Session | password, code; with email codes on, also one of emailCode or recoveryCode | 200, recoveryCodes and session |
| POST /auth/mfa/disable | Session | password and one of code or recoveryCode | 200, session |
| POST /auth/mfa/recovery-codes | Session | password and one of code, recoveryCode or emailCode | 200, recoveryCodes |
| POST /auth/mfa/email/send | Sign-in challenge | mfaToken | 202, message |
| POST /auth/mfa/email/enrol | Session | password | 200, sentTo and expiresAt |
| POST /auth/mfa/email/enable | Session | password, code; with the authenticator on, also one of authenticatorCode or recoveryCode | 200, recoveryCodes and session |
| POST /auth/mfa/email/step-up | Session | password | 200, sentTo and expiresAt; 409 when email codes are off, 503 when the email cannot be sent |
| POST /auth/mfa/email/disable | Session | password and one of code, recoveryCode or emailCode | 200, session |
The session in an enable or disable answer carries the token to use from then on, and expiresAt for native sessions. Authenticator codes and email codes are 6 digits. A recovery code looks like xxxxx-xxxxx; case, spaces and hyphens are ignored when it is checked.