Skip to content

Zip files and folders

By , Head of IntegrationsUpdated

Open this page in a new chat

Short answer

This page has 2 commands: Zip a batch of files or directories (POST /v2/files/zip) and Get results of ZIP job (GET /v2/files/zip). Use this method to create a ZIP archive from 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 zip files and folders
  • 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/zip

Use this method to create a ZIP archive from 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 put in the zip, up to 1,000.
zipFilenamestringNoSirv January 18, 2023.zipName of the zip file, up to 64 characters.

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/zip', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' },
body: JSON.stringify({
"filenames": [
"/REST API Examples/coin/coin_01.jpg",
"/REST API Examples/coin/coin_02.jpg"
],
"zipFilename": "Sirv January 18, 2023.zip"
}),
});
console.log(res.status, await res.text());

Example response

{
"id": "SicD2eqm87EKGpPCAM4sCu28xGeSaNnB"
}
GEThttps://api.sirv.com/v2/files/zip

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

Query parameters

NameTypeRequiredExampleDescription
idstringYesBLDgbVfrCYcLOceNSEf2ymIwLGQDXSCIJob ID returned from POST /files/zip

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

Example response

{
"progress": 100,
"result": [
{
"filename": "Sirv January 18, 2023.zip",
"size": 138237,
"url": "https://goto.sirv.com/AvhriHTv7nOrMvgBBtPHy1tH1hbaeFCi"
}
]
}
Back to top