API

Auth

Register, login, and CLI device approval.

POST /auth/register

Creates the account. First user on a fresh install is admin. Sets a token cookie in browsers.

json
curl -X POST https://api.portlify.ru/auth/register \
  -H "Content-Type: application/json" \
  -d '{"mail":"you@domain.com","password":"at-least-8"}'

Response: { user, token }. Password minimum 8 characters. 409 if the email exists.

POST /auth/login

curl -X POST https://api.portlify.ru/auth/login \
  -H "Content-Type: application/json" \
  -d '{"mail":"you@domain.com","password":"at-least-8"}'

Same shape as register. 401 on bad credentials.

POST /auth/logout

Clears the cookie. Call it from the site. CLI uses portlify logout to drop the saved key.

CLI device login

  1. POST /auth/cli/start with { "redirectUri": "http://127.0.0.1:<port>/callback" } returns code, pollToken, verifyUrl
  2. User opens verifyUrl while logged in on the site and approves
  3. Site calls POST /auth/cli/approve (JWT required) with the code
  4. CLI polls POST /auth/cli/poll with pollToken until it gets a plfy_ key

redirectUri must be localhost HTTP /callback, or a portlify: URL.