Skip to main content
POST
/
v1
/
agents
/
{agent_id}
/
sandbox
/
file_read
Sandbox: File Read
curl --request POST \
  --url https://api.xpander.ai/v1/agents/{agent_id}/sandbox/file_read \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "path": "config.yaml",
  "start_line": 2,
  "end_line": 2,
  "encoding": "utf-8"
}
'
{
  "status": "ok",
  "stdout": "<string>",
  "stderr": "<string>",
  "exit_code": 123,
  "content": "<string>",
  "path": "<string>",
  "matches": [
    {}
  ],
  "url": "<string>",
  "error": "<string>"
}
Read a file from the per-agent sandbox filesystem. Optional line ranges let you page through large files without loading them entirely.

Path Parameters

agent_id
string
required
Agent ID (UUID)

Request Body

path
string
required
Path to the file relative to the sandbox root.
start_line
integer
1-based line number to start reading from. Optional; reads from the beginning when omitted.
end_line
integer
1-based line number to stop reading at (inclusive). Optional; reads to the end when omitted.
encoding
string
default:"utf-8"
Text encoding used to decode the file contents.

Response

status
string
Result status (e.g., ok).
content
string
File contents within the requested range.
path
string
The file path that was read.

Example Request

curl -X POST "https://api.xpander.ai/v1/agents/<agent-id>/sandbox/file_read" \
  -H "Content-Type: application/json" \
  -H "x-api-key: <your-api-key>" \
  -d '{
    "path": "config.yaml",
    "start_line": 1,
    "end_line": 50,
    "encoding": "utf-8"
  }'

Notes

  • Paths must be relative to the sandbox root. Absolute paths are rejected.
  • For binary files, set encoding appropriately or use Sandbox: File Share to retrieve the file via a public URL.

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 reading a file from the agent sandbox.

path
string
required

Path to the file relative to the sandbox root.

Example:

"config.yaml"

start_line
integer

1-based line number to start reading from. Optional; reads from the beginning when omitted.

Required range: x >= 1
end_line
integer

1-based line number to stop reading at (inclusive). Optional; reads to the end when omitted.

Required range: x >= 1
encoding
string
default:utf-8

Text encoding used to decode the file contents.

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.