---
title: "Write a file"
method: PUT
path: "/sandboxes/{id}/files"
tags: ["Files"]
---

# Write a file

`PUT /sandboxes/{id}/files`

## Request

- Base URL: `https://sandbox-as-a-service.com/v1`
- URL: `https://sandbox-as-a-service.com/v1/sandboxes/{id}/files`
- Auth: HTTP bearer

Writes a file into the sandbox. Relative paths resolve inside `/workspace`. Content is transferred verbatim — it is never interpreted by a shell — so any bytes are safe. Use `encoding: "base64"` for binary. Maximum 8 MiB.

## Request body

- object
  - `path` string, required
  - `content` string, required
  - `encoding` 'utf8' | 'base64'

## Response `201`

File written.

- object
  - `object` 'file'
  - `sandbox_id` string
  - `path` string
  - `bytes` integer

## Other responses

- `400`: Invalid path or content.
- `404`: No sandbox with that id for this account.
- `409`: Sandbox is not running.
- `413`: File exceeds the size limit.

---

[API](https://skmtc.dev/sandbox-as-a-service/apis/sandbox-as-a-service-api.md) · [All operations](https://skmtc.dev/sandbox-as-a-service/apis/sandbox-as-a-service-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sandbox-as-a-service/apis/sandbox-as-a-service-api/revisions/4f1ea2cf8333?raw)
