Subchapter 3.8
references/content-management/bulk-actions.mdMarkdown4 KBView on GitHub
The Bulk Actions API lets you publish, unpublish, or validate multiple entities in a single request.
Publish multiple entries and/or assets in one request:
curl -X POST https://api.contentful.com/spaces/{space_id}/environments/{env_id}/bulk_actions/publish \
-H "Authorization: Bearer {cma_token}" \
-H "Content-Type: application/vnd.contentful.management.v1+json" \
-d '{
"entities": {
"items": [
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "entry-1",
"version": 5
}
},
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "entry-2",
"version": 3
}
},
{
"sys": {
"type": "Link",
"linkType": "Asset",
"id": "asset-1",
"version": 2
}
}
]
}
}'Response returns a bulk action object with status:
{
"sys": {
"type": "BulkAction",
"id": "bulk-action-id",
"status": "created",
"createdAt": "2024-01-15T10:00:00Z"
}
}curl -X POST https://api.contentful.com/spaces/{space_id}/environments/{env_id}/bulk_actions/unpublish \
-H "Authorization: Bearer {cma_token}" \
-H "Content-Type: application/vnd.contentful.management.v1+json" \
-d '{
"entities": {
"items": [
{ "sys": { "type": "Link", "linkType": "Entry", "id": "entry-1" } },
{ "sys": { "type": "Link", "linkType": "Entry", "id": "entry-2" } }
]
}
}'Note: Unpublish does not require version numbers.
Validate multiple entries without publishing:
curl -X POST https://api.contentful.com/spaces/{space_id}/environments/{env_id}/bulk_actions/validate \
-H "Authorization: Bearer {cma_token}" \
-H "Content-Type: application/vnd.contentful.management.v1+json" \
-d '{
"entities": {
"items": [
{ "sys": { "type": "Link", "linkType": "Entry", "id": "entry-1" } },
{ "sys": { "type": "Link", "linkType": "Entry", "id": "entry-2" } }
]
}
}'Bulk actions run asynchronously. Poll the status endpoint:
curl https://api.contentful.com/spaces/{space_id}/environments/{env_id}/bulk_actions/actions/{bulk_action_id} \
-H "Authorization: Bearer {cma_token}"Response:
{
"sys": {
"type": "BulkAction",
"id": "bulk-action-id",
"status": "succeeded",
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-01-15T10:00:05Z"
}
}Status values: created, inProgress, succeeded, failed.
On failure, the response includes error details per entity.
Publish requires the entity version for optimistic locking:
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "entry-id",
"version": 5
}
}Unpublish and validate don’t require version:
{
"sys": {
"type": "Link",
"linkType": "Entry",
"id": "entry-id"
}
}A single bulk action can include both entries and assets:
{
"entities": {
"items": [
{ "sys": { "type": "Link", "linkType": "Entry", "id": "entry-1", "version": 3 } },
{ "sys": { "type": "Link", "linkType": "Asset", "id": "asset-1", "version": 2 } }
]
}
}