Skip to content

Get, add and delete tags

By , Head of IntegrationsUpdated

Open this page in a new chat

Short answer

This page has 3 commands: Get file meta tags (GET /v2/files/meta/tags), Add file meta tags (POST /v2/files/meta/tags) and Delete file meta tags (DELETE /v2/files/meta/tags). Each call needs a bearer token and counts towards your hourly API limit. Below are the parameters, sample code in 9 languages and a sample answer.

After reading this you will know

  • How to get, add and delete tags
  • Which parameters each of the 3 commands takes
  • Sample code in 9 languages and a sample answer

Every command on this page needs a bearer token and counts towards your hourly limit.

GEThttps://api.sirv.com/v2/files/meta/tags

Use this API method to get all the meta tags of a file or folder.

Query parameters

NameTypeRequiredExampleDescription
filenamestringYes/REST API Examples/blue-lake.jpgPath of the file in your account, starting with /.

Example request

// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', {
method: 'GET',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Example response

{
"tags": [
"lake",
"water"
]
}
POSThttps://api.sirv.com/v2/files/meta/tags

Use this API method to add a meta tag to a file or folder.

Query parameters

NameTypeRequiredExampleDescription
filenamestringYes/REST API Examples/blue-lake.jpgPath of the file in your account, starting with /.

Request body (JSON)

FieldTypeRequiredExampleDescription
tagsarray of stringYes["blue","lake","winter","cold","water"]Tags to add to the file.

Example request

// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' },
body: JSON.stringify({
"tags": [
"blue",
"lake",
"winter",
"cold",
"water"
]
}),
});
console.log(res.status, await res.text());

Response

HTTP 200 with an empty body when the command succeeds.

DELETEhttps://api.sirv.com/v2/files/meta/tags

Use this API method to delete a meta tag from a file or folder.

Query parameters

NameTypeRequiredExampleDescription
filenamestringYes/REST API Examples/blue-lake.jpgPath of the file in your account, starting with /.

Request body (JSON)

FieldTypeRequiredExampleDescription
tagsarray of stringYes["ocean"]Tags to remove from the file.

Example request

// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/files/meta/tags?filename=%2FREST%20API%20Examples%2Fblue-lake.jpg', {
method: 'DELETE',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' },
body: JSON.stringify({
"tags": [
"ocean"
]
}),
});
console.log(res.status, await res.text());

Response

HTTP 200 with an empty body when the command succeeds.

Back to top