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

# Workspace: File Write

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

## 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_write`
- Auth: API key in header `x-api-key`

Write (create or overwrite) a file in the agent's workspace filesystem.

## Path parameters

- `agent_id` string, required

## Request body

- FileWriteRequest
  - `path` string, required: Relative path where the file should be written. Creates or overwrites the file.
  - `content` union, required: Complete content to write. A string is written verbatim; a JSON object/array is auto-serialized to pretty JSON.
    - string
    - object
    - unknown[]
      - unknown
  - `create_dirs` boolean: If true, creates parent directories automatically if they don't exist.

## Response `200`

Successful Response

- FileWriteResponse
  - `path` string, required: The path where the file was written
  - `bytes_written` integer: Number of bytes written to the file
  - `created` boolean: True if this was a new file, False if overwritten

## 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)
