Log in Create workspace
Skip to content

API reference

Operator - Commands

Dispatch session-authenticated commands to service agents and follow their lifecycle.

Jump to 4 endpoints
On this page

Overview

Agent commands are operator-created realtime work items targeted at one service agent. The REST record moves through queued, dispatched, accepted, running, succeeded, failed, cancelled, or timed_out while delivery and reports travel through the agent channel.

REST records, realtime delivery
POST creates the durable command, while the target consumes it over its authenticated socket topic. correlation_id connects application work, and result_payload or error_payload describes the terminal report.
Cancellation is cooperative
A cancellation request records cancel_requested_at and prevents work where possible, but an already accepted command may finish concurrently. Always re-read the command's final status.

Before you begin

  • A signed-in browser session with a selected workspace backed by an active membership is required; an archived workspace remains readable but rejects mutations. Every /api/v1/operator endpoint rejects API credentials and bearer tokens, regardless of their scopes.
  • Owners, admins, and members can create or cancel commands; auditors are read-only. The target service agent must belong to the current workspace.
  • The agent runtime needs a realtime connection with agent_commands:read to receive command events and agent_commands:write to acknowledge, report progress, complete, or fail them.

How it works

  1. Confirm the target

    Filter commands by service_agent_id and status, check recent failures, and ensure the intended agent is online before dispatching. Use a stable application command_type and a bounded JSON payload.

  2. Track to terminal state

    After dispatch, retain the command ID and correlation ID. Follow realtime updates or poll until succeeded, failed, cancelled, or timed_out, then inspect result_payload or error_payload instead of assuming delivery equals success.

Examples

These examples are illustrative. Replace the sample values with your own. Keep credentials in environment variables or a secret manager, never in client-side code.

List recent commands

The limit is capped at 100; this example reads the most recent 25 commands in the selected workspace.

