Log in Create workspace
Skip to content

API reference

Replays

Re-run a recorded trace against its workflow target with controlled prompt, model, config, or context changes.

Jump to 2 endpoints
On this page

Overview

A replay creates a queued comparison job and a generated replay trace while preserving the source trace. It is useful for debugging and variant analysis, but it can repeat external behavior, so the source must be replayable and the selected target/context must be reviewed before scheduling.

Source and generated traces remain separate
The replay retains a reference to the original source trace and writes the new execution to a separate generated trace; replay itself does not overwrite the source. Overrides are merged into the chosen workflow configuration, while comparison, output, error, cost, and duration describe the new execution.
Machine replay access is write-only
This public surface creates and cancels replays but does not offer a machine GET replay endpoint. Observe progress over authorized realtime replay topics or through the operator observability UI/API rather than inventing a polling URL.
Cancellation is represented as failure
Stored statuses are queued, running, completed, or failed. Cancelling queued/running work returns a replay with status: failed and error_payload.code: cancelled; there is no stored cancelled replay status.

Before you begin

  • The command-line examples require curl and jq; any exception is identified in its introduction.
  • A source trace in the same workspace and a credential with replays:write.
  • Add traces:read only when the machine client will inspect the source first; following progress over the machine WebSocket instead requires sockets:connect and events:read. Operator observability is the alternative to both machine reads.
  • A workflow target supplied explicitly or already attached to the source trace.
  • Complete gateway context for connector replays, including any manual repair required for older traces.

How it works

  1. Inspect the source

    Inspect the trace in operator observability, or read it through the machine API with traces:read. Confirm it is replayable and identify its target, workflow version, input, and recorded connector context. Do not replay an external side effect casually.

  2. Submit a labelled variant

    POST the source trace_id and a meaningful variant_label; add only intentional prompt, model, raw config, workflow-version, or source-context overrides.

  3. Observe or cancel

    Save the replay and generated-trace IDs from HTTP 201. Subscribe to replay events or use operator observability; cancel only while queued/running and treat the returned failed/cancelled error payload as terminal.

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.

Queue a labelled prompt variant

The original source remains unchanged; the response identifies the generated trace used for comparison.

bash
export AGENTOPS_BASE_URL="https://robotscenter.net"
export AGENT_TOKEN="machine_token_with_replays_write"
export SOURCE_TRACE_ID="6646e3ff-8f2f-4204-ad5c-f4ebc1830f9e"

jq -n --arg trace "$SOURCE_TRACE_ID" \
  '{trace_id: $trace, variant_label: "concise-answer-v2", model_override: "gpt-4.1", prompt_override: "Answer accurately in no more than three sentences."}' |
  curl --fail-with-body --silent --show-error \
    -X POST -H 'content-type: application/json' \
    -H "Authorization: Bearer $AGENT_TOKEN" \
    --data-binary @- "$AGENTOPS_BASE_URL/api/v1/replays" | jq .
What to expect

HTTP 201 returns the replay directly, usually queued, with source and generated trace IDs, selected target/version, merged overrides, job ID, and comparison fields.

Troubleshooting

Creation returns 404
The source trace is absent from the credential's workspace. Trace IDs never cross workspace boundaries, even when the caller knows a valid UUID from elsewhere.
A replay cannot select a target
Supply workflow_target_id when the source trace did not record one. The target and any workflow version must belong to the same workspace.
Cancel returns cannot_cancel
Only queued or running replays can be cancelled. Completed, failed, and already-cancelled-as-failed records are terminal.
No machine polling route exists
Use operator observability, or mint a socket token from a credential carrying both sockets:connect and events:read before joining replay:{replay_id}. replays:write alone cannot join that topic. Do not poll a guessed GET /api/v1/replays/:id 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.

POST
/api/v1/replays API key / access token

Create a replay

replays:write

Description

Creates a replay from a trace for debugging and analysis, including optional variant labels and config overrides. Replay.status is queued | running | completed | failed. A replay of a recorded gateway action (execution_path gateway) additionally requires the gateway:execute scope for machine callers, who may only replay actions of their own service agent.

Auth

API key / access token

Required Scopes

replays:write
Request Body
Field Type Required Description
workflow_target_id string No Workflow target UUID. Falls back to source trace's target. Required if source trace has no workflow_target_id.
trace_id string No UUID of the trace to replay
workflow_version_id string No Optional workflow version override
config_overrides object No Raw workflow config overrides merged before replay execution
model_override string No Shortcut override merged into config_overrides.model
prompt_override string No Shortcut override merged into config_overrides.prompt
source_context_override object No Gateway replays only (stored as {} for HTTP-target replays). Keys connector_id/connector_slug, action, input_payload, service_agent_id only fill fields the source trace did not record; recorded values always win and the override key is ignored. From a session, only workspace owners/admins may supply it (other session roles receive 422 on source_context_override). Machine callers may supply it to fill gaps, but the replay must still run as their own service agent.
source_trace_id string No Alias for trace_id
variant_label string No Human-readable label for the replay variant
Responses
201

Replay created

Returns: Replay

