Batch Download
POST multiple export identifiers and receive either one zip file or a JSON list of exported URLs.
This route resolves multiple exports and returns either one zip file or a URL list.
- Method:
POST - Path:
/viewer/exports/download-batch - Content-Type:
application/json - Auth header:
x-api-key: CLIENT_API_KEYwhen the backend protects export routes. If you need to issue or manage that client key, see API Key Management Overview. - Base URL example:
https://db-backend-domain/api
Protected backend download routes require a valid client API key in x-api-key before batch requests will succeed.
- Required setup: complete API Key Management Overview before integrating protected batch download requests.
Send an items array. Each item should contain sourceFileUrl.
Request example
Call the same batch route in one of two ways depending on the response you need.
Without responseType
With responseType=urls
The route supports one binary mode and one JSON mode.
- Default: backend returns one zip file stream.
- URL mode:
POST /viewer/exports/download-batch?responseType=urlsreturns JSON. - URL response shape:
{ "success": true, "exportedUrls": ["https://..."], "skipped": [...] } - Zip naming: duplicate filenames are made unique by the backend inside the zip.
The frontend should choose its parsing logic before sending the request.
- Default mode: read the response as a blob and trigger one zip download.
- URL mode: read the response as JSON.
- Filename source: prefer
Content-Dispositionfrom the backend. - Fallback zip name:
canvas-exports.ziponly when the header is missing.
Use separate client examples for the default zip response and the URL-only response.
Without responseType
With responseType=urls
Keep export registration and export download as separate steps in the application flow.
- 11. Register exports first in your normal export flow.
- 22. Store `sourceFileUrl` values in app state.
- 33. Load the client API key before calling protected download routes.
- 44. Build the batch payload only when the user requests download.
- 55. Choose response mode based on whether the UI needs a zip file or URL data.
- 66. Surface status clearly for
400,401/403,404, and backend failures.
