---
title: "Fetch Files Batch"
method: POST
path: "/v1/fetch_files_batch/"
tags: ["Public"]
---

# Fetch Files Batch

`POST /v1/fetch_files_batch/`

Fetch multiple files and return them as a ZIP archive.

Provide either document IDs, task IDs, or both to download files in a single
ZIP archive. Files are fetched concurrently and packaged efficiently.

**Parameters:**
- `document_ids` (optional): List of document IDs to include
- `task_ids` (optional): List of task IDs to resolve to documents

**Behavior:**
- At least one of `document_ids` or `task_ids` must be provided
- If multiple documents reference the same file, it's included only once
- Fails on first error encountered (all-or-nothing operation)

**Error Codes:**
- `400 BATCH_INVALID_INPUT`: No IDs provided
- `404 TASK_NOT_FOUND`: Task does not exist
- `422 TASK_NOT_DONE`: Task is not completed yet
- `422 TASK_NO_DOCUMENT`: Could not fetch file
- `404 DOCUMENT_NOT_FOUND`: Document does not exist
- `404 DOCUMENT_NO_FILE`: File not found
- `403 BATCH_PERMISSION_DENIED`: Insufficient permissions
- `500 BATCH_FILE_FETCH_FAILED`: File retrieval failed

**Returns:**
- `200`: ZIP file (application/zip) containing all requested files

## Request body

- FetchFilesBatchRequest — Request body for fetching multiple files as a batch.
  - `document_ids` integer[], nullable — List of document IDs to fetch
  - `task_ids` string[], nullable — List of task IDs to resolve to documents

## Response `200`

ZIP file containing all requested files

- unknown

## Other responses

- `400` — Error response with detailed error information
- `422` — Validation Error

---

[API](https://skmtc.dev/koncile/apis/koncile-api.md) · [All operations](https://skmtc.dev/koncile/apis/koncile-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/koncile/koncile-api/revisions/57d8047aa20b/schema)
