---
title: "Workspace: File Edit"
method: POST
path: "/v1/agents/{agent_id}/workspace/file_edit"
tags: ["API v1", "Agents", "Agents Workspace"]
---

# Workspace: File Edit

`POST /v1/agents/{agent_id}/workspace/file_edit`

## Request

- Base URL: `https://api.xpander.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.xpander.ai/v1/agents/{agent_id}/workspace/file_edit`
- Auth: API key in header `x-api-key`

Edit a file in the agent's workspace by replacing exact text occurrences.

## Path parameters

- `agent_id` string, required

## Request body

- FileEditRequest
  - `path` string, required: Relative path to the file to edit.
  - `old_text` string, required: The exact text to find and replace. Must match the file content exactly (whitespace-sensitive).
  - `new_text` string, required: The replacement text that will substitute old_text.

## Response `200`

Successful Response

- FileEditResponse
  - `path` string, required: The path of the edited file
  - `replacements_made` integer: Number of replacements made

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/xpander/apis/xpander-ai-api-service.md) - [All operations](https://skmtc.dev/xpander/apis/xpander-ai-api-service/llms.txt) - [OpenAPI document](https://skmtc.dev/xpander/apis/xpander-ai-api-service/revisions/725c0066d5df?raw)
