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
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.
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.
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.
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.