---
title: "Write file"
method: POST
path: "/api/experimental/fs/write"
tags: ["filesystem"]
---

# Write file

`POST /api/experimental/fs/write`

## Request

- Base URL: `https://opencode.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://opencode.ai/api/experimental/fs/write`
- Auth: none required

Write the raw request body to an absolute path or a path relative to the requested location, creating parent directories, and return the resolved absolute path. Unlike read, the target is not confined to the location. Experimental: may change without compatibility guarantees.

## Query parameters

- `location` object, nullable
  - `directory` string, nullable
- `path` string, required: An absolute path or a path relative to the requested location. Missing parent directories are created.

## Request body `application/octet-stream`

- string, binary

## Response `200`

Success

- object
  - `location` LocationPublicRef, required
    - `directory` string, required
  - `data` FileSystemWrite, required
    - `path` string, required

## Other responses

- `400`: InvalidRequestError
- `401`: UnauthorizedError
- `404`: LocationNotFoundError

---

[API](https://skmtc.dev/kaaass/apis/opencode.md) - [All operations](https://skmtc.dev/kaaass/apis/opencode/llms.txt) - [OpenAPI document](https://skmtc.dev/kaaass/apis/opencode/revisions/4e083d954707?raw)
