Skip to content

Files and folders

By , Head of IntegrationsUpdated

Open this page in a new chat

Short answer

These commands manage the files and folders in your Sirv account: list a folder, get a file's details, copy, rename, move and delete files, create folders, search by name, type, date or metadata, and zip or delete many files at once. Batch and zip jobs run in the background; check their result with the job ID.

After reading this you will know

  • How to list folders and get file details
  • How to copy, rename, move and delete files and folders
  • How to search files and run batch delete and zip jobs

Every command on this page needs a bearer token.

POSThttps://api.sirv.com/v2/files/copy

Use this API method to copy a single file.

Query parameters

NameTypeRequiredExampleDescription
fromstringYes/REST API Examples/aurora.jpgPath of the file to copy.
tostringYes/REST API Examples/aurora-copy.jpgPath of the copy, with its file name.

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/copy?from=%2FREST%20API%20Examples%2Faurora.jpg&to=%2FREST%20API%20Examples%2Faurora-copy.jpg', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Response

HTTP 200 with an empty body when the command succeeds.

POSThttps://api.sirv.com/v2/files/mkdir

Use this API method to create a new empty folder.

Query parameters

NameTypeRequiredExampleDescription
dirnamestringYes/REST API Examples/copiesPath of the new folder, 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/mkdir?dirname=%2FREST%20API%20Examples%2Fcopies', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Example response

{
"name": "RiakFsError",
"message": "Path already exists: /REST API Examples/copies"
}
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"
}
POSThttps://api.sirv.com/v2/files/delete

Use this API method to delete a single file or an empty folder.

Query parameters

NameTypeRequiredExampleDescription
filenamestringYes/REST API Examples/aurora-copy.jpgPath of the file or empty folder to 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/delete?filename=%2FREST%20API%20Examples%2Faurora-copy.jpg', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Response

HTTP 200 with an empty body when the command succeeds.

GEThttps://api.sirv.com/v2/files/stat

Use this API method to get information about a file, including created time, modified time, content type and size. It returns Unix information.

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/stat?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

{
"mtime": "2020-07-17T13:31:39.450Z",
"ctime": "2020-07-17T13:31:39.347Z",
"contentType": "image/jpeg",
"size": 587065,
"isDirectory": false,
"meta": {
"width": 1578,
"height": 1002,
"duration": 0
}
}
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

{}
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"
}
]
}
GEThttps://api.sirv.com/v2/files/readdir

Use this API method to get a list of all the files/folders within a folder.

It will return the filename, mimetype, content type and file size. It will also return any folders that exist.

A page of up to 100 results will be returned - use the ‘continuation’ field to request additional pages.

Query parameters

NameTypeRequiredExampleDescription
dirnamestringYes/REST API ExamplesPath of the folder to list, starting with /.
continuationstringNoSend it to get next page of results

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/readdir?dirname=%2FREST%20API%20Examples', {
method: 'GET',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Example response

{
"contents": [
{
"filename": "aurora.jpg",
"mtime": "2026-02-23T10:22:34.659Z",
"contentType": "image/jpeg",
"size": 260864,
"isDirectory": false,
"meta": {
"width": 2500,
"height": 1667,
"duration": 0
}
},
{
"filename": "aurora3.jpg",
"mtime": "2020-11-18T19:55:13.459Z",
"contentType": "image/webp",
"size": 201846,
"isDirectory": false,
"meta": {
"width": 2500,
"height": 1667,
"duration": 0
}
}
]
}
POSThttps://api.sirv.com/v2/files/rename

Use this API method to rename (or move) a file or folder.

Query parameters

NameTypeRequiredExampleDescription
fromstringYes/REST API Examples/uploaded.txtCurrent path of the file or folder.
tostringYes/REST API Examples/copies/uploaded-copy.txtNew path, with the new name.

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/rename?from=%2FREST%20API%20Examples%2Fuploaded.txt&to=%2FREST%20API%20Examples%2Fcopies%2Fuploaded-copy.txt', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Response

HTTP 200 with an empty body when the command succeeds.

POSThttps://api.sirv.com/v2/files/search/scroll

