---
title: "Batch-write multiple files in a single request. Mirrors `@vercel/sandbox` `writeFiles()`. Semantics are fail-fast: if any file errors, previously-written entries are left in place and the error describes which file broke."
method: POST
path: "/v1/sandboxes/{id}/fs/write-batch"
tags: ["Sandboxes"]
---

# Batch-write multiple files in a single request. Mirrors \`@vercel/sandbox\` \`writeFiles()\`. Semantics are fail-fast: if any file errors, previously-written entries are left in place and the error describes which file broke.

`POST /v1/sandboxes/{id}/fs/write-batch`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/v1/sandboxes/{id}/fs/write-batch`
- Auth: HTTP bearer

## Path parameters

- `id` string, required

## Request body

- WriteFilesBody
  - `files` WriteFileBody[], required: List of files to write. Each entry must include an absolute `path` and base64-encoded `contents_b64`. Empty list is a no-op.
    - `contents_b64` string, required: File contents, base64-encoded. Required — lets callers ship binary data over JSON without charset games.
    - `mode` integer, nullable: Unix permission mask (e.g. 0o644). Defaults to 0o644 when absent.
    - `path` string, required: Absolute path inside the sandbox. Must start with `/`.

## Response `200`

All files written

- WriteFilesResponse
  - `written` integer, required: Number of files successfully written before the first failure (if any). On full success this equals `files.len()`.

## Other responses

- `400`: Validation error or invalid base64
- `404`: Sandbox not found

## Changes

- **2026-04-25** `774be20905f2`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/v1/sandboxes/:id/fs/write-batch/post.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
