Appearance
Authentication
The API supports three authentication methods depending on the use case.
Methods Overview
| Method | Header | Use Case | Write Access |
|---|---|---|---|
| API Key (Bearer) | Authorization: Bearer <roapikey> | Read-only integrations | No |
| JWT (via API key) | Authorization: Bearer <jwt> | Programmatic read/write | Yes (limited) |
| JWT (via login) | Authorization: Bearer <jwt> | Full admin access | Yes (full) |
1. API Key Authentication
Every user has a read-only API key (roapikey). Pass it as a Bearer token:
bash
curl -H "Authorization: Bearer YOUR_RO_API_KEY" \
http://localhost:8080/api/booksThis grants read access only — sufficient for GET endpoints on books, chapters, issues, collection, item, templates, fields, and exporters.
2. JWT via API Key (Token Endpoint)
For programmatic write access, exchange a username + read-write API key for a JWT:
bash
# Get a JWT token
curl -X POST http://localhost:8080/api/token \
-H "Content-Type: application/json" \
-d '{"user": "myuser", "rwtoken": "MY_RW_API_KEY"}'Response:
json
{
"token": "eyJhbGciOiJIUzI1NiIs..."
}Use the JWT for subsequent requests:
bash
curl -X PUT http://localhost:8080/api/book \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
-H "Content-Type: application/json" \
-d '{"name": "New Book"}'Note: Tokens obtained via
/api/tokendo not have theadminsessionflag. They cannot be used for admin-only routes (those requiringjwtAuth(roles, true)— such as deleting books, managing users, etc.).
3. JWT via Login (Full Admin Access)
For full admin access, login with username and password:
bash
curl -X POST http://localhost:8080/api/login \
-H "Content-Type: application/json" \
-d '{"user": "admin", "password": "secret"}'This returns a JWT with adminsession: true, granting access to all endpoints including admin-only operations.
Token Refresh
Refresh an existing JWT before it expires:
bash
curl http://localhost:8080/api/token/refresh \
-H "Authorization: Bearer CURRENT_JWT"Returns a new JWT with a fresh expiry. Default expiration: JWT_EXPIRATION env var (default: 3600 seconds).
Password Reset
Request a password reset email:
bash
curl -X POST http://localhost:8080/api/login/request \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com"}'Complete the reset with the token from the email:
bash
curl -X POST http://localhost:8080/api/login/reset \
-H "Content-Type: application/json" \
-d '{"token": "RESET_TOKEN", "password": "NewP@ss1", "passwordrepeat": "NewP@ss1"}'Password requirements: minimum 8 characters, at least 1 digit, at least 1 special character.
Roles
| Role | Description |
|---|---|
root | Full access. Can manage users, rights, and all resources. |
admin | Can manage books, chapters, issues, templates, fields, exporters. Cannot manage users or rights. |
user | Read access to permitted resources. Can only view and update own user profile. |
Non-root/admin users only see resources they have been granted access to via rights groups.
Auth Requirements by Endpoint
| Endpoint Pattern | Auth | Roles |
|---|---|---|
GET /api/books, chapters, issues, collection, item, templates, fields, exporters | Bearer (API key or JWT) | Any |
POST/PATCH/PUT /api/item, collection | JWT | Any |
POST/PATCH/PUT/DELETE /api/book, chapter, issue, template, field, exporter | JWT + admin session | admin, root |
* /api/user, users | JWT + admin session | root (create/delete), admin/root (list), user (self only) |
* /api/right, rights | JWT + admin session | root |
POST /api/token, login | None | — |