Skip to main content

API

Use this page to inspect the WebSocket methods, events, and errors exposed by the engine.

The engine is driven through one API. The afe command line and, later, the web UI are its clients.

The protocol​

The API is JSON-RPC 2.0 over a WebSocket at /rpc. The handshake must carry Authorization: Bearer <token>, or a valid session cookie from the server's own Origin.

MethodParamsResult
flow.list—flows with their input Schema, the workspace they need, their projects and the current revision
flow.bpmnflow, revision?{xml}: the flow as BPMN 2.0 XML, with no layout
ticket.startflow, input, project?, revision?, traceparent?{ticket_id} as soon as it is accepted
ticket.rerunticket_id{ticket_id} of a new ticket on the same flow, input, project and revision
revision.getrevision_id{id, manifests}: the frozen configuration
ticket.resumeticket_id, answer? (action, comment?){ticket_id}
ticket.pause, ticket.cancelticket_idnull
ticket.getticket_idstate, round, revision, artifacts, totals, pending question, last error
ticket.liststate?tickets with their totals, and the pending question of the waiting ones
ticket.eventsticket_idthe ticket's events, in order
events.subscribeticket_id?{subscription}, then events.event notifications
events.unsubscribesubscriptiontrue or false
workers.status—queue metrics (waiting, claimed) and the live workers

Tickets run in the background. Their progress arrives as events.event notifications on the same connection. A late subscriber first gets the ticket's past events, then the live ones, with no duplicates.

Event kinds​

KindMeaning
ticket_startedThe ticket was accepted and the engine started it.
ticket_resumedA person answered, or the ticket was restarted.
ticket_recoveredA worker took over a ticket whose worker died.
ticket_cancelledThe ticket was cancelled.
ticket_doneThe flow reached END.
node_startedA node began an activation.
node_finishedA node finished an activation.
budget_alertA budget crossed an alert fraction or a limit; waits for a person.
loop_detectedThe same tool call repeated; waits for a person.
human_requestA human node asks a person.
human_responseA person answered a human node.
needs_humanA hand-over; the ticket stops for a person.
errorThe ticket failed; the payload carries state and error.

Errors​

Error codeMeaning
-32602Invalid params
-32001Unknown flow or ticket
-32002Invalid input; data.fields names the field that is wrong
-32003Action not offered
-32004The ticket is running, or closed
-32005Unknown revision
-32006The ticket has no revision (created before revisions existed)

See also​