tencent cloud

HTTP API (Beta)

Download
Focus Mode
Font Size
Last updated: 2026-09-30 18:41:48
AI-Translated
Note:
Beta: This API is in the Beta stage, and its interface may be adjusted. Feedback is welcome.
CodeBuddy Code provides two sets of public APIs for developers to build Agent applications:
REST API (/api/v1/*) — Stateless HTTP request/response, suitable for Webhook integration, management operations, and simple queries.
ACP (/api/v1/acp) — A stateful streaming protocol (JSON-RPC over SSE), suitable for building complete Agent client applications.

Quick Start

Start the HTTP service

codebuddy --serve --port 8080 --session-id my-session

API Documentation (Swagger UI)

After the service starts, access:
Interactive documentation: http://127.0.0.1:8080/api/docs
OpenAPI specification: http://127.0.0.1:8080/api/openapi.json
Swagger UI provides an interactive testing interface for all public endpoints.

Verifying That the Service Is Running Normally

curl http://127.0.0.1:8080/api/v1/health
# {"data":{"status":"ok","uptime":12.3,"platforms":["generic","wecom","wechat-kf"]}}

API Layering

Layer
Route prefix
Compatibility Commitment
Description
Public REST API
/api/v1/*
Semantic versioning, no breaking changes
Content covered in this document
Public ACP protocol
/api/v1/acp
Complies with the ACP specification
Full conversation capability. For more information, see the ACP document.
Internal RPC
/internal/*
No compatibility guarantee
Used internally by CLI and not exposed externally.

Security

Custom request header

All API requests (except exempt paths) must include a custom request header:
X-CodeBuddy-Request: 1
How it works: A custom request header makes the browser's cross-origin request a "non-simple request", forcing a CORS preflight. Combined with a CORS allowlist, requests from unauthorized origins are blocked. Even if an attacker uses fetch(url, { mode: 'no-cors' }), the browser does not allow custom headers to be sent in no-cors mode, so the request is rejected by the server (403) due to the missing header.

Exempted Paths

The following paths do not require the X-CodeBuddy-Request header:
Path
Description
GET /
SPA entry page
GET /assets/*
Static resources
GET /docs/*
API documentation page
GET /manifest.webmanifest
PWA manifest
GET /api/v1/auth/status
Check authentication status
POST /api/v1/auth/login
Log in.
*/api/v1/webhooks/*
Webhook (with platform signature verification)
GET /api/openapi.json
OpenAPI specification
GET /api/docs*
Swagger UI
You can disable this validation by setting the environment variable CODEBUDDY_DISABLE_REQUEST_VALIDATION=1.

CORS Allowlist

The Origin of a cross-origin request is matched against the server-side CORS allowlist. Sources not in the allowlist are rejected, with the preflight returning a 204 without CORS headers and the actual request returning a 403 Origin not allowed. Allowlist sources:
Loopback variants of the local endpoint itself (localhost / 127.0.0.1 / [::1], only on the port the service actually listens on)
Tunnel URL (if enabled)
Configuration item gateway.corsOrigins
The environment variable CODEBUDDY_CODE_CORS_ORIGINS (comma-separated, supports exact origins, *.domain subdomain wildcards, and * to allow all)
Note:
Loopback origins are no longer allowed unconditionally. Earlier implementations allowed any localhost / 127.0.0.1 origin regardless of port, which meant that any page in the user's browser occupying a local port (for example, a malicious page running at http://localhost:3000) could make cross-origin calls to this service's process execution and file read/write interfaces. The Cookie SameSite=Strict setting cannot protect against this scenario because ports are not part of a "site", so localhost:3000 and localhost:8321 belong to the same site but different origins, and the browser will still send the session Cookie as usual.
Local development (Vite dev server 5173 → backend 8321 is cross-origin) requires explicitly declaring the origin:
CODEBUDDY_CODE_CORS_ORIGINS=http://localhost:5173 codebuddy --serve
When a request is rejected, both the server-side logs and the hint field in the 403 response body indicate this configuration method.
When binding to 0.0.0.0 (for example, --host 0.0.0.0, common in cloud VM or LAN exposure scenarios), if CODEBUDDY_CODE_CORS_ORIGINS is not explicitly set, the server automatically allows all origins (equivalent to configuring *), so the Web UI can be accessed through any IP address or domain without additional configuration. If this environment variable is explicitly set, the user configuration takes precedence. In this scenario, authentication is mandatory (see below), and credentials are still required.

Authentication

--serve enables password authentication by default. On first startup, a random password is generated and written to ~/.codebuddy/settings.json, and a clickable link containing the password is printed in the terminal:
Endpoint http://127.0.0.1:8321
Web UI http://127.0.0.1:8321/?password=<generated password>

Password <generated password>
Config ~/.codebuddy/settings.json
Click this link to log in to the Web UI. The server issues a gateway_session Cookie valid for 30 days, so you can access the endpoint directly afterward without entering the password again.
Authentication mode priority (high → low):
Source
Value
Description
Environment variable CODEBUDDY_GATEWAY_AUTH
password / none
Highest priority, suitable for CI.
Binding a non-loopback address (such as --host 0.0.0.0)
Force password
Disabling is not allowed when it is exposed externally.
Command line --auth <mode>
password / none
-
Configuration item gateway.auth
password / none
-
Default
password
--serve fallback mode
Security Note:
These endpoints include sensitive capabilities such as executing processes (/api/v1/process/*), reading and writing arbitrary files (/api/v1/files/*, /api/v1/fs/*), and interactive terminals (/api/v1/pty/*). Therefore, authentication is enforced by default (secure by default, consistent with the default behavior of E2B Secured Access). Disabling authentication means that any process on the same machine can run commands and read or write files through this service, so it is recommended only in isolated environments (containers / disposable sandboxes) or CI.
Disable authentication (use only when you fully understand the risks; a warning is printed at startup):
codebuddy --serve --auth none
# or
CODEBUDDY_GATEWAY_AUTH=none codebuddy --serve

Ways to Carry Credentials

API requests (/api/v1/*) accept only request headers or Cookies:
# 1) Bearer Token (recommended, also carries security headers)
curl -H "X-CodeBuddy-Request: 1" \\
-H "Authorization: Bearer YOUR_PASSWORD" \\
http://host:port/api/v1/sessions

# 2) X-Access-Token (equivalent to Bearer, aligned with the credential header convention of E2B envd)
curl -H "X-CodeBuddy-Request: 1" \\
-H "X-Access-Token: YOUR_PASSWORD" \\
http://host:port/api/v1/sessions

# 3) Cookie (automatically carried by the browser after login)
curl -H "X-CodeBuddy-Request: 1" \\
-H "Cookie: gateway_session=<sha256(password)>" \\
http://host:port/api/v1/sessions
Note:
?password= is valid only for GET / and POST /api/v1/auth/login, and is invalid for other /api/v1/* endpoints (which return 401). This is by design: URLs are recorded in browser history and server access logs, and can be leaked when users copy and share links, so the password does not appear in API request URLs. The sole purpose of ?password= is to exchange for a gateway_session Cookie on first entry.
Testing the API with ?password= returns 401, which does not indicate a problem with the authentication implementation.

Response Format

All /api/v1/* endpoints use a unified envelope format:
// Success
{
"data": { ... }
}

// Error
{
"error": {
"code": "AUTH_REQUIRED", // Machine-readable error code
"message": "Authentication required" // Human-readable description
}
}

Endpoint Overview

System

Methodology
Endpoint
Description
GET
/api/v1/health
Health Check
GET
/api/v1/info
Environment Information (Version, OS, CWD, and so on)
GET
/api/v1/metrics
System Resource Metrics + Instance Process Metrics
GET
/api/v1/envs
Environment Variables (Aligned with E2B envd)

Authentication

Methodology
Endpoint
Description
GET
/api/v1/auth/status
Obtain the authentication status
POST
/api/v1/auth/login
Log in with a password and return a token.

Runs (Agent Execution)

Methodology
Endpoint
Description
POST
/api/v1/runs
Start Agent execution (asynchronous, returns runId).
GET
/api/v1/runs/:runId
Query execution status
GET
/api/v1/runs/:runId/stream
Obtain execution results via SSE streaming
POST
/api/v1/runs/:runId/cancel
Canceling Execution

Webhooks (Third-Party Platform Integration)

Methodology
Endpoint
Description
GET
/api/v1/webhooks/:platform
Platform URL verification (WeCom and others)
POST
/api/v1/webhooks/:platform
Platform message Webhook entry
Supported platforms: generic, wecom (WeCom), wechat-kf (WeChat Customer Service)

Session

Methodology
Endpoint
Description
GET
/api/v1/sessions
Obtain the session list (supports the cwd query parameter).
DELETE
/api/v1/sessions/:id
Delete a session.
POST
/api/v1/sessions/:id/rename
Rename a session.
GET
/api/v1/sessions/across-projects
Deprecated. Use GET /api/v1/sessions?cwd=* instead.
GET
/api/v1/sessions/workspaces
Deprecated

PTY (Terminal)

Methodology
Endpoint
Description
POST
/api/v1/pty
Create a PTY session.
GET
/api/v1/pty
List PTY sessions.
GET
/api/v1/pty/:id
Query a PTY session.
DELETE
/api/v1/pty/:id
Terminate a PTY session.
GET
/api/v1/pty/:id/output
Obtain PTY output via SSE streaming (replacing WebSocket).
POST
/api/v1/pty/:id/input/send
Send PTY input (aligned with E2B Process.SendInput).
POST
/api/v1/pty/:id/resize
Resize a PTY (aligned with E2B Process.Update).
WebSocket
/api/v1/pty/:id/ws
Bidirectional PTY data transfer (retained for compatibility)

Workers & Daemon

A Worker is a running CLI process (interactive / bg / daemon) that is managed through a PID file registry.
Methodology
Endpoint
Description
GET
/api/v1/workers
Obtain the list of all active Workers.
POST
/api/v1/workers
Manually add a remote Worker.
GET
/api/v1/workers/:id
Obtain Worker details (by PID or name).
GET
/api/v1/workers/:id/logs
Obtain Worker logs (multiple types supported).
DELETE
/api/v1/workers/:id
Terminate Worker process.
GET
/api/v1/daemon/status
Query Daemon status.
POST
/api/v1/daemon/start
Start Daemon.
POST
/api/v1/daemon/stop
Stop Daemon.
POST
/api/v1/daemon/restart
Restart Daemon.
Workers query parameters:
?kind=bg — Filter by type (interactive / bg / daemon / daemon-worker).
?local=true — Return only local Workers (used for remote proxy calls).
Log type parameters (GET /api/v1/workers/:id/logs):
?type=telemetry — Telemetry logs (~/.codebuddy/logs/{date}/)
?type=process — Process stdout/stderr (bg/daemon logs)
?type=debug — Debug logs (~/.codebuddy/debug/, requires --debug)
?type=transcript — Conversation history summary
?tail=200 — Return only the last N lines.
When type is not specified, the best source is automatically selected (telemetry > process > debug > transcript).

Jobs (Background Agent Instances)

Jobs are background agent instances dispatched by /bg, the left arrow background action, or codebuddy agents. They share the JobStore and lifecycle semantics with the CLI agent-view / TUI.
Methodology
Endpoint
Description
GET
/api/v1/jobs
Obtain the instance list. Supports filtering by all=1 and cwd.
POST
/api/v1/jobs
Dispatch a background agent or shell job.
GET
/api/v1/jobs/events
Subscribe to snapshot / added / changed / removed / keepalive via SSE.
GET
/api/v1/jobs/prefs
Obtain pinned and project group preferences.
PUT
/api/v1/jobs/prefs
Batch update pinned and project group preferences.
GET
/api/v1/jobs/dispatch-context
Obtain the startup directory, available agents, and repository targets.
GET
/api/v1/jobs/resumable
Obtain resumable historical sessions. Supports cwd and includeAttached=1.
POST
/api/v1/jobs/resume
Resume from a historical session as a standalone job.
GET
/api/v1/jobs/:id
Obtain job details. The id supports stable ID, short ID, or sessionId.
PATCH
/api/v1/jobs/:id/name
Rename job.
POST
/api/v1/jobs/:id/reply
Reply to a job waiting for input.
POST
/api/v1/jobs/:id/stop
Stop job.
POST
/api/v1/jobs/:id/respawn
Restart the job and resume the conversation.
DELETE
/api/v1/jobs/:id
Delete job record.
GET
/api/v1/jobs/:id/stream
Replay the transcript tail over SSE and follow new output.
GET
/api/v1/jobs/:id/transcript
Return up to the latest 1,000 lines of ACP replay updates at once.
Dispatch request body (POST /api/v1/jobs):
Field
Type
Required
Description
prompt
string
Yes
Initial instruction; a shell command when bash=true.
cwd
string
No
Startup directory; the current working directory by default
agent / model
string
No
Custom Agent or model
effort
string
No
minimal / low / medium / high / xhigh / max
permissionMode
string
No
default / acceptEdits / plan / auto / dontAsk / bypassPermissions
name
string
No
Name displayed in the list
bash
boolean
No
Dispatch a one-time shell job
sourceSessionId
string
No
Inherit the restricted context; the new job still uses an independent session.
bgIsolation
string
No
none / worktree; follows the global background write isolation setting when the parameter is omitted.
effort, permissionMode, and bgIsolation are validated against an allowlist. Invalid values return 400 BAD_REQUEST. When optional fields are omitted in a request, session or global default values are not overridden.
Lifecycle fields:
state: working / blocked / done / failed / stopped
status: The current state of a live process: busy / waiting / idle / stopped
tempo: active / idle / blocked
alive and settled are independent. settled=true && alive=false indicates a completed history.
foregroundHeld=true indicates that the resource is still held by the foreground terminal and cannot be attached at this time.
webUrl is returned only when the job worker is alive and listening on loopback HTTP(S). Otherwise, it is null.
Conversations and Errors:
/transcript returns { sessionId, updates } in a single response, containing at most the latest 1000 lines of converted ACP replay updates.
/stream returns text/event-stream. It first replays up to 1000 lines, then tails new JSONL records every second. shell jobs return an empty stream.
A nonexistent job returns 404 JOB_NOT_FOUND.
If the deletion is rejected by the worktree or foreground hold guard, HTTP 200 is still returned, but the body is { "deleted": false, "reason": "..." }.
# Dispatch Background Agent
curl -H "X-CodeBuddy-Request: 1" \\
-H "Authorization: Bearer $PASSWORD" \\
-H 'Content-Type: application/json' \\
-X POST http://127.0.0.1:8080/api/v1/jobs \\
-d '{"prompt":"Check the test status of the current repository","cwd":"/repo/app"}'

# Subscribe to job List Changes
curl -N -H "X-CodeBuddy-Request: 1" \\
-H "Authorization: Bearer $PASSWORD" \\
http://127.0.0.1:8080/api/v1/jobs/events

Channels (Remote Control)

Methodology
Endpoint
Description
GET
/api/v1/channels
Obtain the client list
POST
/api/v1/channels/:type/:id/start
Start the client.
POST
/api/v1/channels/:type/:id/stop
Stop the client.
POST
/api/v1/channels/wechat
Create a WeChat instance.
POST
/api/v1/channels/wecom
Create a WeCom instance.

File System (E2B Compatible)

File content operations (aligned with E2B envd HTTP endpoints):
Methodology
Endpoint
Description
GET
/api/v1/files/download?path=...
Download File (Aligned with E2B envd GET /files).
POST
/api/v1/files/upload?path=...
Upload File (Aligned with E2B envd POST /files).
POST
/api/v1/files/compose
Merge Multiple Files (Aligned with E2B envd POST /files/compose).
File operations (aligned with E2B filesystem.proto):
Methodology
Endpoint
Description
POST
/api/v1/fs/stat
Obtain file/directory information (aligned with Filesystem.Stat).
POST
/api/v1/fs/list
List directory contents (aligned with Filesystem.ListDir).
POST
/api/v1/fs/mkdir
Create a directory (aligned with Filesystem.MakeDir).
POST
/api/v1/fs/remove
Delete a file/directory (aligned with Filesystem.Remove).
POST
/api/v1/fs/move
Move/rename (aligned with Filesystem.Move).
File watching (aligned with E2B filesystem.proto):
Methodology
Endpoint
Description
POST
/api/v1/fs/watch
Streaming directory monitoring over SSE (aligned with Filesystem.WatchDir)
POST
/api/v1/fs/watcher/create
Create a watcher (aligned with Filesystem.CreateWatcher).
POST
/api/v1/fs/watcher/events
Obtain watcher events (aligned with Filesystem.GetWatcherEvents).
POST
/api/v1/fs/watcher/remove
Remove a watcher (aligned with Filesystem.RemoveWatcher).
CBC enhancements:
Methodology
Endpoint
Description
GET
/api/v1/fs/search?query=...
Fuzzy file search (based on ripgrep; no corresponding E2B interface)

Process Management (E2B Compatible)

Align with E2B process.proto and map gRPC methods to REST endpoints:
Methodology
Endpoint
Description
POST
/api/v1/process/start
Start a process (aligned with Process.Start, supporting SSE/JSON).
GET
/api/v1/process/list
List running processes (aligned with Process.List).
POST
/api/v1/process/connect
Connect to the process SSE stream (aligned with Process.Connect).
POST
/api/v1/process/input/send
Send stdin (aligned with Process.SendInput).
POST
/api/v1/process/input/stream
Stream stdin (aligned with Process.StreamInput).
POST
/api/v1/process/signal/send
Send a signal (aligned with Process.SendSignal).
POST
/api/v1/process/stdin/close
Close stdin (aligned with Process.CloseStdin).
POST
/api/v1/process/update
Update process configuration such as PTY resize (aligned with Process.Update).

ACP(Agent Client Protocol)

Methodology
Endpoint
Description
POST
/api/v1/acp/connect
Establish an ACP connection and return the connectionId and sessionToken.
GET
/api/v1/acp
SSE notification subscription (requires the acp-connection-id Header)
POST
/api/v1/acp
Send JSON-RPC requests (newSession, prompt, cancelRun, and so on).
DELETE
/api/v1/acp
Disconnect.

File Changes (Checkpoint) — Internal

Methodology
Endpoint
Description
POST
/internal/file-changes/diff
Obtain the diff content of a single file.
POST
/internal/file-changes/checkpoints
List revertible checkpoints.
POST
/internal/file-changes/revert
Revert file changes or roll back to a checkpoint.
Note:
These are internal endpoints with no stability guarantees and are intended solely for consumption by the Web UI.

Plugin Management

Methodology
Endpoint
Description
GET
/api/v1/plugins
List installed plugins (optionally filter built-in plugins with includeBuiltin=false).
POST
/api/v1/plugins
Installing the Plugin.
POST
/api/v1/plugins/validate
Validate plugin/marketplace manifest file.
POST
/api/v1/plugins/enable
Enable Plugin.
POST
/api/v1/plugins/disable
Disable Plugin.
POST
/api/v1/plugins/uninstall
Uninstalling a Plugin.
POST
/api/v1/plugins/update
Update plugin to the latest version.
GET
/api/v1/plugins/marketplaces
List configured plugin marketplaces (optionally filter built-in marketplaces with includeBuiltin=false).
POST
/api/v1/plugins/marketplaces
Add a plugin marketplace (optionally enable automatic updates upon addition with autoUpdate).
POST
/api/v1/plugins/marketplaces/browse
Browse available plugins in the marketplace.
POST
/api/v1/plugins/marketplaces/update
Update marketplace (sync remote repository content).
POST
/api/v1/plugins/marketplaces/auto-update
Enable or disable automatic marketplace updates.
DELETE
/api/v1/plugins/marketplaces/:name
Delete plugin marketplace.

Configuration Management

Methodology
Endpoint
Description
GET
/api/v1/settings
List all configurations.
GET
/api/v1/settings/:key
Get a single configuration value.
PUT
/api/v1/settings/:key
Set configuration value.
POST
/api/v1/settings/:key/items
Append values to array configuration.
POST
/api/v1/settings/:key/remove
Remove values from array configuration.

Working Directory

Methodology
Endpoint
Description
GET
/api/v1/workspace-dirs
List Currently Attached Working Directories.
POST
/api/v1/workspace-dirs
Add a Single Working Directory.
DELETE
/api/v1/workspace-dirs?path=
Remove a Single Working Directory.
PUT
/api/v1/workspace-dirs/sync
Fully Synchronize the Working Directory List.

Task template

Methodology
Endpoint
Description
GET
/api/v1/tasks/templates
Obtain task templates.
POST
/api/v1/tasks/templates/refresh
Refresh (trigger AI recommendations).

Usage Statistics

Methodology
Endpoint
Description
GET
/api/v1/stats
Historical usage statistics (across all projects)
GET
/api/v1/stats/session
Real-time statistics for the current session

Tracing

Methodology
Endpoint
Description
GET
/api/v1/traces
Obtain the trace list (supports pagination and filtering).
GET
/api/v1/traces/:traceId
Obtain trace details (including spans).
DELETE
/api/v1/traces
Clear all traces.
Traces query parameters:
?offset=0&limit=50 — Pagination (limit has an upper bound of 200)
?session_id=xxx — Filter by session ID
?worker_pid=12345 — Specify a Worker instance (supports remote proxy)
?worker_pid=all — Scan all instances

Scheduled task

Methodology
Endpoint
Description
GET
/api/v1/scheduled-tasks
Obtaining the Scheduled Task List.
POST
/api/v1/scheduled-tasks
Creating a Scheduled Task.
DELETE
/api/v1/scheduled-tasks/:id
Deleting a Schedule Task.
Scheduled task query parameters:
?sessionId=xxx — Session ID (required; if not provided, the current active session is used)

Usage Examples

The following examples omit common request headers to highlight endpoint-specific parameters. You must include them when actually calling /api/v1/*:
-H "X-CodeBuddy-Request: 1" -H "Authorization: Bearer $PASSWORD"
$PASSWORD is the password printed when --serve starts (see Authentication). A missing security header results in a 403 Missing required header response, and missing credentials result in a 401 AUTH_REQUIRED response. Only exempt endpoints such as /api/v1/health and /api/v1/auth/status can be accessed directly.

Health Check

curl http://127.0.0.1:8080/api/v1/health

Starting Agent Execution

# Send a message (the body must be in Gateway Protocol format, and id/type are required)
curl -X POST http://127.0.0.1:8080/api/v1/runs \\
-H "Content-Type: application/json" \\
-H "X-CodeBuddy-Request: 1" \\
-d '{
"id": "run-1",
"type": "message",
"source": {"platform": "generic", "sender": {"id": "dev", "name": "Developer"}, "conversation": {"id": "run-1", "type": "direct"}},
"payload": {"text": "Help me analyze the code performance"}
}'

# Response: {"data": {"runId": "uuid-xxx", "status": "accepted"}}

# Obtain results through an SSE stream (the X-CodeBuddy-Request header is also required)
curl -H "X-CodeBuddy-Request: 1" http://127.0.0.1:8080/api/v1/runs/uuid-xxx/stream

Request Body Fields (Gateway Protocol)

The request body of POST /api/v1/runs uses the Gateway Protocol inbound message format:
Field
Required
Type
Description
id
Yes
string
Unique message ID generated by the caller, used for deduplication and tracing.
type
Yes
"message" | "action"
Message type. message initiates a conversation, and action sends a control instruction.
payload.text
No
string
prompt text (also compatible with top-level text / prompt)
payload.attachments
No
array
Attachment list. Elements include type (image/voice/video/file), url, urlType (local-path/url), and so on.
version
No
string
Protocol version, defaulting to "1.0"
source.platform
No
string
Source platform, defaulting to "generic"
source.sender.id
No
string
Sender ID, used for rate limiting; defaults to "unknown"
source.sender.name
No
string
Sender name
source.conversation.id
No
string
Conversation ID, defaulting to id
source.conversation.type
No
"direct" | "group"
Conversation type, defaulting to "direct"
action
No
"cancel" | "status"
Control action used only when type="action"
callback.url
No
string
Callback URL for asynchronously returning results (mode B)
callback.headers
No
object
Custom headers attached to callback requests
timeoutMs
No
number
Timeout for a single execution in milliseconds, with a higher priority than settings.gateway.runTimeoutMs. It can also be set through the request header X-Codebuddy-Run-Timeout. Setting it to 0 or a negative number disables timeout protection.
For the authoritative definition, see GatewayInboundMessage in the source code at src/node/remote-gateway/gateway-protocol.ts.

PTY Terminal Management

# Create a terminal
curl -X POST http://127.0.0.1:8080/api/v1/pty \\
-H "Content-Type: application/json" \\
-d '{"cols": 120, "rows": 40}'

# List terminals
curl http://127.0.0.1:8080/api/v1/pty

# Stream output over SSE (instead of WebSocket)
curl http://127.0.0.1:8080/api/v1/pty/SESSION_ID/output

# Send input.
curl -X POST http://127.0.0.1:8080/api/v1/pty/SESSION_ID/input/send \\
-H "Content-Type: application/json" \\
-d '{"data": "ls -la\\n"}'

# Resize
curl -X POST http://127.0.0.1:8080/api/v1/pty/SESSION_ID/resize \\
-H "Content-Type: application/json" \\
-d '{"cols": 200, "rows": 50}'

# Terminate a terminal
curl -X DELETE http://127.0.0.1:8080/api/v1/pty/SESSION_ID

File System Operations (E2B Compatible)

# Download files.
curl "http://127.0.0.1:8080/api/v1/files/download?path=/tmp/test.txt"

# Upload documents.
curl -X POST "http://127.0.0.1:8080/api/v1/files/upload?path=/tmp/upload.txt" \\
-H "Content-Type: application/octet-stream" \\
--data-binary @local-file.txt

# Get file information.
curl -X POST http://127.0.0.1:8080/api/v1/fs/stat \\
-H "Content-Type: application/json" \\
-d '{"path": "/tmp"}'

# List directories.
curl -X POST http://127.0.0.1:8080/api/v1/fs/list \\
-H "Content-Type: application/json" \\
-d '{"path": "/tmp", "depth": 2}'

# Create a directory.
curl -X POST http://127.0.0.1:8080/api/v1/fs/mkdir \\
-H "Content-Type: application/json" \\
-d '{"path": "/tmp/new-dir"}'

# Fuzzy file search (CBC enhancement)
curl "http://127.0.0.1:8080/api/v1/fs/search?query=component&limit=10"

Process Management (E2B Compatible)

# Start a process (JSON mode)
curl -X POST http://127.0.0.1:8080/api/v1/process/start \\
-H "Content-Type: application/json" \\
-d '{"process": {"cmd": "python3", "args": ["script.py"]}, "tag": "my-script"}'

# Start a process (SSE streaming output)
curl -X POST http://127.0.0.1:8080/api/v1/process/start \\
-H "Content-Type: application/json" \\
-H "Accept: text/event-stream" \\
-d '{"process": {"cmd": "python3", "args": ["script.py"]}}'

# List running processes.
curl http://127.0.0.1:8080/api/v1/process/list

# Send stdin.
curl -X POST http://127.0.0.1:8080/api/v1/process/input/send \\
-H "Content-Type: application/json" \\
-d '{"process": {"pid": 12345}, "input": {"stdin": "hello\\n"}}'

# Send a signal (SIGTERM).
curl -X POST http://127.0.0.1:8080/api/v1/process/signal/send \\
-H "Content-Type: application/json" \\
-d '{"process": {"tag": "my-script"}, "signal": 15}'

# System metrics + instance process metrics
curl http://127.0.0.1:8080/api/v1/metrics
# Response: { data: { ts, cpuCount, cpuUsedPct, memTotalMib, memUsedMib, diskUsed, diskTotal, instances: [{ id, cwd, pid, rssMib, heapUsedMib, heapTotalMib, uptimeSeconds, ... }] } }

Session Management

# Get the session list of the current workspace.
curl http://127.0.0.1:8080/api/v1/sessions

# Get the session list of all workspaces.
curl http://127.0.0.1:8080/api/v1/sessions?cwd=*

# Get the session list of a specified working directory.
curl http://127.0.0.1:8080/api/v1/sessions?cwd=/path/to/workspace

# Get the session list of a specified project (filtered by compressed working directory name).
curl http://127.0.0.1:8080/api/v1/sessions?cwd=*&projectId=workspace-hash

# Rename a session.
curl -X POST http://127.0.0.1:8080/api/v1/sessions/SESSION_ID/rename \\
-H "Content-Type: application/json" \\
-d '{"name": "Performance optimization discussion"}'
Description of the cwd query parameter:
cwd Value
Description
Not passed
Returns sessions in the current workspace.
*
Returns sessions in all workspaces.
/path/to/workspace
Returns sessions in the specified working directory.

File Change Management (Internal)

# Get the file diff (the file must be tracked in a checkpoint).
curl -X POST http://127.0.0.1:8080/internal/file-changes/diff \\
-H "Content-Type: application/json" \\
-d '{"path": "/path/to/file.ts"}'
# Response: {"data": {"path": "/path/to/file.ts", "oldText": "...", "newText": "..."}}

# List rollback-able checkpoints.
curl -X POST http://127.0.0.1:8080/internal/file-changes/checkpoints \\
-H "Content-Type: application/json" \\
-d '{}'
# Response: {"data": {"checkpoints": [{"id": "xxx", "label": "...", "createdAt": 1234567890, "files": [...], "additions": 5, "deletions": 2}]}}

# Revert changes by file.
curl -X POST http://127.0.0.1:8080/internal/file-changes/revert \\
-H "Content-Type: application/json" \\
-d '{"paths": ["/path/to/file.ts"]}'
# Response: {"data": {"success": true, "revertedFiles": ["/path/to/file.ts"]}}

# Roll back to a specified checkpoint.
curl -X POST http://127.0.0.1:8080/internal/file-changes/revert \\
-H "Content-Type: application/json" \\
-d '{"checkpointId": "checkpoint-uuid", "scope": "CodeAndConversation"}'
# Possible values for scope: "Code" (revert files only), "Conversation" (revert conversations only), "CodeAndConversation" (revert both).

# Revert all changes (roll back to the earliest checkpoint).
curl -X POST http://127.0.0.1:8080/internal/file-changes/revert \\
-H "Content-Type: application/json" \\
-d '{}'

Plugin Management

# List installed plugins (each item includes the isBuiltIn boolean field, indicating whether it belongs to the built-in marketplace).
curl http://127.0.0.1:8080/api/v1/plugins

# List only user-installed plugins, filtering out those from the built-in marketplace.
curl "http://127.0.0.1:8080/api/v1/plugins?includeBuiltin=false"

# Install a plugin (in the "name@marketplace" format)
curl -X POST http://127.0.0.1:8080/api/v1/plugins \\
-H "Content-Type: application/json" \\
-d '{"plugin": "my-plugin@my-marketplace"}'

# Enable a plugin.
curl -X POST http://127.0.0.1:8080/api/v1/plugins/enable \\
-H "Content-Type: application/json" \\
-d '{"plugin": "my-plugin@my-marketplace"}'

# Disable a plugin.
curl -X POST http://127.0.0.1:8080/api/v1/plugins/disable \\
-H "Content-Type: application/json" \\
-d '{"plugin": "my-plugin@my-marketplace"}'

# Uninstall a plugin.
curl -X POST http://127.0.0.1:8080/api/v1/plugins/uninstall \\
-H "Content-Type: application/json" \\
-d '{"plugin": "my-plugin@my-marketplace"}'

# Update a plugin to the latest version (pass waitForApply=true to wait for the rebuild to take effect before returning).
curl -X POST http://127.0.0.1:8080/api/v1/plugins/update \\
-H "Content-Type: application/json" \\
-d '{"plugin": "my-plugin@my-marketplace"}'

# List the plugin marketplace (each item includes the isBuiltIn boolean field).
curl http://127.0.0.1:8080/api/v1/plugins/marketplaces

# List only user-added marketplaces, filtering out built-in ones.
curl "http://127.0.0.1:8080/api/v1/plugins/marketplaces?includeBuiltin=false"

# Add a plugin marketplace.
curl -X POST http://127.0.0.1:8080/api/v1/plugins/marketplaces \\
-H "Content-Type: application/json" \\
-d '{"source": "https://example.com/marketplace", "name": "my-marketplace"}'

# Add a plugin marketplace and enable automatic updates by default (equivalent to adding it and then calling marketplaces/auto-update once).
curl -X POST http://127.0.0.1:8080/api/v1/plugins/marketplaces \\
-H "Content-Type: application/json" \\
-d '{"source": "https://example.com/marketplace", "name": "my-marketplace", "autoUpdate": true}'

# Browse plugins in the marketplace.
curl -X POST http://127.0.0.1:8080/api/v1/plugins/marketplaces/browse \\
-H "Content-Type: application/json" \\
-d '{"marketplace": "my-marketplace"}'

# Update the marketplace (actually pull the latest content from the remote source).
curl -X POST http://127.0.0.1:8080/api/v1/plugins/marketplaces/update \\
-H "Content-Type: application/json" \\
-d '{"marketplace": "my-marketplace"}'

# Enable or disable automatic updates for the marketplace (after enabling, the backend periodically syncs and upgrades installed plugins).
curl -X POST http://127.0.0.1:8080/api/v1/plugins/marketplaces/auto-update \\
-H "Content-Type: application/json" \\
-d '{"marketplace": "my-marketplace", "autoUpdate": true}'

# Delete a plugin marketplace.
curl -X DELETE http://127.0.0.1:8080/api/v1/plugins/marketplaces/my-marketplace

Configuration Management

# List all configurations.
curl http://127.0.0.1:8080/api/v1/settings

# List configurations by scope.
curl "http://127.0.0.1:8080/api/v1/settings?scope=user"

# Get a single configuration.
curl http://127.0.0.1:8080/api/v1/settings/model

# Set a configuration value.
curl -X PUT http://127.0.0.1:8080/api/v1/settings/theme \\
-H "Content-Type: application/json" \\
-d '{"value": "dark"}'

# Append a value to an array configuration.
curl -X POST http://127.0.0.1:8080/api/v1/settings/permissions/items \\
-H "Content-Type: application/json" \\
-d '{"values": ["Allow: Read(**)"]}'

# Remove a value from an array configuration.
curl -X POST http://127.0.0.1:8080/api/v1/settings/permissions/remove \\
-H "Content-Type: application/json" \\
-d '{"values": ["Allow: Read(**)"]}'

Working Directory

Manage additional working directories so that the permission system allows file operations under these directories (equivalent to the /add-dir command).
# List the current additional working directories.
curl http://127.0.0.1:8080/api/v1/workspace-dirs

# Add a working directory.
curl -X POST http://127.0.0.1:8080/api/v1/workspace-dirs \\
-H "Content-Type: application/json" \\
-d '{"path": "/Users/me/other-project"}'

# Remove a working directory.
curl -X DELETE "http://127.0.0.1:8080/api/v1/workspace-dirs?path=/Users/me/other-project"

# Full synchronization (call after page refresh recovery).
curl -X PUT http://127.0.0.1:8080/api/v1/workspace-dirs/sync \\
-H "Content-Type: application/json" \\
-d '{"dirs": ["/Users/me/project-a", "/Users/me/project-b"]}'
Note:
Added directories are stored in the CLI scope (process memory) and become invalid after the instance is shut down.
Frontend data is persisted through the workspace storage of the Web UI and automatically synchronized to the backend after a page refresh.
After these directories are added, Agent tools (Read/Write/Glob/Grep/Bash) can access these directories without prompting.

Usage Statistics

# Obtain historical usage statistics (activity heatmap, model/tool usage rankings, consecutive active days, etc.).
curl http://127.0.0.1:8080/api/v1/stats

# Obtain real-time cost statistics for the current session.
curl http://127.0.0.1:8080/api/v1/stats/session

Tracing

# Obtain the trace list (paginated).
curl "http://127.0.0.1:8080/api/v1/traces?offset=0&limit=20"

# Filter by session ID.
curl "http://127.0.0.1:8080/api/v1/traces?session_id=SESSION_ID"

# Obtain trace details (including all spans).
curl http://127.0.0.1:8080/api/v1/traces/TRACE_ID

# Obtain traces from remote Workers.
curl "http://127.0.0.1:8080/api/v1/traces?worker_pid=12345"

# Clear all traces.
curl -X DELETE http://127.0.0.1:8080/api/v1/traces

Scheduled Task Management

# Obtain the scheduled task list.
curl "http://127.0.0.1:8080/api/v1/scheduled-tasks?sessionId=SESSION_ID"

# Create a scheduled task (runs every 5 minutes).
curl -X POST http://127.0.0.1:8080/api/v1/scheduled-tasks \\
-H "Content-Type: application/json" \\
-d '{"cron": "*/5 * * * *", "prompt": "Check build status", "sessionId": "SESSION_ID"}'

# Create a one-time task (every Monday at 9:00 AM).
curl -X POST http://127.0.0.1:8080/api/v1/scheduled-tasks \\
-H "Content-Type: application/json" \\
-d '{"cron": "0 9 * * 1", "prompt": "Generate weekly report", "recurring": false, "sessionId": "SESSION_ID"}'

# Create a persistent task (retained after restart).
curl -X POST http://127.0.0.1:8080/api/v1/scheduled-tasks \\
-H "Content-Type: application/json" \\
-d '{"cron": "0 0 * * *", "prompt": "Daily cleanup", "durable": true, "sessionId": "SESSION_ID"}'

# Delete a scheduled task.
curl -X DELETE "http://127.0.0.1:8080/api/v1/scheduled-tasks/TASK_ID?sessionId=SESSION_ID"

Error Codes

Error Code
HTTP Status
Description
AUTH_REQUIRED
401
Authentication required
AUTH_INVALID
401
Invalid authentication
AUTH_RATE_LIMITED
429
Too many login attempts
NOT_FOUND
404
The resource does not exist.
BAD_REQUEST
400
The request parameters were incorrect.
RATE_LIMITED
429
Request rate too high
INTERNAL_ERROR
500
Internal server error
SESSION_NOT_FOUND
404
The session does not exist.
SESSION_DELETE_CURRENT
400
The current session cannot be deleted.
TERMINAL_NOT_FOUND
404
PTY does not exist.
PROCESS_NOT_FOUND
404
Process does not exist.
PATH_REQUIRED
400
Missing path parameter
PATH_NOT_DIRECTORY
400
The path is not a directory.
INSUFFICIENT_STORAGE
507
Insufficient disk space
RUN_NOT_FOUND
404
Execution does not exist.
PLATFORM_UNSUPPORTED
400
Unsupported Webhook platform
SIGNATURE_INVALID
403
Signature verification failed.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback