---
title: Overwrite one worktree file
description: "Plain fs overwrite of an EXISTING file in the run's sandbox worktree (WIBLO-130) — no git plumbing; the dirty tree is persisted by auto-commit (085.7) and the pre-timeout checkpoint (WIBLO-126)."
api_method: PUT
api_path: "/v1/agent-runs/{runId}/workbench/files/content"
canonical_url: https://wiblo.app/docs/developers/api/agent-workbench/update-workbench-file
last_updated: 2026-07-28T17:31:44+02:00
md_url: https://wiblo.app/docs/developers/api/agent-workbench/update-workbench-file.md
---

# Overwrite one worktree file

`PUT /v1/agent-runs/{runId}/workbench/files/content`

Plain fs overwrite of an EXISTING file in the run's sandbox worktree (WIBLO-130) — no git plumbing; the dirty tree is persisted by auto-commit (085.7) and the pre-timeout checkpoint (WIBLO-126). Last write wins. Create/delete/rename are out of scope (missing path is 404). Same path guards and 200KB cap as reads. Per-user rate-limited at 30/60s.

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `runId` | `string` | Yes |  |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `path` | `string` | Yes |  |
| `content` | `string` | Yes |  |

## Request

**curl**

```bash
curl https://api.wiblo.app/v1/agent-runs/{runId}/workbench/files/content \
  -X PUT \
  -H "Authorization: Bearer $WIBLO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "path": "...",
  "content": "..."
}'
```

**TypeScript**

```ts
import { createSdk, updateWorkbenchFile } from "@workspace/sdk"

const sdk = createSdk({ baseUrl: "https://api.wiblo.app" })

const { data, error } = await updateWorkbenchFile({
  client: sdk,
  path: { runId: "..." },
  body: {
    "path": "...",
    "content": "..."
  },
})
```

## Responses

**`200`** — The file was written. Returns `UpdateWorkbenchFileResponse`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `runId` | `string` | Yes |  |
| `path` | `string` | Yes |  |
| `size` | `integer` | Yes |  |

**`400`** — Invalid or hidden file path (`INVALID_FILE_PATH`), body failed Zod validation (`VALIDATION_FAILED`), or the content is not text (`FILE_NOT_TEXT`). Returns `ApiErrorEnvelope`.

**`401`** — No valid session cookie or `wbl_*` bearer was present. Returns `ApiErrorEnvelope`.

**`404`** — No run visible to the caller with this id (`AGENT_RUN_NOT_FOUND`). Returns `ApiErrorEnvelope`.

**`409`** — No live sandbox session holds the worktree (`AGENT_SANDBOX_UNAVAILABLE`). Returns `ApiErrorEnvelope`.

**`413`** — The content exceeds the 200KB write cap, or the target file is already over the cap on disk — it was served truncated/read-only, so a capped body would destroy its tail (`FILE_TOO_LARGE`). Returns `ApiErrorEnvelope`.

**`422`** — Path param failed UUID validation (`INVALID_PARAMS`). Returns `ApiErrorEnvelope`.

**`429`** — Rate limit exceeded. The body's `error.code` is `RATE_LIMITED` and `error.details.retry_after` is the same number of seconds as the `Retry-After` header. Returns `ApiErrorEnvelope`.
