Content Versioning
Content versioning lets you save incremental changes to a collection item as a draft without modifying the live record. When ready, promote the draft to overwrite the live item.
Database Schema (daas_versions)
| Column | Type | Description |
|---|---|---|
id | uuid | Primary key |
key | text | Version identifier (e.g., draft, v1.0) |
name | text | Human-readable name |
collection | text | Target collection |
item | text | Primary key of the versioned item |
delta | jsonb | Stores only the changed fields |
date_created | timestamptz | Creation timestamp |
date_updated | timestamptz | Last saved timestamp |
user_created | uuid | FK → daas_users |
user_updated | uuid | FK → daas_users |
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/versions | List versions (supports page, limit, sort, fields, filter) |
POST | /api/versions | Create a version |
PATCH | /api/versions | Bulk update versions (by keys in body or filter query param) |
DELETE | /api/versions | Bulk delete versions (by keys in body or filter query param) |
GET | /api/versions/:id | Get a version |
PATCH | /api/versions/:id | Update version metadata |
DELETE | /api/versions/:id | Delete a version |
POST | /api/versions/:id/save | Save delta changes to the version |
POST | /api/versions/:id/promote | Apply version delta to the live item |
Creating a Version
curl -X POST /api/versions \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"collection": "articles",
"item": "article-uuid",
"key": "draft",
"name": "Draft — April revision"
}'Saving Changes
POST /api/versions/:id/save deep-merges changes into the version’s delta. Only send changed fields:
curl -X POST /api/versions/<id>/save \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{ "title": "Updated Title", "body": "New body text" }'Reading with a Version Applied
curl "/api/items/articles/article-uuid?version=draft" \
-H "Authorization: Bearer <token>"Returns the live item with the version’s delta deep-merged on top.
Promoting a Version
curl -X POST /api/versions/<id>/promote \
-H "Authorization: Bearer <token>"The version’s delta is applied to the live item record. The version is not deleted automatically.
Workflow Integration
Versions integrate with the Workflow system:
- The
version_keyfield on a workflow instance tracks which version is under review - The built-in
xtr.item.promoteworkflow action automatically promotes the linked version when the transition fires - Filter rules on workflow assignments are tested against the parent item, not the version
Query Parameters
GET /api/versions supports:
| Parameter | Example | Description |
|---|---|---|
page | ?page=2 | Page number (1-indexed) |
limit | ?limit=50 | Items per page (default: 25) |
sort | ?sort=-date_created | Sort field (- prefix for descending) |
fields | ?fields=id,name,collection | Comma-separated fields to return |
filter | ?filter={"collection":{"_eq":"articles"}} | JSON filter object |
Last updated on