Skip to main content
Read the contents of files from the sandbox filesystem.
curl -X POST https://api.gravixlayer.com/v1/agents/sandboxes/{sandbox_id}/files/read \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "/home/user/data.csv"
  }'

Request Parameters

ParameterTypeRequiredDescription
pathstringYesAbsolute or relative path to the file

Response

{
  "content": "name,age\nAlice,25\nBob,30",
  "path": "/home/user/data.csv",
  "size": 23
}

Response Fields

FieldTypeDescription
contentstringFile contents as text
pathstringFull path to the file
sizeintegerFile size in bytes

Common File Paths

  • /home/user/ - User home directory
  • /home/user/output/ - Common output directory
  • /home/user/data/ - Common data directory
  • /tmp/ - Temporary files

Example: Read Configuration

curl -X POST https://api.gravixlayer.com/v1/agents/sandboxes/{sandbox_id}/files/read \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "/home/user/config.json"
  }'

Example: Read Generated Output

curl -X POST https://api.gravixlayer.com/v1/agents/sandboxes/{sandbox_id}/files/read \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "/home/user/results.txt"
  }'

Error Handling

File Not Found:
{
  "error": {
    "code": "file_not_found",
    "message": "File not found: /home/user/missing.txt"
  }
}
Permission Denied:
{
  "error": {
    "code": "permission_denied",
    "message": "Permission denied: /root/private.txt"
  }
}

Next Steps