Skip to content

Delete many files at once

By , Head of IntegrationsUpdated

Open this page in a new chat

Short answer

This page has 2 commands: Delete a batch of files or directories (POST /v2/files/batch/delete) and Get results of batch delete job (GET /v2/files/batch/delete). Use this method to delete the list of filenames. Each call needs a bearer token and counts towards your hourly API limit.

After reading this you will know

  • How to delete many files at once
  • Which parameters each of the 2 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.

POSThttps://api.sirv.com/v2/files/batch/delete

Use this method to delete the list of filenames.

Request body (JSON)

FieldTypeRequiredExampleDescription
filenamesarray of stringYes["/REST API Examples/coin/coin_01.jpg"]Paths of the files or folders to delete, up to 1,000.

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/batch/delete', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' },
body: JSON.stringify({
"filenames": [
"/REST API Examples/filename.jpg",
"/REST API Examples/directory/"
]
}),
});
console.log(res.status, await res.text());

Example response

{
"id": "YE49COidrrMuVspJg41HAsaVA0ecmQKs"
}
GEThttps://api.sirv.com/v2/files/batch/delete

Use this method to get results and progress of batch delete job created with POST /files/batch/delete method.

Query parameters

NameTypeRequiredExampleDescription
idstringYesBLDgbVfrCYcLOceNSEf2ymIwLGQDXSCIJob ID returned from POST /files/batch/delete

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/batch/delete?id=BLDgbVfrCYcLOceNSEf2ymIwLGQDXSCI', {
method: 'GET',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Example response

{}
Back to top