javascript
const response = await fetch("/api/v1/operator/agent_commands?limit=25", {
  credentials: "same-origin",
  headers: {"Accept": "application/json"}
});
const body = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${body.detail}`);
console.log(body);
What to expect

200 OK with {"agent_commands": []} when no commands exist. Populated rows include service_agent, command_type, status, correlation_id, lifecycle timestamps, and terminal payloads.

Troubleshooting

A command stays queued
Check the service agent's availability and socket authentication. The REST create can succeed even when the agent is not currently connected, so inspect realtime and queue health next.
Create or cancel returns 403
Auditor memberships cannot operate commands, archived workspaces reject all mutations, and machine credentials never authenticate the operator route.

Endpoint reference

Ready to integrate? Open an endpoint for its required permissions, request fields, response format, and status codes. The examples above explain the workflow; these details define each individual request.

GET
/api/v1/operator/agent_commands Web Session

List agent commands

Description

Returns recent agent commands in the current workspace, optionally filtered by service agent or lifecycle status. Results are capped by limit (default 25, maximum 100).

Auth

Web Session
Parameters
Name In Type Required Description
service_agent_id query string No Filter by target service-agent UUID
status query string No Filter by command lifecycle status
limit query integer No Maximum commands to return (default 25, maximum 100)
Responses
200

Recent agent commands

Response Body
Field Type Required Description
agent_commands array<object> Yes Agent commands
agent_commands[].id string Yes Agent command UUID
agent_commands[].status string (queued, dispatched, accepted, running, succeeded, failed, cancelled, timed_out) Yes Current command lifecycle state
agent_commands[].payload object Yes Original command payload
agent_commands[].inserted_at datetime (ISO 8601) Yes Record insertion timestamp
agent_commands[].updated_at datetime (ISO 8601) Yes Record update timestamp
agent_commands[].completed_at datetime (ISO 8601) No Timestamp when the command reached a terminal state
agent_commands[].service_agent object No Target service agent summary
agent_commands[].service_agent.id string Yes Service agent UUID
agent_commands[].service_agent.name string Yes Service agent name
agent_commands[].service_agent.slug string Yes Service agent slug
agent_commands[].correlation_id string Yes Correlation identifier for idempotency and tracing
agent_commands[].accepted_at datetime (ISO 8601) No Timestamp when the agent accepted the command
agent_commands[].cancel_requested_at datetime (ISO 8601) No Timestamp when the operator requested cancellation
agent_commands[].command_type string Yes Application-defined command type
agent_commands[].created_by_user object No User who created the command
agent_commands[].created_by_user.id string Yes User UUID
agent_commands[].created_by_user.email string Yes User email address
agent_commands[].error_payload object Yes Agent-reported error payload
agent_commands[].lease_expires_at datetime (ISO 8601) No Dispatch lease expiry timestamp for unaccepted commands
agent_commands[].result_payload object Yes Agent-reported result payload
POST
/api/v1/operator/agent_commands Web Session

Create agent command

Description

Queues or dispatches a command for a target service agent. This endpoint is restricted to human operator sessions.

Auth

Web Session
Request Body
Field Type Required Description
agent_command object Yes Agent command attributes
agent_command.payload object No Opaque payload delivered to the agent
agent_command.service_agent_id string Yes Target service agent UUID
agent_command.correlation_id string No Optional caller-supplied tracing identifier; it does not deduplicate requests
agent_command.command_type string Yes Application-defined command type
Responses
201

Agent command created

Returns: AgentCommand

Response Body
Field Type Required Description
id string Yes Agent command UUID
status string (queued, dispatched, accepted, running, succeeded, failed, cancelled, timed_out) Yes Current command lifecycle state
payload object Yes Original command payload
inserted_at datetime (ISO 8601) Yes Record insertion timestamp
updated_at datetime (ISO 8601) Yes Record update timestamp
completed_at datetime (ISO 8601) No Timestamp when the command reached a terminal state
service_agent object No Target service agent summary
service_agent.id string Yes Service agent UUID
service_agent.name string Yes Service agent name
service_agent.slug string Yes Service agent slug
correlation_id string Yes Correlation identifier for idempotency and tracing
accepted_at datetime (ISO 8601) No Timestamp when the agent accepted the command
cancel_requested_at datetime (ISO 8601) No Timestamp when the operator requested cancellation
command_type string Yes Application-defined command type
created_by_user object No User who created the command
created_by_user.id string Yes User UUID
created_by_user.email string Yes User email address
error_payload object Yes Agent-reported error payload
lease_expires_at datetime (ISO 8601) No Dispatch lease expiry timestamp for unaccepted commands
result_payload object Yes Agent-reported result payload
Example
{
  "id": "116835e4-02f7-4f5f-b1a0-8e7d3010a3d2",
  "status": "queued",
  "payload": {
    "workflow_target_id": "2d8c8f18-c9fa-47b3-9725-3e0ec602b045"
  },
  "inserted_at": "2026-03-26T12:45:11Z",
  "updated_at": "2026-03-26T12:45:11Z",
  "completed_at": null,
  "service_agent": {
    "id": "a91720d1-1c45-4343-bb45-786e20432f04",
    "name": "Deploy Worker",
    "slug": "deploy-worker"
  },
  "correlation_id": "d6a37d6d-97c1-4aa2-bcee-6d91b3362fa8",
  "accepted_at": null,
  "cancel_requested_at": null,
  "command_type": "deploy.workflow",
  "created_by_user": {
    "id": "5bca08dd-cb95-4102-8efa-55a7a4e8611d",
    "email": "operator@example.com"
  },
  "error_payload": {},
  "lease_expires_at": null,
  "result_payload": {}
}
403

Service-agent credentials cannot create operator commands

404

Service agent not found

422

Validation error

GET
/api/v1/operator/agent_commands/:id Web Session

Get agent command details

Description

Returns the latest lifecycle state and payloads for a single agent command. This endpoint is restricted to human operator sessions.

Auth

Web Session
Parameters
Name In Type Required Description
id path string Yes Agent command UUID
Responses
200

Agent command details

Returns: AgentCommand

Response Body
Field Type Required Description
id string Yes Agent command UUID
status string (queued, dispatched, accepted, running, succeeded, failed, cancelled, timed_out) Yes Current command lifecycle state
payload object Yes Original command payload
inserted_at datetime (ISO 8601) Yes Record insertion timestamp
updated_at datetime (ISO 8601) Yes Record update timestamp
completed_at datetime (ISO 8601) No Timestamp when the command reached a terminal state
service_agent object No Target service agent summary
service_agent.id string Yes Service agent UUID
service_agent.name string Yes Service agent name
service_agent.slug string Yes Service agent slug
correlation_id string Yes Correlation identifier for idempotency and tracing
accepted_at datetime (ISO 8601) No Timestamp when the agent accepted the command
cancel_requested_at datetime (ISO 8601) No Timestamp when the operator requested cancellation
command_type string Yes Application-defined command type
created_by_user object No User who created the command
created_by_user.id string Yes User UUID
created_by_user.email string Yes User email address
error_payload object Yes Agent-reported error payload
lease_expires_at datetime (ISO 8601) No Dispatch lease expiry timestamp for unaccepted commands
result_payload object Yes Agent-reported result payload
403

Service-agent credentials cannot read operator commands

404

Agent command not found

POST
/api/v1/operator/agent_commands/:id/cancel Web Session

Cancel agent command

Description

Requests cancellation for a queued, dispatched, accepted, or running agent command. This endpoint is restricted to human operator sessions.

Auth

Web Session
Parameters
Name In Type Required Description
id path string Yes Agent command UUID
Responses
200

Agent command updated

Returns: AgentCommand

Response Body
Field Type Required Description
id string Yes Agent command UUID
status string (queued, dispatched, accepted, running, succeeded, failed, cancelled, timed_out) Yes Current command lifecycle state
payload object Yes Original command payload
inserted_at datetime (ISO 8601) Yes Record insertion timestamp
updated_at datetime (ISO 8601) Yes Record update timestamp
completed_at datetime (ISO 8601) No Timestamp when the command reached a terminal state
service_agent object No Target service agent summary
service_agent.id string Yes Service agent UUID
service_agent.name string Yes Service agent name
service_agent.slug string Yes Service agent slug
correlation_id string Yes Correlation identifier for idempotency and tracing
accepted_at datetime (ISO 8601) No Timestamp when the agent accepted the command
cancel_requested_at datetime (ISO 8601) No Timestamp when the operator requested cancellation
command_type string Yes Application-defined command type
created_by_user object No User who created the command
created_by_user.id string Yes User UUID
created_by_user.email string Yes User email address
error_payload object Yes Agent-reported error payload
lease_expires_at datetime (ISO 8601) No Dispatch lease expiry timestamp for unaccepted commands
result_payload object Yes Agent-reported result payload
403

Service-agent credentials cannot cancel operator commands

404

Agent command not found

Where to go next

see also