Replicas Replica API
Manage replicas (workspaces) for AI agents
Manage replicas (workspaces) for AI agents
openapi: 3.1.0
info:
title: Analytics Replica API
version: 2.0.0
description: The Replica API allows you to programmatically manage cloud workspaces for AI agents. Use this API to manage environments (the org-scoped primitive workspaces are created from — including variables, files, skills, MCPs, warm hooks, start hooks, and warm pools), create and manage replicas, send messages, manage chats, stream events, read connected repositories and repository sets, and configure automations.
servers:
- url: https://api.tryreplicas.com
description: Production API
security:
- apiKey: []
tags:
- name: Replica
description: Manage replicas (workspaces) for AI agents
paths:
/v1/replica:
post:
operationId: createReplica
summary: Create Replica
description: Creates a new replica in your organization and sends an initial message to the coding agent. The workspace and agent are initialized asynchronously.
tags:
- Replica
parameters:
- name: X-Replicas-Api-Version
in: header
description: Optional dated API version. When omitted, the request blocks until the workspace reaches `active` and the response includes the populated engine details (legacy behavior). When set to `2026-05-17`, the request returns immediately with a `preparing` workspace; the initial message is still delivered to the agent in the background. See the [API Versioning](/features/api#api-versioning) section for details.
required: false
schema:
type: string
enum:
- '2026-05-17'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateReplicaRequest'
responses:
'201':
description: Replica created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/CreateReplicaResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
description: Repository or repository set not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'409':
$ref: '#/components/responses/Conflict'
'500':
$ref: '#/components/responses/InternalServerError'
'503':
$ref: '#/components/responses/ServiceUnavailable'
get:
operationId: listReplicas
summary: List Replicas
description: Returns a paginated list of all replicas in your organization. Supports filtering by user, source, and status. For this API endpoint, results are ordered by newest `created_at` first, except `status=archived` results are ordered by most recent activity (`last_activity_at`, falling back to `created_at`).
tags:
- Replica
parameters:
- name: page
in: query
description: Page number for pagination
required: false
schema:
type: integer
default: 1
minimum: 1
- name: limit
in: query
description: Number of items per page
required: false
schema:
type: integer
default: 10
minimum: 1
maximum: 100
- name: user_id
in: query
description: Filter replicas by the user who created them
required: false
schema:
type: string
- name: source
in: query
description: Filter replicas by creation source
required: false
schema:
type: string
enum:
- api
- dashboard
- slack
- linear
- github
- gitlab
- automation
- name: status
in: query
description: Filter replicas by status
required: false
schema:
type: string
enum:
- active
- sleeping
- archived
- preparing
- error
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/ListReplicasResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/replica/{id}:
get:
operationId: getReplica
summary: Get Replica
description: 'Returns detailed information about a specific replica by its ID. Use the `include` query parameter to request additional data such as environment configuration and diffs. If the workspace is sleeping or archived, it will be woken and the response will indicate this with `waking: true`.'
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
- name: include
in: query
description: Comma-separated list of additional fields to include in the response
required: false
schema:
type: string
example: environment,diffs
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/GetReplicaResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
'502':
$ref: '#/components/responses/BadGateway'
delete:
operationId: deleteReplica
summary: Delete Replica
description: Deletes a replica by its ID. This terminates the underlying sandbox and processes any outstanding billing.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Replica deleted successfully
content:
application/json:
schema:
$ref: '#/components/schemas/DeleteReplicaResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/replica/{id}/messages:
post:
operationId: sendReplicaMessage
summary: Send Message
description: Sends a message to an existing replica. Supports targeting a specific chat, choosing a coding agent and model, attaching images, and enabling plan mode.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SendReplicaMessageRequest'
responses:
'200':
description: Message accepted
content:
application/json:
schema:
$ref: '#/components/schemas/SendReplicaMessageResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'500':
$ref: '#/components/responses/InternalServerError'
'502':
$ref: '#/components/responses/BadGateway'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/v1/replica/{id}/chats:
get:
operationId: listReplicaChats
summary: List Chats
description: Returns a list of chats for a replica.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
chats:
type: array
items:
$ref: '#/components/schemas/ReplicaChat'
waking:
type: boolean
description: If true, the workspace was sleeping or archived and is now waking up. Retry after 30-90 seconds.
required:
- chats
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
post:
operationId: createReplicaChat
summary: Create Chat
description: Creates a new chat session for a replica.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateChatRequest'
responses:
'201':
description: Chat created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/ReplicaChat'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/replica/{id}/chats/{chatId}:
delete:
operationId: deleteReplicaChat
summary: Delete Chat
description: Deletes a chat session from a replica.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
- name: chatId
in: path
description: The unique identifier of the chat
required: true
schema:
type: string
responses:
'200':
description: Chat deleted successfully
content:
application/json:
schema:
type: object
properties:
success:
type: boolean
required:
- success
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/replica/{id}/chats/{chatId}/slash-commands:
get:
operationId: listReplicaSlashCommands
summary: List Slash Commands
description: Returns built-in Replicas slash commands and agent-provided commands for a chat, including Claude, Codex ASP, Cursor, Opencode, and Pi commands.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
- name: chatId
in: path
description: The unique identifier of the chat
required: true
schema:
type: string
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/SlashCommandsResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'500':
$ref: '#/components/responses/InternalServerError'
'502':
$ref: '#/components/responses/BadGateway'
/v1/replica/{id}/chats/{chatId}/queue:
get:
operationId: getReplicaChatQueue
summary: Get Chat Queue
description: Returns queued messages for a chat. The currently processing message is not included.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
- name: chatId
in: path
description: The unique identifier of the chat
required: true
schema:
type: string
responses:
'200':
description: Queue retrieved successfully
content:
application/json:
schema:
$ref: '#/components/schemas/ChatQueueResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
delete:
operationId: clearReplicaChatQueue
summary: Clear Chat Queue
description: Removes all queued messages from a chat. The currently processing message is not interrupted.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
- name: chatId
in: path
description: The unique identifier of the chat
required: true
schema:
type: string
responses:
'200':
description: Queue cleared successfully
content:
application/json:
schema:
$ref: '#/components/schemas/QueueMutationResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/replica/{id}/chats/{chatId}/queue/{messageId}:
delete:
operationId: removeReplicaChatQueueMessage
summary: Remove Queued Message
description: Removes one queued message from a chat.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
- name: chatId
in: path
description: The unique identifier of the chat
required: true
schema:
type: string
- name: messageId
in: path
description: The unique identifier of the queued message
required: true
schema:
type: string
responses:
'200':
description: Queued message removed successfully
content:
application/json:
schema:
$ref: '#/components/schemas/QueueMutationResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/replica/{id}/chats/{chatId}/queue/reorder:
patch:
operationId: reorderReplicaChatQueue
summary: Reorder Chat Queue
description: Moves a queued message to a new zero-based position.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
- name: chatId
in: path
description: The unique identifier of the chat
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ReorderQueueRequest'
responses:
'200':
description: Queue reordered successfully
content:
application/json:
schema:
$ref: '#/components/schemas/QueueMutationResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/replica/{id}/history:
get:
operationId: readReplicaHistory
summary: Read History
description: 'Reads the conversation history for a replica with pagination from the end (bottom-up). Optionally filter by chat ID. If the workspace is sleeping or archived, it will be woken and the response will indicate this with `waking: true`. Retry in 30-90 seconds when waking.'
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
- name: chat_id
in: query
description: Filter history to a specific chat
required: false
schema:
type: string
- name: limit
in: query
description: Maximum number of events to return
required: false
schema:
type: integer
minimum: 1
- name: offset
in: query
description: Number of events to skip from the end
required: false
schema:
type: integer
default: 0
minimum: 0
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/ReadReplicaHistoryResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
'502':
$ref: '#/components/responses/BadGateway'
/v1/replica/{id}/hooks:
get:
operationId: getReplicaHooks
summary: Get Hook Logs
description: Returns the warm hook and start hook execution logs for a replica.
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/HooksResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
'502':
$ref: '#/components/responses/BadGateway'
/v1/replica/{id}/canvas:
get:
operationId: listReplicaCanvasItems
summary: List Canvas Items
description: 'Lists the items in the replica''s Canvas (files agents drop into `~/.replicas/canvas/`). Each item has a `kind` (markdown, html, image, video, audio, or other) inferred from its extension and a `sizeBytes` measured at list time. Files larger than 5 MB are still listed; the `getReplicaCanvasItem` endpoint will return `tooLarge: true` for them so callers know to fall back to `replicas media upload`.'
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/CanvasListResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
'502':
$ref: '#/components/responses/BadGateway'
/v1/replica/{id}/canvas/{filename}:
get:
operationId: getReplicaCanvasItem
summary: Get Canvas Item
description: 'Reads a single Canvas item by filename. Text kinds (`markdown`, `html`) return UTF-8 text in `content`. Binary kinds (`image`, `video`, `audio`, `other`) return base64 in `base64`. Items over the 5 MB per-file cap return `tooLarge: true` with neither payload; callers should reach for `replicas media upload` for those.'
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
- name: filename
in: path
description: The Canvas item filename, including extension (e.g. `example-plan.md`).
required: true
schema:
type: string
responses:
'200':
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/CanvasContentResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
'502':
$ref: '#/components/responses/BadGateway'
/v1/replica/{id}/events:
get:
operationId: streamReplicaEvents
summary: Stream Events
description: 'Opens a Server-Sent Events (SSE) stream for real-time events from a replica. The connection remains open and events are pushed as they occur.
Each event is delivered as an SSE message in the format `data: <JSON>\n\n`. A heartbeat ping is sent every 15 seconds to keep the connection alive. Clients should reconnect automatically on disconnect.
All events share a common envelope structure with `id` (unique event ID), `ts` (ISO 8601 timestamp), `type` (event type discriminator), and `payload` (type-specific data). See the `EngineEvent` schema for all possible event types.'
tags:
- Replica
parameters:
- name: id
in: path
description: The unique identifier of the replica
required: true
schema:
type: string
format: uuid
responses:
'200':
description: SSE event stream opened successfully. Each line is a JSON-encoded `EngineEvent`.
content:
text/event-stream:
schema:
$ref: '#/components/schemas/EngineEvent'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
'502':
$ref: '#/components/responses/BadGateway'
'503':
$ref: '#/components/responses/ServiceUnavailable'
/v1/workspaces/{workspaceId}/chats:
get:
operationId: listWorkspaceChats
summary: List Workspace Chats
description: Lists active, sleeping, and pending chats. Chats created while the workspace is preparing remain visible while startup completes.
tags:
- Replica
parameters:
- name: workspaceId
in: path
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Workspace chats
content:
application/json:
schema:
$ref: '#/components/schemas/WorkspaceChatListResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalServerError'
post:
operationId: createWorkspaceChat
summary: Create Workspace Chat
description: Creates a chat immediately. For preparing or sleeping workspaces, the chat stays visible and is created in the engine after startup completes. Archived and error workspaces return 409.
tags:
- Replica
parameters:
- name: workspaceId
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateChatRequest'
responses:
'201':
description: Chat accepted
content:
application/json:
schema:
$ref: '#/components/schemas/CreateWorkspaceChatResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/workspaces/{workspaceId}/chats/{chatId}/messages:
post:
operationId: sendWorkspaceChatMessage
summary: Send Workspace Chat Message
description: Accepts a message immediately. Messages sent while a workspace is preparing or sleeping are queued server-side and delivered in order after startup completes. Archived and error workspaces return 409.
tags:
- Replica
parameters:
- name: workspaceId
in: path
required: true
schema:
type: string
format: uuid
- name: chatId
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SendWorkspaceChatMessageRequest'
responses:
'200':
description: Message accepted by an active workspace
content:
application/json:
schema:
$ref: '#/components/schemas/SendWorkspaceChatMessageResponse'
'202':
description: Message queued while the workspace starts
content:
application/json:
schema:
$ref: '#/components/schemas/SendWorkspaceChatMessageResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/workspaces/{workspaceId}/messages/deferred:
post:
operationId: sendDeferredWorkspaceMessage
summary: Send Deferred Workspace Message
description: Creates or selects a chat, queues a message, and wakes a preparing or sleeping workspace. The queued message remains available while startup completes. Archived and error workspaces return 409.
tags:
- Replica
parameters:
- name: workspaceId
in: path
required: true
schema:
type: string
format: uuid
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SendDeferredWorkspaceMessageRequest'
responses:
'202':
description: Message queued and workspace waking
content:
application/json:
schema:
$ref: '#/components/schemas/SendDeferredWorkspaceMessageResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/workspaces/{workspaceId}/archive:
post:
operationId: archiveWorkspace
summary: Archive Workspace
description: Archives a workspace in the authenticated organization. Archived workspaces stay paused and can be woken later.
tags:
- Replica
parameters:
- name: workspaceId
in: path
description: Workspace UUID.
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Workspace archived
content:
application/json:
schema:
$ref: '#/components/schemas/ArchiveWorkspaceResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'500':
$ref: '#/components/responses/InternalServerError'
/v1/workspaces/{workspaceId}/sleep:
post:
operationId: sleepWorkspace
summary: Sleep Workspace
description: Forces an active workspace in the authenticated organization to sleep, stopping compute charges. Slept workspaces can be woken later. A no-op for already-sleeping or archived workspaces; returns 409 for preparing or error workspaces.
tags:
- Replica
parameters:
- name: workspaceId
in: path
description: Workspace UUID.
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Workspace slept
content:
application/json:
schema:
$ref: '#/components/schemas/SleepWorkspaceResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/Conflict'
'500':
$ref: '#/components/responses/InternalServerError'
components:
schemas:
HooksResponse:
type: object
description: Hook execution logs for a replica
properties:
warm_hooks:
type: object
properties:
logs:
type: array
items:
$ref: '#/components/schemas/WarmHookLogEntry'
required:
- logs
start_hooks:
type: object
properties:
logs:
type: array
items:
$ref: '#/components/schemas/StartHookLogEntry'
required:
- logs
required:
- warm_hooks
- start_hooks
CanvasItemKind:
type: string
enum:
- markdown
- html
- image
- video
- audio
- other
description: The kind of Canvas item, inferred from its file extension.
ClaudeAgentEvent:
type: object
description: A streaming event from the Claude Code agent. The `type` field is prefixed with `claude-` followed by the SDK message type.
properties:
timestamp:
type: string
format: date-time
description: When the event occurred
type:
type: string
enum:
- claude-assistant
- claude-user
- claude-result
- claude-system
description: Claude event type. `claude-assistant` contains model output (text, thinking, tool use). `claude-user` contains tool results. `claude-result` signals turn completion or errors. `claude-system` contains system-level messages.
payload:
$ref: '#/components/schemas/ClaudeEventPayload'
required:
- timestamp
- type
- payload
# --- truncated at 32 KB (105 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/replicas/refs/heads/main/openapi/replicas-replica-api-openapi.yml