API Keys
API keys provide authentication for automation, scripts, and third-party applications.
Creating API Keys
Via Web Interface
- Go to Profile > API Keys
- Click Create API Key
- Enter a name
- Select permissions
- Copy the generated key (shown only once!)
Via API
curl -X POST http://localhost:8080/api/v1/api-keys \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Automation Script",
"permissions": ["LibrariesRead", "BooksRead"]
}'
Response:
{
"id": "uuid",
"name": "Automation Script",
"key": "codex_abc12345_secretpart123456789",
"key_prefix": "abc12345",
"permissions": ["LibrariesRead", "BooksRead"],
"created_at": "2024-01-15T10:00:00Z"
}
danger
The full API key is only shown once! Store it securely immediately.
Using API Keys
As Bearer Token
curl -H "Authorization: Bearer codex_abc12345_secretpart" \
http://localhost:8080/api/v1/libraries
As X-API-Key Header
curl -H "X-API-Key: codex_abc12345_secretpart" \
http://localhost:8080/api/v1/libraries
As Basic Auth (for OPDS)
Username: api
Password: codex_abc12345_secretpart
API Key Permissions
API keys can only have permissions that the creating user has. You cannot create an API key with more permissions than your account.
Managing API Keys
List API Keys
curl http://localhost:8080/api/v1/api-keys \
-H "Authorization: Bearer $TOKEN"
Revoke API Key
curl -X DELETE http://localhost:8080/api/v1/api-keys/{id} \
-H "Authorization: Bearer $TOKEN"
Best Practices
- Minimal permissions: Only grant permissions the key needs
- Descriptive names: Name keys by their purpose
- Regular rotation: Regenerate keys periodically
- Secure storage: Never commit keys to version control
- Revoke unused keys: Delete keys no longer in use
- Separate keys: Use different keys for different applications
Common Use Cases
OPDS Reader
{
"name": "OPDS Reader",
"permissions": ["LibrariesRead", "SeriesRead", "BooksRead", "PagesRead"]
}
Automation Script
{
"name": "Library Scanner Script",
"permissions": ["LibrariesRead", "LibrariesWrite", "TasksRead", "TasksWrite"]
}
Mobile App
{
"name": "Mobile App",
"permissions": [
"LibrariesRead",
"SeriesRead",
"BooksRead",
"BooksWrite",
"PagesRead"
]
}
Troubleshooting
API Key Not Working
- Verify key is copied correctly (no extra spaces)
- Check key hasn't been revoked
- Verify key has required permissions
- Try different auth method (header vs Bearer)
Permission Denied
- Check key has the required permission
- Verify endpoint requires the permission you expect
- Check server logs for details