Skip to main content
POST
/
v1
/
agents
/
{agent_id}
/
sandbox
/
file_write
Sandbox: File Write
curl --request POST \
  --url https://api.xpander.ai/v1/agents/{agent_id}/sandbox/file_write \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "path": "output/report.txt",
  "content": "<string>",
  "create_dirs": true
}
'
{
  "status": "ok",
  "stdout": "<string>",
  "stderr": "<string>",
  "exit_code": 123,
  "content": "<string>",
  "path": "<string>",
  "matches": [
    {}
  ],
  "url": "<string>",
  "error": "<string>"
}
Create or overwrite a file in the per-agent sandbox 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 sandbox 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>/sandbox/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

Agent UUID

Body

application/json

Request body for creating or overwriting a file in the agent sandbox.

path
string
required

Destination file path relative to the sandbox root.

Example:

"output/report.txt"

content
string
required

Full file content. Existing files are overwritten.

create_dirs
boolean
default:true

When true, missing parent directories are created automatically.

Response

Successful Response

Generic response wrapper returned by agent sandbox endpoints. Not every field is populated for every tool.

status
string

Result status of the sandbox operation.

Example:

"ok"

stdout
string | null

Standard output captured from the sandbox command. Present for bash.

stderr
string | null

Standard error captured from the sandbox command. Present for bash.

exit_code
integer | null

Process exit code returned by the sandbox. Present for bash.

content
string | null

File contents. Present for file_read.

path
string | null

File path affected by the operation. Present for file_write, file_edit, multi_edit, file_share.

matches
Matches · object[] | null

Match results. Present for glob and grep.

url
string<uri> | null

Public CDN URL. Present for file_share.

error
string | null

Error message when the operation fails.