Skip to main content
POST
/
v1
/
agents
/
{agent_id}
/
workspace
/
file_write
Workspace: File Write
curl --request POST \
  --url https://api.xpander.ai/v1/agents/{agent_id}/workspace/file_write \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "path": "<string>",
  "content": "<string>",
  "create_dirs": true
}
'
{
  "path": "<string>",
  "bytes_written": 0,
  "created": false
}
Create or overwrite a file in the per-agent workspace filesystem. When create_dirs is true, any missing parent directories are created automatically.

Path Parameters

agent_id
string
required
Agent ID (UUID)

Request Body

path
string
required
Destination file path relative to the workspace root.
content
string
required
Full file content. Existing files are overwritten.
create_dirs
boolean
default:true
When true, missing parent directories are created automatically.

Response

status
string
Result status (e.g., ok).
path
string
Path of the file that was written.

Example Request

curl -X POST "https://api.xpander.ai/v1/agents/<agent-id>/workspace/file_write" \
  -H "Content-Type: application/json" \
  -H "x-api-key: <your-api-key>" \
  -d '{
    "path": "output/report.txt",
    "content": "Hello World\n",
    "create_dirs": true
  }'

Notes

See Also

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

agent_id
string
required

Body

application/json
path
string
required

Relative path where the file should be written. Creates or overwrites the file.

Example:

"output/report.txt"

content
string
required

Complete content to write to the file.

Example:

"Hello World\n"

create_dirs
boolean
default:true

If true, creates parent directories automatically if they don't exist.

Response

Successful Response

path
string
required

The path where the file was written

bytes_written
integer
default:0

Number of bytes written to the file

Example:

12

created
boolean
default:false

True if this was a new file, False if overwritten