agentlyleads docs
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:

  • EMAIL and TASK workflows can only use CREATED.
  • STATUS_CHANGED is for leads and REPLY_RECEIVED for contacts. STAGE_CHANGED, STALLED and TIME_IN_STAGE are for deals; the last two take triggerConfig.
  • SET_FIELD only sets status, to a value that record type has.
  • A tagId, a NOTIFY user ID and a sequenceId must 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.

  • conditions replaces the filters and keeps triggerConfig.
  • triggerConfig replaces the trigger settings and keeps the filters.
  • actions replaces 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.

On this page