Skip to content

Authentication ​

The API supports three authentication methods depending on the use case.

Methods Overview ​

MethodHeaderUse CaseWrite Access
API Key (Bearer)Authorization: Bearer <roapikey>Read-only integrationsNo
JWT (via API key)Authorization: Bearer <jwt>Programmatic read/writeYes (limited)
JWT (via login)Authorization: Bearer <jwt>Full admin accessYes (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/books

This 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/token do not have the adminsession flag. They cannot be used for admin-only routes (those requiring jwtAuth(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 ​

RoleDescription
rootFull access. Can manage users, rights, and all resources.
adminCan manage books, chapters, issues, templates, fields, exporters. Cannot manage users or rights.
userRead 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 PatternAuthRoles
GET /api/books, chapters, issues, collection, item, templates, fields, exportersBearer (API key or JWT)Any
POST/PATCH/PUT /api/item, collectionJWTAny
POST/PATCH/PUT/DELETE /api/book, chapter, issue, template, field, exporterJWT + admin sessionadmin, root
* /api/user, usersJWT + admin sessionroot (create/delete), admin/root (list), user (self only)
* /api/right, rightsJWT + admin sessionroot
POST /api/token, loginNone—