---
title: "Batch file operations"
method: POST
path: "/api/buckets/{namespace}/{repo}/batch"
tags: ["buckets"]
---

# Batch file operations

`POST /api/buckets/{namespace}/{repo}/batch`

Accepts NDJSON (newline-delimited JSON) where each line is an addFile, copyFile, or deleteFile instruction.
All add/copy operations must come before all delete operations.

JSON-lines payload:
```json
	'{"type":"addFile","path":"...","xetHash":"...","mtime":...,"mtimeNanos":...,"contentType":"..."}' +
	'{"type":"copyFile","path":"...","xetHash":"...","sourceRepoType":"...","sourceRepoId":"...","mtime":...,"mtimeNanos":...,"contentType":"..."}' +
	'{"type":"deleteFile","path":"..."}'
```

## Path parameters

- `namespace` string, required
- `repo` string, required

## Response `200`

Batch operation status

- object
  - `success` boolean, required — True if all operations succeeded
  - `processed` integer, required — Total number of operations attempted
  - `succeeded` integer, required — Number of successful operations
  - `failed` object[], required — List of failed operations
    - `path` string, required — File path that failed
    - `error` string, required — Error message

## Other responses

- `422` — Batch operation status

---

[API](https://skmtc.net/huggingface/apis/hub-api-endpoints.md) · [All operations](https://skmtc.net/huggingface/apis/hub-api-endpoints/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/huggingface/hub-api-endpoints/versions/dae0cc3790f0/schema)
