Skip to main content

Worked flows samples

The endpoint list below documents each operation’s parameters; this overlay walks the chain a runner actually executes, in order, with the exact envelopes you branch on: create the draft → publish → execute → poll the execution → inspect node results, plus the two error shapes to handle. Every request uses your API key (X-API-Key) against https://api.orbit.devotel.io. Links on this page are relative to it; the examples below tab cURL and Node.js (TypeScript). See the recipes guide for templated use cases — welcome series, appointment reminders, support triage, surveys, and order updates with copy-ready definitions. This overlay stays at envelope level: what you send per operation, and what comes back.

1. Create the flow draft

POST /api/v1/flows creates the flow as a draft at version: 1. The definition graph carries nodes (each with an id and type) and edges (source → target between node ids). trigger_type is one of manual, webhook, schedule, event, or workflow; a schedule trigger also needs a 5-field cron_expr and optionally an IANA cron_tz (UTC otherwise) — a missing or unparseable expression is rejected with a 422 (see Errors).
201
Nothing runs while the flow is a draft. Publishing freezes the current definition as an immutable version and returns the flow with its new status and version:
200

2. Execute and poll

POST /api/v1/flows/{id}/execute starts one run. trigger_data is merged into the execution’s trigger context, so a node template like {{order_total}} resolves at run time. The run is accepted asynchronously (202) with the new execution id — poll GET /api/v1/flows/executions/{id} for the outcome.
202
Poll the execution until data.status leaves running (waiting means a defer node is parked; terminal states are completed, completed_with_errors, failed, timeout). The response carries the normalized per-node step trace — each step’s name, mapped status, and duration_ms — so you can see exactly which node a run stopped on:
200
When the fan-out you want is a contact or a list rather than raw context, use POST /api/v1/flows/{id}/start below — it merges your context the same way but also records which subject was enrolled.

3. Errors

Errors follow the { error, meta } envelope; quote meta.request_id when reporting a failure. 422 — invalid node graph or schedule. The create call below declares a schedule trigger with no cron_expr (the same 422 fires for an unparseable expression, or a graph whose edges reference a node id that doesn’t exist):
422
404 — unknown execution id. Polling an execution id your tenant doesn’t have (a typo, or an id from a different environment) returns 404 in the same envelope:
404