Sign-in:
- Google, GitHub, Microsoft and any OpenID Connect provider, set up in the
admin panel (secrets are write-only). PocketBase talks to the provider,
and docwell-server keeps the state and PKCE verifier. Accounts a
provider creates follow the sign-up switch and the domain list; refused
ones are removed again.
- Two-step sign-in with an authenticator app (TOTP), set up under "Your
account", with ten single-use recovery codes. After any first factor
(password, email code, provider) the session is held behind a
five-minute challenge: five tries, each code works once. Turning it off
needs a code. Managers can reset it for someone who lost their phone.
Both the web app and the admin panel ask for the code.
Integrations:
- Personal API tokens ("dw_…") that act as their owner, read-only or
read-write, with optional expiry. Only a hash is stored, and the token is
shown once. Tokens cannot manage tokens or two-step sign-in. Admins see
and can revoke their organization's tokens.
- Workspace webhooks for page, comment and space events. Deliveries are
HMAC-SHA256 signed and retried (10 s, 1 min, 5 min), with a 30-day log
and a test button. Loopback and link-local addresses are refused
(DOCWELL_WEBHOOKS_ALLOW_LOCAL is for development).
Audit log: sign-ins (including failures and second steps, filed under the
account's organization) and every successful change request, by route and
path ids, never bodies. Superadmins see everything and org admins their
organization. It is searchable and exportable as CSV in the admin panel's
new Security page, and kept for DOCWELL_AUDIT_RETENTION_DAYS (365).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1.5 KiB
1.5 KiB
HTTP API
docwell-server's API is described in api/openapi.yaml
(OpenAPI 3.1). It is the source of truth: the web, desktop and mobile apps use clients generated from it.
- Base path:
/api/v1. - Authentication: for scripts and integrations, create an API token under Your account → API tokens and send
it as
Authorization: Bearer dw_…. A token acts as you, with your access; read only tokens can only makeGETrequests, and no token can manage tokens or two-step sign-in. Apps sign in withPOST /api/v1/auth/logininstead and send the returned session token the same way (refresh it withPOST /api/v1/auth/refresh). Accounts with two-step sign-in answer401 {"error":"totp_required","challenge":"…"}; finish withPOST /api/v1/auth/totp/verify {"challenge","code"}. - Errors are JSON:
{"error": "<code>", "message": "...", "fields": {...}}, wherefieldsholds per-field messages forvalidationerrors. - File links (
/api/v1/files/{id}) also accept?token=with a short-lived token fromPOST /api/v1/files/token, because<img>tags cannot send headers.
Health checks for load balancers: GET /healthz (process up) and GET /readyz (database reachable).
Example
TOKEN=$(curl -s -X POST https://wiki.example.com/api/v1/auth/login \
-H 'Content-Type: application/json' \
-d '{"email":"me@example.com","password":"..."}' | jq -r .token)
curl -s https://wiki.example.com/api/v1/workspaces -H "Authorization: Bearer $TOKEN"