Show examples in:
Javascript HTTP
Endpoint info
Available examples

Content Management API > Upload

Add tags to assets in bulk

Body parameters

type string Required

Must be exactly "upload_bulk_tag_operation".

attributes.tags Required

The tags to add to the assets

Type: Array<string>
Example: ["cats"]
relationships.uploads.data Required

Assets to tag

Examples

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

1
POST https://site-api.datocms.com/uploads/bulk/tag 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_tag_operation",
10
"attributes": {
11
"tags": [
12
"cats"
13
]
14
},
15
"relationships": {
16
"uploads": {
17
"data": [
18
{
19
"type": "upload",
20
"id": "q0VNpiNQSkG6z0lif_O1zg"
21
}
22
]
23
}
24
}
25
}
26
}
Terminal window
1
curl -g 'https://site-api.datocms.com/uploads/bulk/tag' \
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_tag_operation","attributes":{"tags":["cats"]},"relationships":{"uploads":{"data":[{"type":"upload","id":"q0VNpiNQSkG6z0lif_O1zg"}]}}}}'
1
await fetch("https://site-api.datocms.com/uploads/bulk/tag", {
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_tag_operation",
12
attributes: { tags: ["cats"] },
13
relationships: {
14
uploads: { data: [{ type: "upload", id: "q0VNpiNQSkG6z0lif_O1zg" }] },
15
},
16
},
17
}),
18
});
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
}