Response Body
Field Type Required Description
id string Yes Replay UUID
status string (queued, running, completed, failed) Yes Stored status. Cancel never writes cancelled.
started_at datetime (ISO 8601) No When execution started
inserted_at datetime (ISO 8601) Yes Record insertion timestamp
updated_at datetime (ISO 8601) Yes Record update timestamp
job_id integer No Oban job id
error_payload object Yes Replay error payload. Cancel sets code to cancelled.
workflow_target_id string No Workflow target UUID
output_payload object Yes Replay output payload
duration_ms integer No Duration in milliseconds
last_activity_at datetime (ISO 8601) No Last recorded activity
total_cost string No Attributed replay cost, as a decimal string
workflow_version_id string No Workflow version UUID
config_overrides object Yes Merged config overrides
source_context_override object Yes Source context override used during replay
source_trace_id string Yes Source trace UUID
variant_label string No Replay variant label
comparison object Yes Source vs generated comparison
finished_at datetime (ISO 8601) No When execution finished
generated_trace_id string No Generated replay trace UUID
Example
{
  "comparison": {
    "changed": false
  },
  "config_overrides": {
    "model": "gpt-4.1"
  },
  "duration_ms": 1840,
  "error_payload": {},
  "finished_at": "2026-03-15T10:00:03Z",
  "generated_trace_id": "7c8d9e0f-1234-4abc-b567-890123456789",
  "id": "e5f6a7b8-9012-4cde-f345-678901234567",
  "inserted_at": "2026-03-15T10:00:00Z",
  "job_id": 18421,
  "last_activity_at": "2026-03-15T10:00:03Z",
  "output_payload": {
    "result": "ok"
  },
  "source_context_override": {},
  "source_trace_id": "6646e3ff-8f2f-4204-ad5c-f4ebc1830f9e",
  "started_at": "2026-03-15T10:00:01Z",
  "status": "completed",
  "total_cost": "0.0400",
  "updated_at": "2026-03-15T10:00:03Z",
  "variant_label": "prompt-v2",
  "workflow_target_id": "4ce4d170-e6d5-4118-8f4d-fac69dc099ea",
  "workflow_version_id": "d0b91d0c-0f4b-4a28-8d9d-ccf0c427d6e8"
}
401

Invalid or missing token

403

Missing replays:write, or missing gateway:execute for a gateway replay

404

Trace not found

422

Validation failed: the gateway replay's service agent is missing or not active, the source trace lacks connector/action, an override was sent by a non-admin session, or a machine credential tried to replay another service agent's action

POST
/api/v1/replays/:id/cancel API key / access token

Cancel a replay

replays:write

Description

Cancels a queued or running replay. Replay.status is only queued | running | completed | failed; cancel writes status failed with error_payload.code "cancelled". A cancelled status is never stored.

Auth

API key / access token

Required Scopes

replays:write
Parameters
Name In Type Required Description
id path string Yes Replay UUID
Responses
200

Replay cancelled. status is failed; error_payload.code is "cancelled".

Returns: Replay

Response Body
Field Type Required Description
id string Yes Replay UUID
status string (queued, running, completed, failed) Yes Stored status. Cancel never writes cancelled.
started_at datetime (ISO 8601) No When execution started
inserted_at datetime (ISO 8601) Yes Record insertion timestamp
updated_at datetime (ISO 8601) Yes Record update timestamp
job_id integer No Oban job id
error_payload object Yes Replay error payload. Cancel sets code to cancelled.
workflow_target_id string No Workflow target UUID
output_payload object Yes Replay output payload
duration_ms integer No Duration in milliseconds
last_activity_at datetime (ISO 8601) No Last recorded activity
total_cost string No Attributed replay cost, as a decimal string
workflow_version_id string No Workflow version UUID
config_overrides object Yes Merged config overrides
source_context_override object Yes Source context override used during replay
source_trace_id string Yes Source trace UUID
variant_label string No Replay variant label
comparison object Yes Source vs generated comparison
finished_at datetime (ISO 8601) No When execution finished
generated_trace_id string No Generated replay trace UUID
Example
{
  "comparison": {
    "error": "cancelled"
  },
  "config_overrides": {
    "model": "gpt-4.1"
  },
  "duration_ms": 1840,
  "error_payload": {
    "cancelled": true,
    "code": "cancelled",
    "reason": "User cancelled"
  },
  "finished_at": "2026-03-15T10:00:03Z",
  "generated_trace_id": null,
  "id": "e5f6a7b8-9012-4cde-f345-678901234567",
  "inserted_at": "2026-03-15T10:00:00Z",
  "job_id": 18421,
  "last_activity_at": "2026-03-15T10:00:03Z",
  "output_payload": {},
  "source_context_override": {},
  "source_trace_id": "6646e3ff-8f2f-4204-ad5c-f4ebc1830f9e",
  "started_at": "2026-03-15T10:00:01Z",
  "status": "failed",
  "total_cost": "0.0400",
  "updated_at": "2026-03-15T10:00:03Z",
  "variant_label": "prompt-v2",
  "workflow_target_id": "4ce4d170-e6d5-4118-8f4d-fac69dc099ea",
  "workflow_version_id": "d0b91d0c-0f4b-4a28-8d9d-ccf0c427d6e8"
}
400

cannot_cancel — the replay is not queued or running

401

Invalid or missing token

403

Missing required scope

404

Replay not found

Where to go next

see also