The Replica API and Automations are the only sanctioned channels for programmatic use of Replicas. Scripting against the dashboard, automating the CLI, or driving interactive surfaces from headless browsers is prohibited under our Terms of Service.
Authentication
Organization admins can generate org API keys from Settings > API Keys. You can generate personal API keys from Account > API Keys. Include it as a Bearer token in requests:Org vs Personal API Keys
| Org API Key | Personal API Key | |
|---|---|---|
| Created by | Org admins | Any member |
| Workspace attribution | Replicas bot (no user) | Owning user |
| Can manage org automations | Yes | Yes |
| Can manage personal automations | No | Own automations only |
| Use case | CI/CD, shared integrations | Personal automations, user-attributed workspaces |
Quick Start
1. List Available Repositories
Before creating a replica, list the repositories available in your organization:2. Create a Replica
Thename field must not contain whitespace (e.g. fix-auth-bug, not fix auth bug).
coding_agent chooses the agent for the initial message. Valid values are claude, codex, cursor, and opencode. Cursor requires a Cursor API key in Coding Agents settings; Opencode requires an OpenRouter API key there.
Optional lifecycle_policy controls what happens when work is done:
default- workspace sleeps after inactivity and is deleted after 7 days asleep (default)delete_when_done- workspace is deleted when the agent finishes (useful for CI/CD)delete_after_inactivity- workspace is deleted after a period of inactivity
size picks the compute envelope and per-minute price for this replica:
size | Compute | Price |
|---|---|---|
small | 2 vCPU, 8 GB memory, 20 GB disk | $0.008 / min |
large | 4 vCPU, 16 GB memory, 32 GB disk | $0.016 / min |
size to keep the legacy behaviour: the workspace inherits your org’s sandbox tier (including any team-plan auto-bump) and is billed at the standard rate. Pick small to opt into the lower per-minute price for cheap, frequent jobs; pick large for memory or CPU-bound work. Mixed fleets bill correctly; each workspace charges at its own rate.
Optional config controls per-workspace behavior. API-created replicas default to capabilities.pr_followups: true, meaning Replicas will auto-reply to CI failures and review comments on matching PRs created or touched by that workspace; set it to false for a read-only replica. Set preferences.keep_open_on_pr_merge: true when that workspace should remain open after its tracked PR merges. See Automations: Pull request management for how this default flips for automation-created workspaces.
The replica boots asynchronously and the message is delivered once ready.
3. Send a Follow-up Message
4. Check Status
include=environment to get detailed environment info, or include=diffs for full git diffs.
The status response also includes lastChatMessage, a preview of the most recent input message across the workspace’s chats (its text, the agent that received it (claude, codex, cursor, or opencode), and a timestamp), so you can surface recent activity without fetching full chat history. Each chat object likewise exposes lastMessageText, the preview for that individual chat.
5. Delete a Replica
200 OK with { "success": true }. IDs that never existed or belong to another organization return 404.
6. Stream Events (SSE)
7. Webhook Callbacks (alternative to polling)
Passwebhook_url when creating a replica to receive status updates without polling:
webhook_url accepts either a bare URL string ("https://...") or an object { url, secret }.
The platform POSTs a JSON body for every event with these headers:
| Header | Description |
|---|---|
X-Replicas-Event | Event type, e.g. replica.turn_completed |
X-Replicas-Event-Id | Stable per-event ID. Reuse for idempotent processing. |
X-Replicas-Delivery | Unique delivery ID for this event delivery. Retry attempts reuse the same value. |
X-Replicas-Replica-Id | The replica’s workspace ID |
X-Replicas-Signature | sha256=<hex HMAC-SHA256(secret, raw body)> (only present when a secret is set) |
replica.ready: the workspace finished provisioning (or finished waking) and is reachable. Use this as the “your replica is ready” signal instead of pollingGET /v1/replica/:id.replica.turn_completed: the coding agent finished a turn. Payload includes per-repository branches and any newly opened PR URLs.replica.deleted: the workspace was deleted. Payload data is empty.replica.error: the workspace went into an unrecoverable terminal state. The replica is being soft-deleted; the payload includes the failure message.
replica.turn_completed body:
2xx within 10 seconds.
To verify the signature in Node:
Key Concepts
Environments
Workspaces are created from environments. Each environment can be bound to a repository or repository set and carries the runtime configuration for the workspace (variables, files, skills, MCPs, warm hooks). The full environment management surface is available via the API — see Environments API below.Chat Management
Each workspace can have multiple chat sessions with different coding agents:Queue Management
Messages queue automatically when the agent is busy. You can inspect, clear, reorder, and remove queued messages:Mode Flags
Setplan_mode, goal_mode, or fast_mode to enable mode-specific behavior. goal_mode is only available for Codex. Leading slash commands (/plan, /goal, /fast) are also accepted at the start of message; Replicas strips them from the sent message and combines them with these flags.
POST /v1/replica when creating a replica.
Thinking Level
Control how much reasoning the agent applies withthinking_level:
| Level | Claude | Codex | Cursor | Opencode | Description |
|---|---|---|---|---|---|
low | low | low | low | native variant when supported | Minimal thinking, fastest responses |
medium | medium | medium | medium | native variant when supported | Moderate reasoning depth |
high | high | high | high | native variant when supported | Deep reasoning |
max | max | xhigh | max | strongest native variant when supported | Maximum effort |
high, Codex = medium, Cursor = medium, Opencode = medium.
Opencode thinking levels use the selected model’s native variants when available; models without a matching variant use Opencode’s model default.
Also supported in POST /v1/replica when creating a replica.
Images
Attach images (screenshots, diagrams) to messages:Chat History
Read the message history for a chat (replaces the deprecated/read endpoint):
Hooks
View warm and start hook execution logs:Canvas
Read files the agent drops into the workspace Canvas (~/.replicas/canvas/). Supported kinds: markdown, html, image, video, audio, other. Per-item size is capped at 5MB; use replicas media upload for anything larger. When Workspace History is enabled, Canvas items remain available after the workspace sleeps.
List items:
{ filename, kind, sizeBytes }.
Get a single item:
markdown, html) return content (UTF-8 string). Binary kinds return base64. Items over the size cap return tooLarge: true with no payload.
Environments API
Environments are the primitive that ties together a repository binding plus the runtime configuration (variables, files, skills, MCPs, warm hooks) applied to every workspace created from them. See Environments for feature details. Every organization has a singleton Global environment that applies to every workspace. You can address it in any URL by passing the literal stringglobal instead of a UUID — there’s no need to look up its ID first.
List Environments
Get an Environment
Create an Environment
repository_id and repository_set_id are mutually exclusive; both can be omitted if you want an unbound environment.
Update an Environment
Delete an Environment
Variables
{environmentId} accepts global for the Global environment.
Files
Files are placed inside workspaces at the configured path. Max content size is 64 KB.PATCH / DELETE / GET shape as variables.
Skills
Skills come from skills.sh. Search the catalog, then enable a skill on a specific environment.Skill registries
Add GitHub repositories as skill registries so their skills install into workspaces at provisioning time.MCPs
transport may be stdio, http, or sse. PATCH and DELETE work on /v1/environments/{environmentId}/mcps/{id}.
Warm Hooks
Each environment has at most one active warm hook (a shell script that runs while pre-warming workspaces). The Global environment’s warm hook applies to every pool.POST /v1/environments, so this PUT is only needed to disable a pool or re-enable one that was previously turned off. Existing environments are unaffected.
There are three mutation endpoints: test-only (runs without persisting), save-only (persists and activates immediately without testing), and save-and-test (persists only if the test passes). The test and save-test endpoints spin up a real isolated sandbox and run your script there. The streaming endpoint (POST .../warm-hooks/save-test/stream) returns Server-Sent Events so the connection stays alive during long-running hooks — use it instead of the synchronous save-test endpoint to avoid gateway timeouts. Events include progress (status messages), output (captured stdout/stderr), and complete (final exit_code, timed_out, and the saved warm_hook record on success). The mode field can be "save_test" (default, persists on success) or "test_only".
Start Hooks
Each environment has at most one active start hook (a shell script that runs at workspace startup, before repository-level start hooks). The Global environment’s start hook applies to every workspace. See Start Hooks for feature details.{ test: { exit_code, output, timed_out } } once the hook finishes - use it from CLI tooling and short-lived clients. The streaming endpoint emits SSE events (progress, output, complete, error) and is recommended for long-running hooks to avoid gateway timeouts. The Global environment can be addressed as "global" in any URL, no UUID lookup required.
Automations API
Automations let you trigger replicas on a schedule or in response to GitHub or GitLab events. The full CRUD is available via the API. See Automations for feature details. Automations default toscope: "org". Set scope: "user" when creating an automation with a personal API key or JWT auth to make it personal to that user inside the current organization. Org API keys cannot read, edit, run, or delete personal automations.
List Automations
scope=user to list your personal automations, or scope=all to list org automations plus your personal automations.
Create an Automation
Create a cron-triggered automation that runs every weekday at 9am:high thinking:
environment_id.
Use "type": "gitlab" with events like "merge_request.opened" for GitLab project automations:
workspace_size picks the compute envelope (and per-minute price) for every workspace the automation fires off. Accepts small (2 vCPU, 8 GB, 20 GB; $0.008/min) or large (4 vCPU, 16 GB, 32 GB; $0.016/min). Defaults to small. The same field is accepted on PATCH /v1/automations/:id.
Personal automation runs create workspaces with the automation owner’s user_id, but the workspace source remains automation. They are billed as automation metered usage, not seat usage.
agent_provider, model, and thinking_level are all optional. Omit any of them to inherit the organization’s default agent and the agent’s own defaults. Valid agent_provider values are claude, codex, cursor, and opencode. model must be one of the models supported by the chosen provider (e.g. opus[1m], sonnet, haiku for Claude; gpt-5.5, gpt-5.4, gpt-5.4-mini, gpt-5.3-codex, gpt-5.2 for Codex; composer-2, composer-2.5 for Cursor; z-ai/glm-5.2, minimax/minimax-m3, xiaomi/mimo-v2.5-pro, moonshotai/kimi-k2.6:free for Opencode via OpenRouter). thinking_level is one of low, medium, high, max.
Optional debounce_seconds sets a per-automation debounce window (0-86400 seconds, where 0 or null disables debouncing). When greater than 0, bursty trigger events update one pending run and the latest payload fires after the automation stops receiving events for the configured window. Accepts integers or null. Defaults to null (disabled). The same field is accepted on PATCH /v1/automations/:id.
Get an Automation
Update an Automation
agent_provider, model, and thinking_level are also patchable. Send null for any field to clear the override and fall back to the default. Note that changing agent_provider without also providing a new model clears the stored model, since the previous model may not be valid for the new provider.
Delete an Automation
Manually Trigger an Automation
Only works for automations with a cron trigger:List Execution History
Workspace Lifecycle
| Status | Description |
|---|---|
preparing | Workspace is being created and initialized |
active | Workspace is running and ready for messages |
sleeping | Workspace is paused (auto-wakes on interaction) |
error | Terminal state: the underlying sandbox died unrecoverably (e.g. OOM during a heavy build). The workspace cannot be woken or messaged. See the workspaces overview for next steps. |
waking: true. When a warm pool is configured for the target repository or repository set, expect setup times under 10 seconds. Otherwise, expect 10-60 seconds depending on repository size.
POST /v1/replica/{id}/wake and the engine-proxy endpoints (messages, chats, history, canvas, logs, previews, events) return 409 Conflict when the workspace is in sleeping or error, so clients can branch on that status instead of retrying indefinitely. To distinguish the recoverable (sleeping, can wake) and terminal (error) cases, read the workspace’s status field from GET /v1/replica/:id rather than parsing the 409 body.
API Versioning
POST /v1/replica supports an optional dated version header:
| Header value | Behavior |
|---|---|
| (omitted) | Legacy. Request blocks until the workspace reaches active, then returns. Engine details are populated in the response. |
2026-05-17 | Fire-and-forget. Request returns immediately with a preparing workspace. The initial message is still delivered to the agent in the background; poll GET /v1/replica/:id or stream GET /v1/replica/:id/events to follow progress. |
Prerequisites
Before using the API:- Add your repository in the dashboard
- Configure credentials for your coding agent
Use Cases
- CI/CD Integration - Trigger replicas from GitHub Actions or other pipelines
- Batch Operations - Create multiple replicas for parallel task execution
- Custom Workflows - Build internal tools that leverage AI coding agents
- Monitoring - Stream events and poll workspace state for dashboards