Use the scroll API method after performing an API search if you need to retrieve more than 1000 results.

Each call to the scroll API returns the next batch of search results until there are no more results left to return.

To use scrolling, the initial search request should specify the “scroll” parameter.

The search context will then be kept alive for 30 seconds between each scroll call.

A scrolling search will cache the entire results temporarily while you retrieve them.

As such, it shows a snapshot in time and may become outdated if files have been added, deleted or modified since then. Learn more

Request body (JSON)

FieldTypeRequiredExampleDescription
scrollIdstringYesScroll ID returned from preceding /files/search or /files/search/scroll call.

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/search/scroll', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' },
body: JSON.stringify({}),
});
console.log(res.status, await res.text());

Response

HTTP 200 with an empty body when the command succeeds.

POSThttps://api.sirv.com/v2/files/search

Use this API method to search for files based on one or more criteria: file name; folder path; file extension; content type; created/modified time; or with some specific meta information.

Up to 1000 results can be returned. If you need more results, use the scroll API method.

Request body (JSON)

FieldTypeRequiredExampleDescription
querystringNoextension:.jpgWhat to find, as Elasticsearch query text. Fields include filename, dirname, extension, size, mtime, contentType, meta.title, meta.tags, meta.product.id, and EXIF, IPTC and XMP fields. How to search by each is in Search files with the API.
sortobjectNoFields to sort the results by, each with asc or desc, as in Elasticsearch: {“mtime”: “desc”}.
fromnumberNo0Up to 1000.
sizenumberNo5Up to 100.
scrollbooleanNotrueStart a scrolling search.

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/search', {
method: 'POST',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' },
body: JSON.stringify({
"query": "extension:.jpg AND mtime:[now-30d TO now] AND -dirname:\\/.Trash",
"from": 0,
"size": 5
}),
});
console.log(res.status, await res.text());

Example response

{
"hits": [
{
"_index": "sirvfs-v4",
"_type": "_doc",
"_id": "248e197b4546afd4da9ccdb2ee0d30cf844ecf44",
"_score": 1.3096726,
"_routing": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"_source": {
"accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"filename": "/REST API Examples/aurora-copy.jpg",
"dirname": "/REST API Examples",
"basename": "aurora-copy.jpg",
"extension": ".jpg",
"id": "boW27K3kkyWK5LbGvxeOb0Sx3IOO0JoU",
"ctime": "2026-02-23T13:55:04.615Z",
"mtime": "2026-02-23T13:55:04.653Z",
"size": 260864,
"contentType": "image/jpeg",
"meta": {
"width": 2500,
"height": 1667,
"format": "JPEG",
"duration": 0,
"EXIF": {
"ModifyDate": "2020-01-29T17:12:45Z"
},
"ICC_Profile": {
"ProfileDescription": "GIMP built-in sRGB"
}
}
},
"sort": [
1.3096726,
"/REST API Examples/aurora-copy.jpg"
]
},
{
"_index": "sirvfs-v4",
"_type": "_doc",
"_id": "4b57cdf35a3568220bb9ad7a6f62f0048c8b4ae1",
"_score": 1.3096726,
"_routing": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"_source": {
"accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
"filename": "/REST API Examples/aurora.jpg",
"dirname": "/REST API Examples",
"basename": "aurora.jpg",
"extension": ".jpg",
"id": "tkLbo0YuHJuBIEYj40lEUYRZZ8cLBGnF",
"ctime": "2020-07-17T13:31:39.348Z",
"mtime": "2026-02-23T10:22:34.659Z",
"atime": "2026-02-12T07:43:18.986Z",
"size": 260864,
"contentType": "image/jpeg",
"meta": {
"width": 2500,
"height": 1667,
"format": "JPEG",
"duration": 0,
"EXIF": {
"ModifyDate": "2020-01-29T17:12:45Z"
},
"ICC_Profile": {
"ProfileDescription": "GIMP built-in sRGB"
}
}
},
"sort": [
1.3096726,
"/REST API Examples/aurora.jpg"
]
}
],
"total": 455,
"_relation": "eq"
}
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"
}
Back to top