cardinal

Auth and setup API

Log in, manage passwords, sessions and API keys, and finish a site's setup over HTTP.

All paths are on the site's host. Bodies are JSON. A cookie session must send x-cardinal-csrf on every POST, PUT, PATCH and DELETE, and a guest's unsafe request must be JSON. API-key requests need no CSRF token.

The session cookie is __Host-cardinal_sid over https and cardinal_sid over http.

Sign in and out

Method and pathBodyAnswers
POST /api/auth/login{login, password}{user, site, csrf_token} and the session cookie. 401 on a bad pair, 429 with Retry-After after too many failures
POST /api/auth/logout{ok: true}, and clears the cookie
GET /api/auth/me{user, setup_state, site, csrf_token}. 401 for a guest
curl -X POST https://erp.acme.com/api/auth/login -c cookies.txt \
  -H 'Content-Type: application/json' \
  -d '{"login": "jane@acme.com", "password": "..."}'

API keys

POST /api/auth/keys with {user} gives that User a new key pair. It needs a signed-in caller with write on the User's API key field. The answer {api_key, api_secret} is the only place the secret appears. Send the pair as Authorization: token KEY:SECRET, Bearer KEY:SECRET or Basic auth.

Passwords

Method and pathWhoBodyDoes
POST /api/auth/password/strengthAnyone{password, user_inputs}Scores a password. 30 a minute per IP
POST /api/auth/password/resetAnyone{email}Queues a reset mail. Same answer whether or not the address has an account
POST /api/auth/password/updateAnyone with a link{key, new_password}Sets the password from a reset, welcome or invitation link, then signs in. 410 for a used or expired link
POST /api/auth/password/changeSigned in{old_password, new_password}Changes the caller's password
POST /api/auth/password/verifySigned in{password}Checks the caller's password

change and verify count against the login lockout. Reset requests are limited per address and per IP to System Settings' password_reset_limit an hour (3 by default).

A weak new password is accepted with password_warning set to the sentence to show, unless System Settings' enforce_password_strength is on.

Sessions

Method and pathDoes
GET /api/auth/sessionsThe caller's sessions
DELETE /api/auth/sessions/:idEnds one. Ending the current one also clears the cookie
POST /api/auth/sessions/revoke-othersEnds every session but the current one

Ending a session closes its realtime sockets.

Setup

Method and pathWhoDoes
GET /api/setup/stateAnyone{setup_state}
GET /api/setup/regional-dataAnyoneEnabled languages, every Country with its time zones, currency and formats, and a sample number and date in each. 30 a minute per IP
POST /api/setup/completeAnyone on an unclaimed site, a System Manager afterFinishes setup and signs the first user in. 409 once the site is set up. 30 a minute per IP

Other public endpoints

Method and pathDoes
POST /api/website/language{language} sets the preferred_language cookie to an enabled Language's code
GET /api/email/unsubscribe?token=A mail's signed unsubscribe link. Shows a confirm page
POST /api/email/unsubscribe?token=Unsubscribes. Exempt from CSRF, since the signed token is the proof
POST /api/telegram/webhookThe site's Telegram bot updates, checked by the secret token Telegram sends
GET or HEAD /health200 ok while Postgres answers, 503 db otherwise. Needs no site host

See REST API for Records and Routes for every path.

On this page