Box Developer Documentation

A beta version of the new Box developer documentation site is launching soon! Updated Developer Guides, modern API Reference, and AI-powered search are on the way to help you build with Box faster. Stay tuned for more updates.

Download ZIP Archive

Guides Downloads Download ZIP Archive
Edit this page

Download ZIP Archive

To download all files in a folder or an entire folder structure, you have to create and download a ZIP archive.

Create a ZIP Archive

First, you need to create a ZIP archive containing the files or the folder structure. You can include up to 10,000 file and folder IDs unless you reach the account’s upload limit.

cURL
curl -i -X POST "https://api.box.com/2.0/zip_downloads" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -d '{
       "download_file_name": "January Financials",
       "items": [
         {
           "type": "file",
           "id": "12345"
         },
         {
           "type": "file",
           "id": "34325"
         },
         {
           "type": "folder",
           "id": "45678"
         }
       ]
     }'
Node/TypeScript v10
await client.zipDownloads.createZipDownload({
  items: [
    {
      id: file1.id,
      type: 'file' as ZipDownloadRequestItemsTypeField,
    } satisfies ZipDownloadRequestItemsField,
    {
      id: file2.id,
      type: 'file' as ZipDownloadRequestItemsTypeField,
    } satisfies ZipDownloadRequestItemsField,
    {
      id: folder1.id,
      type: 'folder' as ZipDownloadRequestItemsTypeField,
    } satisfies ZipDownloadRequestItemsField,
  ],
  downloadFileName: 'zip',
} satisfies ZipDownloadRequest);
Python v10
client.zip_downloads.create_zip_download(
    [
        CreateZipDownloadItems(id=file_1.id, type=DownloadZipItemsTypeField.FILE),
        CreateZipDownloadItems(id=file_2.id, type=DownloadZipItemsTypeField.FILE),
        CreateZipDownloadItems(id=folder_1.id, type=DownloadZipItemsTypeField.FOLDER),
    ],
    download_file_name="zip",
)
.NET v10
await client.ZipDownloads.CreateZipDownloadAsync(requestBody: new ZipDownloadRequest(items: Array.AsReadOnly(new [] {new ZipDownloadRequestItemsField(id: file1.Id, type: ZipDownloadRequestItemsTypeField.File),new ZipDownloadRequestItemsField(id: file2.Id, type: ZipDownloadRequestItemsTypeField.File),new ZipDownloadRequestItemsField(id: folder1.Id, type: ZipDownloadRequestItemsTypeField.Folder)})) { DownloadFileName = "zip" });
Swift v10
try await client.zipDownloads.createZipDownload(requestBody: ZipDownloadRequest(items: [ZipDownloadRequestItemsField(id: file1.id, type: ZipDownloadRequestItemsTypeField.file), ZipDownloadRequestItemsField(id: file2.id, type: ZipDownloadRequestItemsTypeField.file), ZipDownloadRequestItemsField(id: folder1.id, type: ZipDownloadRequestItemsTypeField.folder)], downloadFileName: "zip"))
Java v10
client.getZipDownloads().createZipDownload(new ZipDownloadRequest.Builder(Arrays.asList(new ZipDownloadRequestItemsField(ZipDownloadRequestItemsTypeField.FILE, file1.getId()), new ZipDownloadRequestItemsField(ZipDownloadRequestItemsTypeField.FILE, file2.getId()), new ZipDownloadRequestItemsField(ZipDownloadRequestItemsTypeField.FOLDER, folder1.getId()))).downloadFileName("zip").build())
.NET v6
await client.ZipDownloads.CreateZipDownloadAsync(requestBody: new ZipDownloadRequest(items: Array.AsReadOnly(new [] {new ZipDownloadRequestItemsField(id: file1.Id, type: ZipDownloadRequestItemsTypeField.File),new ZipDownloadRequestItemsField(id: file2.Id, type: ZipDownloadRequestItemsTypeField.File),new ZipDownloadRequestItemsField(id: folder1.Id, type: ZipDownloadRequestItemsTypeField.Folder)})) { DownloadFileName = "zip" });
Node v4
await client.zipDownloads.createZipDownload({
  items: [
    {
      id: file1.id,
      type: 'file' as ZipDownloadRequestItemsTypeField,
    } satisfies ZipDownloadRequestItemsField,
    {
      id: file2.id,
      type: 'file' as ZipDownloadRequestItemsTypeField,
    } satisfies ZipDownloadRequestItemsField,
    {
      id: folder1.id,
      type: 'folder' as ZipDownloadRequestItemsTypeField,
    } satisfies ZipDownloadRequestItemsField,
  ],
  downloadFileName: 'zip',
} satisfies ZipDownloadRequest);

