Skip to Content
APIFiles API

Files API

Each environment has a workspace for files, backed by Google Cloud Storage. The Files API lets you upload, download, list, and manage files that agents can access during execution.

Overview

Files in an environment workspace are:

  • Accessible to agents executing in that environment
  • Synced automatically with cloud storage
  • Persisted between executions
  • Isolated per environment

Files are scoped to environments. Each environment has its own isolated workspace.


List Files

Returns files in an environment workspace.

GET /v1/environments/:environmentId/files

Query Parameters

ParameterTypeDefaultDescription
pathstring/Directory path to list
recursivebooleanfalseInclude subdirectories

Example

curl "https://api.computer-agents.com/v1/environments/env_abc123/files?path=/src" \ -H "Authorization: Bearer $API_KEY"

Response

{ "object": "list", "data": [ { "name": "app.py", "path": "/src/app.py", "type": "file", "size": 2048, "mimeType": "text/x-python", "modifiedAt": "2025-01-15T10:30:00.000Z" }, { "name": "utils", "path": "/src/utils", "type": "directory", "modifiedAt": "2025-01-14T08:00:00.000Z" } ], "path": "/src", "has_more": false, "total_count": 2 }

File Object

AttributeTypeDescription
namestringFile or directory name
pathstringFull path from workspace root
typestringfile or directory
sizenumberSize in bytes (files only)
mimeTypestringMIME type (files only)
modifiedAtstringLast modification time

Get File

Downloads a file’s content.

GET /v1/environments/:environmentId/files/:path

Path Parameters

ParameterDescription
pathURL-encoded file path (e.g., src%2Fapp.py)

Query Parameters

ParameterTypeDescription
downloadbooleanForce download (vs inline)

Example

# Get file content curl "https://api.computer-agents.com/v1/environments/env_abc123/files/src%2Fapp.py" \ -H "Authorization: Bearer $API_KEY" # Download as attachment curl "https://api.computer-agents.com/v1/environments/env_abc123/files/src%2Fapp.py?download=true" \ -H "Authorization: Bearer $API_KEY" \ -o app.py

Response

Returns the file content with appropriate Content-Type header.

Content-Type: text/x-python Content-Length: 2048 from flask import Flask app = Flask(__name__) ...

Upload File

Uploads a file to the environment workspace.

PUT /v1/environments/:environmentId/files/:path

Path Parameters

ParameterDescription
pathDestination path (URL-encoded)

Headers

HeaderRequiredDescription
Content-TypeYesFile MIME type
Content-LengthYesFile size in bytes

Example

curl -X PUT "https://api.computer-agents.com/v1/environments/env_abc123/files/src%2Fnew_file.py" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: text/x-python" \ --data-binary @new_file.py

Response

{ "success": true, "file": { "name": "new_file.py", "path": "/src/new_file.py", "type": "file", "size": 142, "mimeType": "text/x-python", "modifiedAt": "2025-01-20T12:00:00.000Z" } }

Delete File

Deletes a file or directory.

DELETE /v1/environments/:environmentId/files/:path

Query Parameters

ParameterTypeDefaultDescription
recursivebooleanfalseDelete directory contents

Deleting a directory requires recursive=true if it contains files.

Example

# Delete single file curl -X DELETE "https://api.computer-agents.com/v1/environments/env_abc123/files/src%2Fold_file.py" \ -H "Authorization: Bearer $API_KEY" # Delete directory recursively curl -X DELETE "https://api.computer-agents.com/v1/environments/env_abc123/files/old_folder?recursive=true" \ -H "Authorization: Bearer $API_KEY"

Response

{ "success": true }

Create Directory

Creates a new directory in the workspace. Parent directories are created automatically if they don’t exist.

POST /v1/environments/:environmentId/files/mkdir

Request Body

ParameterTypeRequiredDescription
pathstringYesDirectory path to create (relative to workspace root)

Example

curl -X POST "https://api.computer-agents.com/v1/environments/env_abc123/files/mkdir" \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{"path": "src/components"}'

Response

{ "success": true, "path": "src/components", "environmentId": "env_abc123" }

Parent directories are created recursively. Creating src/components/ui will also create src and src/components if they don’t exist.


Bulk Upload

Upload multiple files at once.

POST /v1/environments/:environmentId/files/bulk

Request Body (multipart/form-data)

FieldTypeDescription
filesFile[]Files to upload
basePathstringBase directory path

Example

curl -X POST "https://api.computer-agents.com/v1/environments/env_abc123/files/bulk" \ -H "Authorization: Bearer $API_KEY" \ -F "basePath=/src" \ -F "files=@app.py" \ -F "files=@utils.py" \ -F "files=@config.py"

Response

{ "success": true, "uploaded": [ { "path": "/src/app.py", "size": 2048 }, { "path": "/src/utils.py", "size": 1024 }, { "path": "/src/config.py", "size": 512 } ], "total": 3 }

Errors

StatusErrorDescription
400Bad RequestInvalid path or content
404Not FoundFile or directory not found
409ConflictFile already exists
413Payload Too LargeFile exceeds size limit
507Insufficient StorageWorkspace quota exceeded

Size Limits

LimitValue
Single file100 MB
Bulk upload500 MB total
Workspace10 GB per environment

Last updated on