Skip to main content

Endpoints

MethodPathDescription
GET/api/automations/rules/List automation rules
POST/api/automations/rules/Create a rule
GET/api/automations/rules/{id}/Get a rule
PATCH/api/automations/rules/{id}/Update a rule
DELETE/api/automations/rules/{id}/Delete a rule
POST/api/automations/rules/{id}/activate/Activate a rule
POST/api/automations/rules/{id}/deactivate/Deactivate a rule
GET/api/automations/rules/{id}/logs/List execution logs for a rule

List Rules

GET /api/automations/rules/
Authorization: Bearer <token>
Response:
{
  "count": 7,
  "results": [
    {
      "id": "rul_01HX...",
      "name": "New Lead Follow-Up",
      "trigger": "lead_created",
      "isActive": true,
      "stepCount": 4,
      "enrolledCount": 142,
      "createdAt": "2025-01-10T09:00:00Z",
      "updatedAt": "2025-03-01T11:00:00Z"
    }
  ]
}

Get a Rule

GET /api/automations/rules/{id}/
Authorization: Bearer <token>
Returns the full rule definition including trigger, conditions, and all steps. Response:
{
  "id": "rul_01HX...",
  "name": "New Lead Follow-Up",
  "trigger": "lead_created",
  "triggerConditions": [
    {
      "field": "source",
      "operator": "eq",
      "value": "website_form"
    }
  ],
  "exitConditions": [
    {
      "field": "status",
      "operator": "eq",
      "value": "converted"
    }
  ],
  "steps": [
    {
      "type": "send_email",
      "order": 1,
      "config": {
        "mode": "template",
        "templateId": "tmpl_01HX..."
      }
    },
    {
      "type": "wait",
      "order": 2,
      "config": {
        "duration": 3,
        "unit": "days"
      }
    },
    {
      "type": "create_task",
      "order": 3,
      "config": {
        "name": "Follow up with {{lead.firstName}}",
        "assignTo": "assigned_user",
        "dueDays": 1
      }
    }
  ],
  "isActive": true,
  "enrolledCount": 142,
  "createdAt": "2025-01-10T09:00:00Z"
}

Create a Rule

POST /api/automations/rules/
Authorization: Bearer <token>
Content-Type: application/json
Request body:
{
  "name": "Qualified Lead Fast-Track",
  "trigger": "lead_status_changed",
  "triggerConditions": [
    { "field": "status", "operator": "eq", "value": "qualified" }
  ],
  "exitConditions": [],
  "steps": [
    {
      "type": "assign_user",
      "order": 1,
      "config": {
        "mode": "round_robin",
        "userIds": ["usr_01HX...", "usr_02HX...", "usr_03HX..."]
      }
    },
    {
      "type": "send_notification",
      "order": 2,
      "config": {
        "recipients": ["assigned_user"],
        "message": "New qualified lead assigned: {{lead.firstName}} {{lead.lastName}}"
      }
    }
  ]
}
The rule is created in inactive state. Call the activate endpoint to start it. Response: 201 Created with the full rule object.

Activate / Deactivate a Rule

POST /api/automations/rules/{id}/activate/
Authorization: Bearer <token>
POST /api/automations/rules/{id}/deactivate/
Authorization: Bearer <token>
Both return 200 OK with the updated rule object.

Get Execution Logs

GET /api/automations/rules/{id}/logs/
Authorization: Bearer <token>
Query Parameters:
ParameterTypeDescription
pageintegerPage number
statusstringcompleted, failed, cancelled, in_progress
afterISO8601Logs after this date
Response:
{
  "count": 58,
  "results": [
    {
      "id": "log_01HX...",
      "enrolledRecordType": "lead",
      "enrolledRecordId": "ld_01HX...",
      "status": "completed",
      "completedSteps": 3,
      "totalSteps": 3,
      "startedAt": "2025-03-20T08:00:00Z",
      "completedAt": "2025-03-23T08:01:00Z"
    }
  ]
}