The response will look similar to the following:

{
  "download_url": "https://dl.boxcloud.com/2.0/zip_downloads/25gvaXcIE4QJlinNiw2oHAQ==ZFs3Q2Xpd7pKBz7OyzXNrUaoW3aJxQRN5znAvyM-KpdEEPdWcQDKU-Dl85Ew/content",
  "status_url": "https://api.box.com/2.0/zip_downloads/25gvaXcIE4QJlinNiw2oHAQ==ZFs3Q2Xpd7pKBz7OyzXNrUaoW3aJxQRN5znAvyM-KpdEEPdWcQDKU-Dl85Ew/status",
  "expires_at": "2023-02-28T10:23:54Z",
  "name_conflicts": []
}

Extract the ZIP download ID

To download the ZIP archive, you need the ZIP download ID. You can find it in the response you got when you created the archive.

Go to status_url and copy the ID located betweenzip_downloads and content:

25gvaXcIE4QJlinNiw2oHAQ==ZFs3Q2Xpd7pKBz7OyzXNrUaoW3aJxQRN5znAvyM-KpdEEPdWcQDKU-Dl85Ew

Download URL is valid only for a the time specified in expires_at parameter.

Download files

Place the download ID in the file location URL as in the sample below to point to the right files.

cURL
curl -L GET "https://dl.boxcloud.com/2.0/zip_downloads/29l00nfxDyHOt7RphI9zT_w==nDnZEDjY2S8iEWWCHEEiptFxwoWojjlibZjJ6geuE5xnXENDTPxzgbks_yY=/content" \
     -H "authorization: Bearer <ACCESS_TOKEN>" \
     -o sample_curl.zip
Node/TypeScript v10
await client.zipDownloads.getZipDownloadContent(zipDownload.downloadUrl!);
Python v10
client.zip_downloads.get_zip_download_content(zip_download.download_url)
.NET v10
await client.ZipDownloads.GetZipDownloadContentAsync(downloadUrl: NullableUtils.Unwrap(zipDownload.DownloadUrl));
Swift v10
try await client.zipDownloads.getZipDownloadContent(downloadUrl: zipDownload.downloadUrl!, downloadDestinationUrl: URL(path: destinationPathString))
Java v10
client.getZipDownloads().getZipDownloadContent(zipDownload.getDownloadUrl())
.NET v6
await client.ZipDownloads.GetZipDownloadContentAsync(downloadUrl: NullableUtils.Unwrap(zipDownload.DownloadUrl));
Node v4
await client.zipDownloads.getZipDownloadContent(zipDownload.downloadUrl!);

For downloads that take longer, you can monitor the download status using the status endpoint. This allows you to inspect the progress of the download as well as the number of items that might have been skipped.

cURL
curl -i -X GET "https://api.box.com/2.0/zip_downloads/29l00nfxDyHOt7RphI9zT_w==nDnZEDjY2S8iEWWCHEEiptFxwoWojjlibZjJ6geuE5xnXENDTPxzgbks_yY=/status" \
     -H "authorization: Bearer <ACCESS_TOKEN>"
Node/TypeScript v10
await client.zipDownloads.getZipDownloadStatus(zipDownload.statusUrl!);
Python v10
client.zip_downloads.get_zip_download_status(zip_download.status_url)
.NET v10
await client.ZipDownloads.GetZipDownloadStatusAsync(statusUrl: NullableUtils.Unwrap(zipDownload.StatusUrl));
Swift v10
try await client.zipDownloads.getZipDownloadStatus(statusUrl: zipDownload.statusUrl!)
Java v10
client.getZipDownloads().getZipDownloadStatus(zipDownload.getStatusUrl())
.NET v6
await client.ZipDownloads.GetZipDownloadStatusAsync(statusUrl: NullableUtils.Unwrap(zipDownload.StatusUrl));
Node v4
await client.zipDownloads.getZipDownloadStatus(zipDownload.statusUrl!);

If you want to use SDKs to download the contents of the folder, follow this guide.