Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Upload

Destroy uploads

Delete assets in bulk

Body parameters

type string Required

Must be exactly "upload_bulk_destroy_operation".

relationships.uploads.data Required

Assets to delete

Examples

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

1
POST https://site-api.datocms.com/uploads/bulk/destroy 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": "upload_bulk_destroy_operation",
10
"relationships": {
11
"uploads": {
12
"data": [
13
{
14
"type": "upload",
15
"id": "q0VNpiNQSkG6z0lif_O1zg"
16
}
17
]
18
}
19
}
20
}
21
}
Terminal window
1
curl -g 'https://site-api.datocms.com/uploads/bulk/destroy' \
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":"upload_bulk_destroy_operation","relationships":{"uploads":{"data":[{"type":"upload","id":"q0VNpiNQSkG6z0lif_O1zg"}]}}}}'
1
await fetch("https://site-api.datocms.com/uploads/bulk/destroy", {
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: "upload_bulk_destroy_operation",
12
relationships: {
13
uploads: { data: [{ type: "upload", id: "q0VNpiNQSkG6z0lif_O1zg" }] },
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
}