---
title: "Write a file in an existing sandbox."
description: "API reference for POST /v1/sandboxes/{id}/files/write: Write a file in an existing sandbox. Review its parameters, input, response, and generated SDK method names."
canonical: "https://wildflower.computer/docs/reference/write-sandbox-file/"
openapi_version: "0.8.0"
source_revision: "788b7325a454b8b753a7d614247d5694bad5c967"
---

# Write a file in an existing sandbox.

**POST** `/v1/sandboxes/{id}/files/write`

Writes one file through the shared sandbox command boundary. Parent directories must already exist and writes are limited to 1 MiB.

- **Operation ID:** `writeSandboxFile`
- **Success:** **200**
- **Authentication:** **Bearer key**

## Path parameters

| Name | Type | Requirement | Meaning |
| --- | --- | --- | --- |
| `id` | string | Required | Opaque, project-scoped Wildflower sandbox ID returned by create. The provider namespace is visible, but the random payload does not encode the provider-native ID. |

## Optional provider context

These headers are inline overrides. Connected project profiles keep the same fields outside individual requests.

| Name | Type | Requirement | Meaning |
| --- | --- | --- | --- |
| `X-Provider-Workspace` | string | Optional | Optional inline provider workspace override. Required with an inline Blaxel credential and omitted when using a connected profile. |

## Request and response

- **Request body:** [WriteFileInput](https://wildflower.computer/docs/reference/models/write-file-input/)
- **Response:** [WriteFileResult](https://wildflower.computer/docs/reference/models/write-file-result/)

## HTTP example

This credential-safe request and its representative success response are generated with the operation contract. Replace placeholder IDs and read secrets from your environment.

Request

```bash
curl --fail-with-body --request POST \
  "$WILDFLOWER_URL/v1/sandboxes/wf_e2b_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/files/write" \
  -H "Authorization: Bearer $WILDFLOWER_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"path":"/tmp/hello.txt","content":"hello","encoding":"utf8"}'
```

Response / 200

```json
{
  "sandboxId": "wf_e2b_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
  "path": "/tmp/hello.txt",
  "bytesWritten": 5
}
```

## SDK examples

Use the same operation through any generated client. Each snippet comes from the SDK generator rather than a hand-copied website example.

### TypeScript

```typescript
import { Wildflower } from "@wildflowercomputer/sdk";

const client = new Wildflower({
  wildflowerApiKey: process.env.WILDFLOWER_API_KEY,
});

const handle = client.sandboxes.attach("wf_e2b_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
const written = await handle.writeFile({
  path: "/tmp/hello.txt",
  content: "hello",
  encoding: "utf8",
});
console.log(written.bytesWritten);
```

### Python

```python
import os

from wildflower import (
    E2bCreateSandboxInput,
    ReadFileInput,
    RunCommandInput,
    WriteFileInput,
    Wildflower,
)

client = Wildflower(
    wildflower_api_key=os.environ.get("WILDFLOWER_API_KEY"),
)

handle = client.sandboxes.attach("wf_e2b_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
written = handle.write_file(
    WriteFileInput(
        path="/tmp/hello.txt",
        content="hello",
        encoding="utf8",
    )
)
print(written.bytes_written)
```

### Rust

```rust
use wildflower::{
    CreateSandboxInput, FileEncoding, ListSandboxesOptions, ReadFileInput,
    RunCommandInput, WriteFileInput,
    Wildflower,
};

let client = Wildflower::new(std::env::var("WILDFLOWER_API_KEY")?)?;

let handle = client.sandboxes().attach("wf_e2b_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")?;
let written = handle.write_file(&WriteFileInput {
    path: "/tmp/hello.txt".to_owned(),
    content: "hello".to_owned(),
    encoding: FileEncoding::Utf8,
}).await?;
println!("{}", written.bytes_written);
```

### Go

```go
client, err := wildflower.NewClient(os.Getenv("WILDFLOWER_API_KEY"))
if err != nil {
    return err
}

handle, err := client.Sandboxes.Attach("wf_e2b_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
if err != nil {
    return err
}
encoding := wildflower.FileEncodingUtf8
written, err := handle.WriteFile(ctx, wildflower.WriteFileInput{
    Path: "/tmp/hello.txt",
    Content: "hello",
    Encoding: &encoding,
})
if err != nil {
    return err
}
fmt.Println(written.BytesWritten)
```

### Zig

```zig
var client = try Wildflower.init(
    allocator,
    wildflower_api_key,
    transport,
);
defer client.deinit();

var handle = client.attach("wf_e2b_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
var written = try handle.writeFile(.{
    .path = "/tmp/hello.txt",
    .content = "hello",
    .encoding = .utf8,
});
defer written.deinit();
std.debug.print("{d}\n", .{written.value.bytes_written});
```

## Generated SDK methods

Every name below comes from the generator mapping for this operation, so a language-specific rename creates website drift.

- [TypeScript](https://wildflower.computer/sdk/typescript/): `writeFile`
- [Python](https://wildflower.computer/sdk/python/): `write_file`
- [Rust](https://wildflower.computer/sdk/rust/): `write_file`
- [Go](https://wildflower.computer/sdk/go/): `WriteFile`
- [Zig](https://wildflower.computer/sdk/zig/): `writeFile`
