Skip to Content
APIEnvironments API

Environments API

Environments are isolated execution contexts for agent operations. Each environment has its own workspace, configuration, environment variables, and MCP servers.

The Environment Object

{ "id": "env_kJDvlIZ0mXZI0JrqbHj25", "userId": "user_abc123", "name": "production", "status": "running", "config": { "baseImage": "node:20-slim", "envVars": { "NODE_ENV": "production" }, "mcpServers": [ { "type": "stdio", "name": "filesystem", "command": "npx", "args": ["@modelcontextprotocol/server-filesystem", "/workspace"] } ] }, "createdAt": "2025-01-15T10:30:00.000Z", "updatedAt": "2025-01-15T14:22:00.000Z" }

Attributes

AttributeTypeDescription
idstringUnique identifier (env_*)
userIdstringOwner user ID
namestringHuman-readable name
statusstringstopped, building, running, error
configobjectEnvironment configuration
appIdstringAssociated application ID
metadataobjectCustom key-value metadata
createdAtstringISO 8601 timestamp
updatedAtstringISO 8601 timestamp

Environment Status

StatusDescription
stoppedContainer is not running
buildingContainer image is being built
runningContainer is active and ready
errorContainer failed to start or crashed

List Environments

GET /v1/environments

Query Parameters

ParameterTypeDefaultDescription
statusstring-Filter by status
appIdstring-Filter by application
limitnumber50Max results (1-100)
offsetnumber0Pagination offset

Example

curl https://api.computer-agents.com/v1/environments \ -H "Authorization: Bearer $API_KEY"

Response

{ "object": "list", "data": [ { "id": "env_kJDvlIZ0mXZI0JrqbHj25", "name": "production", "status": "running", "createdAt": "2025-01-15T10:30:00.000Z" }, { "id": "env_lK0Cu7erCnf0jQjXKDs26", "name": "staging", "status": "stopped", "createdAt": "2025-01-10T08:00:00.000Z" } ], "has_more": false, "total_count": 2 }

Create Environment

POST /v1/environments

Request Body

ParameterTypeRequiredDescription
namestringYesEnvironment name
configobjectNoConfiguration settings
appIdstringNoApplication ID
metadataobjectNoCustom metadata

Example

curl -X POST https://api.computer-agents.com/v1/environments \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "development", "config": { "baseImage": "python:3.11-slim", "envVars": { "DEBUG": "true" } } }'

Response

{ "environment": { "id": "env_mL1Dv8fsDoc1kRkYLEt37", "userId": "user_abc123", "name": "development", "status": "stopped", "config": { "baseImage": "python:3.11-slim", "envVars": { "DEBUG": "true" } }, "createdAt": "2025-01-20T12:00:00.000Z" } }

Get Environment

GET /v1/environments/:environmentId

Example

curl https://api.computer-agents.com/v1/environments/env_xyz789 \ -H "Authorization: Bearer $API_KEY"

Response

{ "environment": { "id": "env_xyz789", "userId": "user_abc123", "name": "development", "status": "running", "config": { "baseImage": "python:3.11-slim", "envVars": { "DEBUG": "true" } }, "createdAt": "2025-01-20T12:00:00.000Z" } }

Update Environment

PATCH /v1/environments/:environmentId

Request Body

ParameterTypeDescription
namestringNew environment name
configobjectUpdated configuration
metadataobjectUpdated metadata

Example

curl -X PATCH https://api.computer-agents.com/v1/environments/env_xyz789 \ -H "Authorization: Bearer $API_KEY" \ -H "Content-Type: application/json" \ -d '{ "config": { "envVars": { "LOG_LEVEL": "debug" } } }'

Delete Environment

DELETE /v1/environments/:environmentId

This stops any running container and deletes all environment configuration and files.

Example

curl -X DELETE https://api.computer-agents.com/v1/environments/env_xyz789 \ -H "Authorization: Bearer $API_KEY"

Response

{ "success": true }

Environment Configuration

Base Image

Specify the container base image:

{ "config": { "baseImage": "node:20-slim" } }

Common images:

  • node:20-slim - Node.js applications
  • python:3.11-slim - Python applications
  • golang:1.21-alpine - Go applications

Environment Variables

Set environment variables accessible to agents:

{ "config": { "envVars": { "NODE_ENV": "production", "DATABASE_URL": "postgres://...", "API_KEY": "secret" } } }

Environment variables are securely stored and only accessible during agent execution.

MCP Servers

Configure MCP servers available in this environment:

{ "config": { "mcpServers": [ { "type": "stdio", "name": "filesystem", "command": "npx", "args": ["@modelcontextprotocol/server-filesystem", "/workspace"] }, { "type": "http", "name": "database", "url": "https://db-mcp.example.com/mcp", "bearerToken": "token" } ] } }

File Operations

List Files

List files in an environment’s workspace.

GET /v1/environments/:environmentId/files

Query Parameters

ParameterTypeDefaultDescription
pathstring/Directory path
recursivebooleanfalseInclude subdirectories

Example

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

Response

{ "object": "list", "data": [ { "name": "app.py", "path": "/src/app.py", "type": "file", "size": 2048, "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 }

Get File

Download a file from the environment.

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

Example

curl "https://api.computer-agents.com/v1/environments/env_xyz789/files/src%2Fapp.py" \ -H "Authorization: Bearer $API_KEY"

Upload File

Upload a file to the environment.

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

Example

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

Delete File

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

Errors

StatusErrorDescription
400Bad RequestInvalid configuration
404Not FoundEnvironment not found
409ConflictContainer already in requested state
500Internal Server ErrorContainer operation failed

  • Threads - Run conversations in environments
  • Agents - Configure agents for environments
  • Costs - Track environment costs
Last updated on