Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Record

Publish items in bulk

Body parameters

type string Required

Must be exactly "item_bulk_publish_operation".

relationships.items.data Required

Records to publish (a maximum of 200 records are allowed per request)

Examples

The response contains the ID of the asynchronous job that started:

1
POST https://site-api.datocms.com/items/bulk/publish HTTP/1.1
2
Authorization: Bearer YOUR-API-TOKEN
3
Accept: application/json
4
X-Api-Version: 3
5
Content-Type: application/vnd.api+json
6
7
{
8
"data": {
9
"type": "item_bulk_publish_operation",
10
"relationships": {
11
"items": {
12
"data": [
13
{
14
"type": "item",
15
"id": "hWl-mnkWRYmMCSTq4z_piQ"
16
}
17
]
18
}
19
}
20
}
21
}
Terminal window
1
curl -g 'https://site-api.datocms.com/items/bulk/publish' \
2
-X POST \
3
-H "Authorization: Bearer YOUR-API-TOKEN" \
4
-H "Accept: application/json" \
5
-H "X-Api-Version: 3" \
6
-H "Content-Type: application/vnd.api+json" \
7
--data-binary '{"data":{"type":"item_bulk_publish_operation","relationships":{"items":{"data":[{"type":"item","id":"hWl-mnkWRYmMCSTq4z_piQ"}]}}}}'
1
await fetch("https://site-api.datocms.com/items/bulk/publish", {
2
method: "POST",
3
headers: {
4
Authorization: "Bearer YOUR-API-TOKEN",
5
Accept: "application/json",
6
"X-Api-Version": "3",
7
"Content-Type": "application/vnd.api+json",
8
},
9
body: JSON.stringify({
10
data: {
11
type: "item_bulk_publish_operation",
12
relationships: {
13
items: { data: [{ type: "item", id: "hWl-mnkWRYmMCSTq4z_piQ" }] },
14
},
15
},
16
}),
17
});
1
HTTP/1.1 202 Accepted
2
Content-Type: application/json
3
Cache-Control: cache-control: max-age=0, private, must-revalidate
4
X-RateLimit-Limit: 30
5
X-RateLimit-Remaining: 28
6
7
{
8
"data": {
9
"type": "job",
10
"id": "4235"
11
}
12
}

To get the asynchronous job result, poll the job result endpoint. While the task is in progress, the endpoint returns a 404 status code. When the job completes, the status changes to 200 OK:

1
GET https://site-api.datocms.com/job-results/:job_result_id HTTP/1.1
2
Authorization: Bearer YOUR-API-TOKEN
3
Accept: application/json
4
X-Api-Version: 3
Terminal window
1
curl -g 'https://site-api.datocms.com/job-results/:job_result_id' \
2
\
3
-H "Authorization: Bearer YOUR-API-TOKEN" \
4
-H "Accept: application/json" \
5
-H "X-Api-Version: 3"
1
await fetch("https://site-api.datocms.com/job-results/:job_result_id", {
2
headers: {
3
Authorization: "Bearer YOUR-API-TOKEN",
4
Accept: "application/json",
5
"X-Api-Version": "3",
6
},
7
});
1
HTTP/1.1 200 OK
2
Content-Type: application/json
3
Cache-Control: cache-control: max-age=0, private, must-revalidate
4
X-RateLimit-Limit: 30
5
X-RateLimit-Remaining: 28
6
7
{
8
"data": {
9
"type": "job_result",
10
"id": "34",
11
"attributes": {
12
"status": 200,
13
"payload": {
14
"data": [],
15
"meta": {
16
"successful": 20,
17
"failed": 20
18
}
19
}
20
}
21
}
22
}