Schema
Apply Schema Difference
Update the instance's schema by passing the diff previously retrieved via `/schema/diff` endpoint in the JSON request body or a JSON/YAML file. This endpoint is only available to admin users.
Request Body
POST /schema/apply
Retrieve Schema Difference
Compare the current instance's schema against the schema snapshot in JSON request body and retrieve the difference. This endpoint is only available to admin users. Alternatively, upload a JSON or YAML schema file. Does not allow different Directus versions and database vendors by default. You can opt in to bypass these checks by passing the `force` query parameter.
Query Parameters
Bypass version and database vendor restrictions.
Request Body
POST /schema/diff
{
"data": {
"diff": {
"collections": [
{
"diff": [
{}
]
}
],
"fields": [
{
"diff": [
{}
]
}
],
"relations": [
{
"diff": [
{}
]
}
]
}
}
}
Retrieve Schema Snapshot
Retrieve the current schema. This endpoint is only available to admin users.
Query Parameters
Saves the API response to a file. Accepts one of csv
, json
, xml
, yaml
.
GET /schema/snapshot
{
"data": {
"version": 1,
"collections": [
{
"collection": "customers",
"translations": [],
"item_duplication_fields": []
}
],
"fields": [
{
"collection": "about_us",
"field": "id",
"special": [],
"options": {},
"translations": []
}
],
"relations": [
{
"id": 1,
"many_collection": "directus_activity",
"many_field": "user",
"one_collection": "directus_users",
"one_field": null,
"one_allowed_collections": [],
"junction_field": null
}
]
}
}