Appearance
Collection
Bulk operations on contributions (content entries). This is the primary endpoint for querying and managing content.
Note: The database entity is called
Contributions. Field values are stored inDatarows.
Routes
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /api/collection/:chapter? | Bearer | Query contributions |
| PUT | /api/collection/:chapter? | JWT | Bulk insert (max 50) |
| PATCH | /api/collection/:chapter? | JWT | Bulk update (max 50) |
| DELETE | /api/collection/:chapter? | JWT | Bulk delete |
The optional :chapter path parameter scopes operations to a specific chapter.
Query Collection
GET /api/collection?query=<JSON>
GET /api/collection/:chapter?query=<JSON>Query Parameters
| Parameter | Type | Default | Max | Description |
|---|---|---|---|---|
where | object | — | — | Filter conditions (required) |
limit | number | 1000 | 1000 | Maximum results |
offset | number | 0 | — | Skip first N results |
sort | string/object | — | — | Sort specification |
depth | number | 1 | 3 | Levels of references resolved in relation fields |
schema | boolean | false | — | Return JSON Schema instead of data |
type | string | — | — | Set to "ts" to return TypeScript types instead of JSON Schema (requires schema: true) |
meta | boolean | false | — | Metadata only (omit field values) |
referenced | boolean/object | false | — | Include the referencing contributions: true or {depth, limit} (default depth 1, limit = limit), see Referenced |
fields | array | all | — | Restrict to specific fields (by name) |
whereBool | string | $and | — | Logical operator: $and or $or |
Filterable Where Fields
| Field | Type | Operators |
|---|---|---|
$and | array | Array of nested where-clauses, combined with AND |
$or | array | Array of nested where-clauses, combined with OR |
book | name or id | All operators (accepts name string or numeric id) |
chapter | name or id | All operators (accepts name string or numeric id) |
fields | object | Key-value map: {"FieldName": {"$like": "value"}} |
issue | name or id | All operators (accepts name string or numeric id) |
template | name or id | All operators (accepts name string or numeric id) |
id | number | All numeric operators |
newdate | number | All numeric operators |
moddate | number | All numeric operators |
name | string | All string operators |
status | string | All string operators |
Response Format
json
{
"items": [
{
"id": 1,
"name": "My Article",
"sort": 1,
"fields": {
"Title": "Breaking News",
"Body": "<p>Content here</p>"
},
"created": 1700000000,
"lastmodified": 1700100000,
"status": "Open",
"book": {"id": 1, "name": "Publications"},
"chapter": {"id": 1, "name": "News"},
"issue": {"id": 1, "name": "2025-01"},
"template": {"id": 1, "name": "Article"}
}
],
"_count": 42,
"_limit": 1000,
"_offset": 0
}id, name, sort (number or null) and fields are always present. created, lastmodified, status, config, book, chapter, issue and template are only included with meta: true. The same applies to GET /api/item/:id.
Examples
bash
# List all contributions for a template
curl -G http://localhost:8080/api/collection \
-H "Authorization: Bearer API_KEY" \
--data-urlencode 'query={"where":{"template":"Article"},"limit":20,"sort":{"newdate":"DESC"}}'bash
# Full-text search in field content
curl -G http://localhost:8080/api/collection \
-H "Authorization: Bearer API_KEY" \
--data-urlencode 'query={"where":{"fields":{"Title":{"$fulltext":"climate"}}}}'bash
# Metadata only (fast, no field data)
curl -G http://localhost:8080/api/collection \
-H "Authorization: Bearer API_KEY" \
--data-urlencode 'query={"where":{"book":"Reports"},"meta":true}'bash
# With the contributions referencing each result: 10 at most, without their fields
curl -G http://localhost:8080/api/collection \
-H "Authorization: Bearer API_KEY" \
--data-urlencode 'query={"where":{"template":"Category"},"limit":50,"referenced":{"depth":0,"limit":10}}'Bulk Insert (PUT)
PUT /api/collection/:chapter?Send an array of contribution objects (maximum 50 per request). Items are created sequentially; the response is an array of {status, id, name} objects in request order.
To upload files, send the request as multipart/form-data: the JSON array goes into the form field payload (as a string), the binaries into one or more files parts. See File Uploads.
Body (per item)
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name |
sort | number | No | Sort order |
status | enum: Close, Draft, Open, Deleted, close, draft, open, deleted | No | Status value |
created | number | No | Creation timestamp (unix) |
lastmodified | number | No | Last modified timestamp (unix) |
config | object | No | Configuration object |
chapter | object | number | string |
book | object | number | string |
issue | object | number | string |
template | object | number | string |
fields | object | No | Field values (keyed by field name) |
Example
bash
curl -X PUT http://localhost:8080/api/collection \
-H "Authorization: Bearer JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '[
{"name": "Entry 1", "template": "Article", "chapter": 1, "fields": {"Title": "First"}},
{"name": "Entry 2", "template": "Article", "chapter": 1, "fields": {"Title": "Second"}}
]'bash
# Two entries, each with an image — all files share one "files" pool
curl -X PUT http://localhost:8080/api/collection/1 \
-H "Authorization: Bearer JWT_TOKEN" \
-F 'payload=[
{"name": "Entry 1", "fields": {"Image": [{"key": "one.jpg", "action": "upload"}]}},
{"name": "Entry 2", "fields": {"Image": [{"key": "two.jpg", "action": "upload"}]}}
]' \
-F "files=@./one.jpg" \
-F "files=@./two.jpg"Bulk Update (PATCH)
PATCH /api/collection/:chapter?Send an array of objects with id and fields to update (maximum 50). Each item behaves like PATCH /api/item/:id. There is no bulk POST.
File uploads work as for bulk insert: multipart/form-data with the JSON array in payload and the binaries in files. See File Uploads.
Body (per item)
| Field | Type | Required | Description |
|---|---|---|---|
id | number | No | Entity ID |
name | string | No | Display name |
sort | number | No | Sort order |
status | enum: Close, Draft, Open, Deleted, close, draft, open, deleted | No | Status value |
config | object | No | Configuration object |
chapter | number | string | No |
issue | number | string | No |
template | number | string | No |
fields | object | No | Field values (keyed by field name) |
Example
bash
curl -X PATCH http://localhost:8080/api/collection \
-H "Authorization: Bearer JWT_TOKEN" \
-F 'payload=[
{"id": 42, "fields": {"Image": [{"key": "cover.jpg", "action": "upload"}]}},
{"id": 43, "fields": {"Image": [{"key": "old.jpg", "action": "delete"}]}}
]' \
-F "files=@./cover.jpg"Bulk Delete
DELETE /api/collection/:chapter?query=<JSON>Deletes all contributions matching the query filter. Uses the same where syntax as GET.
Response: {"status": "ok", "affected_items": 5}
Caching
GET requests are cached in Redis (when available). The cache key is derived from the query parameters and the caller's rights. Write operations invalidate only the affected responses: those rendering a changed contribution, those listing the chapter it belongs to, and collections not restricted to a chapter. Changes to templates, fields, books, issues, chapters or rights invalidate the whole cache. Cached entries have no expiry by default (set REDIS_CACHE_TTL in seconds to add one); Redis evicts them when its memory is full.