VocalDocscontracts 1.65.0

Test a Workflow over scripted events

POST /v1/workflows/{workflow_id}/test

PropertyValue
Operationtest_workflow
GroupWorkflows
Scopeworkflows:write
Route classcontrol
IdempotencyIdempotency-Key accepted: a retry with the same key replays the first answer
AuditNot audited: A dry run: it changes no state and reads no Call content, so it writes no Audit event (ADR 0012, workflows-and-processes.md section 9.8).
Released in1.59.0
Phase 0 hostServed (the hosted api pins 1.65.0)

Compiles the draft, or a published version, and runs the interpreter over it (1.59.0): the start, then each scripted event (a node's completion with its outlet and output, a node's failure, a closed Turn or the Call's end), with each node a step evaluates evaluated by the engine. It answers each step's evaluations, value, effects, records and state hook dispatches, the nodes entered, the node it waits on and how the Call would end. A draft that does not compile is refused as a publish would be. It writes nothing: no Call, Call event, Audit event or Usage event.

Request

Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the workflows:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.

curl -X POST "$VOCAL_API/v1/workflows/wfl_.../test" \
  -H "Authorization: Bearer $VOCAL_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "events": []
  }'

Parameters

NameInTypeRequiredDescription
workflow_idpathWorkflowIdyesThe id of a Workflow: wfl_ and the row's UUIDv7 in 26 Crockford base32 characters. Opaque and safe to log.
idempotency-keyheaderstringnoA client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response.

Request body

Content type application/json, required: WorkflowTestRequest.

FieldTypeRequiredDescription
contextWorkflowTestContextInputno
eventsarray of WorkflowTestEventInputyesThe scripted events after the start, in order; empty to see the start alone.
slotsmap of anynoSlot values at the start, over the declared defaults.
versionWorkflowTestVersionno

Responses

StatusContent typeShapeError codes
200application/jsonWorkflowTestResult
400application/jsonErrorEnvelopeinvalid_request
401application/jsonErrorEnvelopeunauthenticated
403application/jsonErrorEnvelopeforbidden
404application/jsonErrorEnvelopenot_found
409application/jsonErrorEnvelopeidempotency_in_progress, idempotency_key_reused
422application/jsonErrorEnvelopevalidation_failed, capability_not_available
429application/jsonErrorEnveloperate_limited
500application/jsonErrorEnvelopeinternal_error

Fields of the 200 answer

The shape is WorkflowTestResult.

FieldTypeRequiredDescription
ended_reasonEndedReason or nullyesHow the Call would end: workflow_complete once a hangup or end node was entered, the reason of a scripted session.ended, or null while it runs.
finalMachineStateyes
object"workflow_test"yes
outputsobject or nullnoThe Workflow's declared outputs (1.60.0): the outputs expressions of the hangup or end node the run entered, evaluated over its value; null while it runs or when that node declares none. Content of the scripted values. Absent from an api before 1.60.0.
patharray of MachineIdyesEvery node the run entered or evaluated, in order.
stepsarray of WorkflowTestStepyesThe start, then one step per scripted event.
versioninteger or nullyesThe version run; null for the draft.
waiting_onMachineId or nullyesThe node whose completion the run waits for after the last event; null when it ended.
workflow_idWorkflowIdyes