Workflows API
Create, update and delete
These endpoints require the write:workflows scope (or *).
POST /api/v1/workflows
POST /api/v1/workflows HTTP/1.1
Host: agentlyleads.com
Authorization: Bearer alk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json
{
"name": "Round-robin web leads",
"entity": "LEAD",
"trigger": "CREATED",
"conditions": [{ "field": "source", "op": "contains", "value": "Web form" }],
"actions": [
{ "type": "ASSIGN_ROUND_ROBIN" },
{ "type": "CREATE_TASK", "title": "Call within a day", "dueInDays": 1, "assignToOwner": true }
]
}Returns 201 with { "workflow": { ... } }. New workflows are active unless you send "active": false.
Before saving, we check the workflow the same way the automation builder does, and a few things the builder's form enforces for you:
EMAILandTASKworkflows can only useCREATED.STATUS_CHANGEDis for leads andREPLY_RECEIVEDfor contacts.STAGE_CHANGED,STALLEDandTIME_IN_STAGEare for deals; the last two taketriggerConfig.SET_FIELDonly setsstatus, to a value that record type has.- A
tagId, aNOTIFYuser ID and asequenceIdmust exist in your workspace.
Anything that fails comes back as 400 with a message saying what to change. See Errors.
PATCH /api/v1/workflows/{id}
Send only what you want to change: name, active, conditions, actions, triggerConfig. entity and trigger can't change; create a new workflow instead.
conditionsreplaces the filters and keepstriggerConfig.triggerConfigreplaces the trigger settings and keeps the filters.actionsreplaces the whole list.
Pause a workflow:
{ "active": false }Returns 200 with the updated { "workflow": { ... } }.
DELETE /api/v1/workflows/{id}
Deletes the workflow and its run log. Tasks, tags and emails it already created stay.
{ "deleted": 1, "id": "cmq5wflo0alk34567890" }To stop a workflow without losing it, pause it instead.