API

Guides

Messages

Voice

WhatsApp Business

Groups

Contacts

Outbox

Account

Sender IDs

Teammate/Subaccount

Conversations

Workflows

Message Templates

Birthday Message

Opt-out

Other

Webhooks (v2)

Workflows

A workflow is an automation you build in the workflow builder of your panel. It starts with one trigger (an inbound message, a delivery report, a schedule or a birthday), can branch on conditions and performs actions: send an SMS or WhatsApp message, call a webhook, edit the contact, opt out, wait, assign the conversation to a team member. The /v1/flows endpoints work on the same workflows as the panel: a workflow created through the API shows up in the builder and the other way round.

The reference is split over a few pages: Definition (the workflow, node and edge objects), Triggers, Conditions and Actions (the settings of every node type), Executions (what a run reports) and Examples. The endpoints follow after that.

How a workflow is built

A definition is a small graph: a list of nodes and a list of edges that connect them. Every node has a type and a data.config object; the first key of that object says what the node does.

Node type Config key Role Outgoing handles
triggerNodetriggerTypeStarts the workflow and fills the payload. Exactly one per published workflow.out
conditionNodeconditionTypeTests the payload and picks a branch.true, false
actionNodeactionTypeDoes something: send, edit a contact, call a webhook, wait, assign a conversation, ...out (send_whatsapp_message also fallback)

The smallest useful workflow: opt the sender out when an inbound message contains STOP.

{
	"name": "STOP = opt out",
	"nodes": [
		{ "id": "trigger", "type": "triggerNode",
		  "data": { "config": { "triggerType": "inbound_message", "inboxId": 0 } } },
		{ "id": "is_stop", "type": "conditionNode",
		  "data": { "title": "Says STOP?", "config": { "conditionType": "if", "field": "message.body", "operator": "contains", "value": "STOP" } } },
		{ "id": "opt_out", "type": "actionNode",
		  "data": { "title": "Opt out", "config": { "actionType": "opt_out", "editMethod": "opt_out" } } }
	],
	"edges": [
		{ "id": "e1", "source": "trigger", "sourceHandle": "out", "target": "is_stop" },
		{ "id": "e2", "source": "is_stop", "sourceHandle": "true", "target": "opt_out" }
	]
}

When the trigger fires, the engine builds a payload (the message, the contact, ...) and walks the graph from the trigger node: a condition evaluates the payload and the engine follows every edge that leaves the matching handle; an action runs and the engine follows its out edges. Actions such as get_contact add data to the payload for the nodes that follow, and text fields can use {{ placeholders }} from the payload (see Triggers).

Draft and published versions

A workflow has a status: draft (never published), active (published and running on its trigger) or inactive (unpublished). Every change is kept as a version:

Operation Effect on the versions
CreateMakes the workflow and version 1, both in draft.
UpdateWrites the editable draft. When the workflow is published and has no draft yet, a new draft is created next to the published version. The published version keeps running while you edit the draft; the status of the workflow does not change.
PublishValidates the draft with the publish rules (see Definition), archives the previously published version, marks the draft as published and sets the status to active. Publishing a workflow that has no draft only sets the status back to active.
UnpublishSets the status to inactive; the versions are untouched.
DeleteRemoves the workflow, its versions and its executions.

Get workflow, Test workflow and Run workflow use the builder version: the draft when there is one, otherwise the published version. The trigger itself only ever runs the published version. Every workflow response tells you which version you are looking at with version_number and version_status (draft, published or archived), next to published_version_number, draft_version_number, has_draft_changes and published_at.

Permissions

Workflow automations have to be enabled on your account; otherwise every endpoint returns http status 403 with error 166. Team users need API access and the Allow workflows permission (403 / error 1403 otherwise); Run workflow additionally needs the permission to send messages, because a run really executes the actions.

Errors

Http status Error When
404163Unknown workflow, or a workflow of another account
400164Invalid nodes or edges; error_info lists every problem as { path, message }
400165The draft cannot be published (trigger, reachability, cron minimum); error_info as above
403166Workflow automations are not enabled on the account
404167Unknown execution, or an execution of another workflow
400168The account already has 100 workflows
400139Body or query errors: missing name, nodes without edges, an unknown status or trigger_type filter, an unknown contact_id, a public ID of the wrong type in the URL
400135 / 136Invalid limit (1 to 100 for the workflow endpoints) or page
4031403Team user without API access or without the workflows permission (or without the permission to send messages, for Run workflow)

SMS API

Smstools
Integrate our SMS Gateway by implementing our SMS API, and add text messaging to your platform in minutes. Free trial. SMS API
5 out of 5 based on 3302 user ratings.
SMSGATEWAYAPI API1

REGISTER NOW

Discover our SMS platform today!

REGISTER