Content Versions
Content Versioning enables users to create unpublished copies of an item (called "Content Versions"), modify them independently from the main version, and promote them to become the new main version when ready.
The Content Version Object
id
uuid
Primary key of the Content Version.
key
string
Key of the Content Version, used as the value for the version
query parameter.
name
string
Descriptive name of the Content Version.
collection
string
Name of the collection the Content Version is created on.
item
many-to-one
The item the Content Version is created on.
date_created
Date
When the Content Version was created.
date_updated
Date
When the Content Version was last updated.
user_created
many-to-one
User that created the Content Version. Many-to-one to users.
user_updated
many-to-one
User that last updated the Content Version. Many-to-one to users.
delta
json
The current changes compared to the main version of the item.
{
"id": "21a7ed5f-eb19-42ae-8ee2-61f25b8c4eb5",
"key": "my_version",
"name": "My Version",
"collection": "my_collection",
"item": "1",
"hash": "aaafc0db8fb60e82e634903523e1fa2144c58520",
"date_created": "2024-07-22T10:33:02.542Z",
"date_updated": "2024-07-22T10:33:14.324Z",
"user_created": "a2dbc923-7c75-4d26-83f4-4674bfa7be81",
"user_updated": "a2dbc923-7c75-4d26-83f4-4674bfa7be81",
"delta": {
"my_field": "Updated Value"
}
}
{
"id": "21a7ed5f-eb19-42ae-8ee2-61f25b8c4eb5",
"key": "my_version",
"name": "My Version",
"collection": "my_collection",
"item": "1",
"hash": "aaafc0db8fb60e82e634903523e1fa2144c58520",
"date_created": "2024-07-22T10:33:02.542Z",
"date_updated": "2024-07-22T10:33:14.324Z",
"user_created": "a2dbc923-7c75-4d26-83f4-4674bfa7be81",
"user_updated": "a2dbc923-7c75-4d26-83f4-4674bfa7be81",
"delta": {
"my_field": "Updated Value"
}
}
List Content Versions
List all Content Versions that exist in Directus.
Request
Query Parameters
Supports all global query parameters.
Response
An array of up to limit Content Version objects. If no items are available, data will be an empty array.
Example
Retrieve a Content Version
List an existing Content Version by primary key.
Request
Query Parameters
Supports all global query parameters.
Response
Returns the requested Content Version object.
Example
Create a Content Version
Create a new Content Version for an item.
Request
Query Parameters
Supports all global query parameters.
Request Body
A partial Content Version object.
Response
Returns the Content Version object for the created version.
Example
Create Multiple Content Versions
Create multiple new Content Versions.
Request
Query Parameters
Supports all global query parameters.
Request Body
An array of partial Content Version objects.
Response
Returns an array of Content Version objects for the created versions.
Example
Update a Content Version
Update an existing Content Version.
Request
Query Parameters
Supports all global query parameters.
Request Body
A partial Content Version object.
Response
Returns the Content Version object for the updated version.
Example
Update Multiple Content Versions
Update multiple existing Content Versions.
Request
Query Parameters
Supports all global query parameters.
Request Body
keys
Required
Array of primary keys of the Content Versions you'd like to update.
data
Required
The name property of the Content Version object.
Response
Returns the Content Version objects for the updated versions.
Example
Delete a Content Version
Delete an existing Content Version.
Request
Response
Empty body.
Example
Delete Multiple Content Versions
Delete multiple existing Content Versions.
Request
Request Body
An array of Content Version primary keys
Response
Empty body.
Example
Save to a Content Version
Save item changes to an existing Content Version.
Request
Response
Returns the item object with the new state after save.
Example
Compare a Content Version
Compare an existing Content Version with the main version of the item.
Request
Response
Returns all fields with different values, along with the hash of the main version of the item and the information whether the Content Version is outdated (i.e. main version of the item has been updated since the creation of the Content Version):
{
"outdated": false,
"mainHash": "2ee9c4e33b19d2cdec66a1ff7355e75a331591d9",
"current": {
"my_field": "Updated Value"
},
"main": {
"my_field": "Main Value"
}
}
{
"outdated": false,
"mainHash": "2ee9c4e33b19d2cdec66a1ff7355e75a331591d9",
"current": {
"my_field": "Updated Value"
},
"main": {
"my_field": "Main Value"
}
}
Example
Promote a Content Version
Promote an existing Content Version to become the new main version of the item.
Request
Response
The primary key of the promoted item.