Flows API
Creating a Flow through the API follows the same structure as the visual editor: create the Flow, add nodes, then connect them with transitions.
The examples below assume the BASE_URL and HEADERS client from API authentication. Creating flows requires an Editor role.
Create a Flow and node
flow_id = requests.post(
f"{BASE_URL}/flow/create",
json={"name": "Sample Flow", "description": "Created through the API"},
headers=HEADERS,
).json()
http_config = {
"url": "https://httpbin.org/ip",
"http_method": "get",
"auth_type": "no-auth",
"body_type": "json",
"data": {},
"headers": {},
"params": {},
"request_timeout": 3600,
}
node_id = requests.post(
f"{BASE_URL}/flow/{flow_id}/nodes/add",
params={"type": "HTTP Request", "node-name": "lookup-ip"},
json=http_config,
headers=HEADERS,
).json()
POST /flow/{flow_id}/nodes/add uses the type query parameter and a node-specific JSON configuration. The API examples cover HTTP Request, Send Message, Voicemail Detection, DTMF IVR Input, Call Transfer, and Add to DNC nodes. Each node page documents the fields and the outcomes you can connect.
Connect nodes
Use POST /flow/{flow_id}/transitions/add with source and target node IDs. source_transition_type must be an event supported by the source node.
transition = {"source_id": starter_id, "target_id": node_id}
response = requests.post(
f"{BASE_URL}/flow/{flow_id}/transitions/add",
params={"source_transition_type": "incoming_message"},
json=transition,
headers=HEADERS,
)
response.raise_for_status()
Retrieve the completed setup with GET /flow/{flow_id}/flow-data before publishing or assigning it. Validate node configuration and every transition in a test Flow first.
Related
- API authentication: obtaining the token these calls need.
- API overview: shared client setup.
- Build flows · Flow nodes: the same objects in the editor.
- Flow revisions: publishing, which a Flow needs before it can be assigned.
- Flow sessions: verifying what a generated Flow actually did.