Account
Accounts and sessions
Register, sign in, refresh and end sessions, reset a password and delete an account through the API.
These routes are what the dashboard calls. All paths are relative to https://api.perkhost.com/api/v1. Request and response fields are listed in "API reference: account and sign-in".
Register
POST /auth/register takes name, email and password (8 to 128 characters) and always answers 202 with { "status": "check_email" }, whether or not the address is already registered, so it never reveals who is registered. A new address is emailed a link that works once and expires in 60 minutes; POST /auth/register/confirm with its token and the same password creates the account and a personal workspace named after you, with you as its owner, and signs you in (a native app sends client here, not to /auth/register, to get a refresh token). A registered address is emailed a note that someone tried to sign up, with links to sign in or reset the password, and no second account is created.
Sign in
POST /auth/login takes email and password. The answer depends on who is calling.
- A browser session sends no
clientfield and receivestokenanduser. The token is valid for 7 days. - A script, tool or native app sends
clientwith aplatform(web,cli,mcporapi) and anameof up to 100 characters. It receivestoken,expiresAt(Unix seconds),refreshTokenanduser. The access token lasts 15 minutes and the refresh token 30 days. - An account with two-factor authentication on receives
mfaRequired: trueand anmfaTokeninstead of a session. Finish the sign-in withPOST /auth/mfa/verify. The challenge expires after 5 minutes.
Ten failed sign-ins for one email address within 15 minutes lock that address for 15 minutes. Sign-in, registration and the other public routes are also rate limited, and a limited request gets 429 with a Retry-After header.
curl -sS -X POST https://api.perkhost.com/api/v1/auth/login \
-H 'Content-Type: application/json' \
-d '{"email":"you@example.com","password":"your password","client":{"platform":"api","name":"my script"}}'Use the access token
Send it as Authorization: Bearer <token>. Every route except the public ones needs it.
Refresh a session
POST /auth/refresh takes the refreshToken and returns a new token, expiresAt and refreshToken. The refresh token rotates on every use: keep the new one. Presenting a refresh token that was already used ends that session, revokes your current access tokens and revokes your API tokens, because it can mean the token was copied. A replay within 5 seconds of the rotation, as from a retry, is treated more narrowly: it ends that session and revokes only the API tokens created in it. Never reuse an old refresh token.
Sign out and manage sessions
POST /auth/logoutends the session. Send therefreshToken, a bearer access token, or both. It answers 204.GET /auth/sessionslists the sessions that have a refresh token, which are the ones started with aclient: scripts, tools and native apps. Each hasid,platform,name,createdAt,lastUsedAtandcurrent. A browser session is not listed.DELETE /auth/sessions/{sessionId}ends one of them. An unknown id gets 404.
Signing out does not end API tokens
Reset a password
POST /auth/forgotwith theemail. The answer is always 200 with the same body, whether or not an account exists, so it never reveals who is registered.- If the account exists, PerkHost emails a link. It works once and expires after one hour.
POST /auth/resetwith thetokenfrom the link and a newpassword. It answers 204. A reset also revokes the account's API tokens.
Delete an account
DELETE /auth/me with your password deletes the account and answers 204. A wrong password answers 403. A workspace in which you are the only owner or admin, or in which nobody but client members would be left, is deleted together with its data. In every other workspace your membership is removed and what you created passes to another owner or admin. The request is refused with 409 while a workspace that would be deleted still has a paid subscription that is not set to cancel, or live apps.
Google sign-in
GET /auth/google/config says whether Google sign-in is enabled. The dashboard runs the sign-in flow itself and sends the result to POST /auth/google. A Google account whose email address already belongs to a password account gets 409 with the code account_exists_use_password, and an address Google has not verified gets 401 with google_email_unverified.