Workflows API
Start a run
POST /api/workflows/run answers 202 at once; the run carries on on the server.
Run a released workflow:
{ "workflowId": "…", "useRelease": true, "inputs": { "jobTitle": "Data Engineer", "headcount": 1 } }Or send a graph:
{ "agentType": "hiring", "nodes": [ … ], "edges": [ … ], "inputs": { … }, "simulate": false }| Field | Meaning |
|---|---|
workflowId | A saved workflow |
useRelease | Run its approved release. 409 if it has never been released |
rehearsal | Rehearse the saved version: side effects are recorded instead of done. Cannot be combined with simulate |
agentType, nodes, edges | A graph to run, at most 200 nodes. Not used with useRelease or rehearsal |
inputs | The run-form fields, by key |
simulate | Sample results without a model |
{ "success": true, "correlationId": "wf_…", "status": "running" }The run is queued and a worker picks it up, usually at once. Until then GET /api/workflows/runs/{correlationId} shows it as running with stage: "queued".
Retrying safely: Idempotency-Key
Send an Idempotency-Key header (1 to 255 characters) to make a retry safe. A second request with the same key from the same account within 24 hours starts nothing; it answers 202 with the first request's correlationId, that run's current status, and "idempotentReplay": true. The key is matched on its own: a repeat with a different body still returns the first run. A key over 255 characters is refused with 400. After 24 hours the key starts a new run.
curl -X POST https://changents.ai/api/workflows/run \
-H "Authorization: Bearer $TOKEN" \
-H "Idempotency-Key: invoice-INV-1042" \
-H "Content-Type: application/json" \
-d '{ "workflowId": "…", "useRelease": true, "inputs": { … } }'If the server restarts during a run
Every finished step is saved as the run goes. If the process running it stops (a deploy, a crash), the run is picked up again within about two minutes and carries on from the last finished step; steps that already finished are not run, or counted, again. The step that was running when it stopped runs again from the start. A run that is interrupted three times is marked failed, with the reason in degraded[].
Read runs
GET /api/workflows/runs?limit=…: recent runs for you and your organisation.GET /api/workflows/runs/{correlationId}:{ "success": true, "run": { … } }.
run field | Meaning |
|---|---|
status | running, awaiting_approval, completed, partial, failed, cancelled |
nodes[] | nodeId, nodeTitle, nodeType, status, result, error, approvalId, startedAt, finishedAt, durationMs, attempts |
finalResult | The composed result |
degraded[] | Steps that did not finish, and why |
inputs, agentType, workflowId, releaseVersion, rehearsal, simulated, startedAt, finishedAt, durationMs |
A step's status is pending, running, completed, failed, skipped or awaiting_approval.
Approvals
| Method | Path | Body / query |
|---|---|---|
| GET | /api/workflows/approvals | optional agentType, workflowId |
| GET | /api/workflows/approvals/{approvalId} | |
| POST | /api/workflows/approval/{actionId} | { "decision": "approved" | "rejected", "reason": "…" } |
The decision is recorded against the caller. Approving resumes the run from that step; rejecting records the step as rejected, and the steps that depended on it do not run.
Schedules
With a signed-in session token (not an API key):
| Method | Path | Body |
|---|---|---|
| GET | /api/schedules | |
| POST | /api/schedules | workflowId, cronExpression (required), name, timezone (default UTC), inputs |
| PATCH | /api/schedules/{id}/pause | |
| PATCH | /api/schedules/{id}/resume | |
| DELETE | /api/schedules/{id} |
cronExpression has five fields, or six. A schedule runs the workflow's approved release, or its saved version if it has never been released. Creating or changing schedules needs the editor role or above in an organisation.