Automations
List automation templates, trigger automation runs, and cancel in-progress instances.
Automations allow you to define reusable workflow templates that execute business logic automatically. The API provides endpoints to list templates, trigger new runs, and cancel in-progress instances.
List Automation Templates
GET /v1/automationsReturns a paginated list of automation templates with execution statistics.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number |
limit | integer | 20 | Items per page (max 100) |
Example Request
curl -H "Authorization: Bearer lw_live_xxxx" \
"https://api.lend.works/v1/automations?limit=10"Example Response
{
"data": [
{
"id": "tmpl_a1b2c3d4-1234-5678-9abc-def012345678",
"type": "automation_template",
"attributes": {
"name": "New Lead Welcome Sequence",
"description": "Sends welcome email and assigns to advisor when a new lead is created",
"triggerType": "lead.created",
"isActive": true,
"stats": {
"totalRuns": 342,
"successCount": 338,
"failureCount": 4,
"lastRunAt": "2025-01-15T14:30:00Z"
},
"createdAt": "2024-09-01T10:00:00Z",
"updatedAt": "2025-01-10T08:00:00Z"
}
}
],
"meta": {
"total": 12,
"page": 1,
"limit": 10,
"hasMore": true,
"requestId": "a10b20c3-d4e5-4f67-8901-234567890abc"
}
}Trigger an Automation
POST /v1/automations/{id}/triggerManually trigger an automation template to create a new instance. This is useful for testing or one-off execution.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | UUID | Template ID to trigger |
Request Body (Optional)
| Field | Type | Description |
|---|---|---|
entityType | string | Type of entity to pass to the automation. Defaults to api_trigger |
entityId | string | ID of the entity. Defaults to the template ID |
Example Request
curl -X POST https://api.lend.works/v1/automations/tmpl_a1b2c3d4-1234-5678-9abc-def012345678/trigger \
-H "Authorization: Bearer lw_live_xxxx" \
-H "Content-Type: application/json" \
-d '{
"entityType": "lead",
"entityId": "d290f1ee-6c54-4b01-90e6-d701748f0851"
}'Response — 201 Created
{
"data": {
"id": "inst_f1e2d3c4-1234-5678-9abc-def012345678",
"type": "automation_instance",
"attributes": {
"templateId": "tmpl_a1b2c3d4-...",
"status": "running",
"entityType": "lead",
"entityId": "d290f1ee-...",
"startedAt": "2025-01-15T14:35:00Z",
"createdAt": "2025-01-15T14:35:00Z",
"updatedAt": "2025-01-15T14:35:00Z"
}
},
"meta": {
"requestId": "b21c31d4-e5f6-4a78-9012-345678901bcd"
}
}Cancel an Automation Instance
POST /v1/automations/{id}/cancelCancel a running automation instance. Only in-progress instances can be cancelled. Note: this takes an instance ID (returned from trigger), not a template ID.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | UUID | Instance ID (not template ID) |
Example Request
curl -X POST https://api.lend.works/v1/automations/inst_f1e2d3c4-1234-5678-9abc-def012345678/cancel \
-H "Authorization: Bearer lw_live_xxxx"Response — 200 OK
{
"data": {
"type": "cancel_result",
"attributes": {
"success": true
}
},
"meta": {
"requestId": "c32d42e5-f6a7-4b89-0123-456789012cde"
}
}Errors
| Status | Code | Description |
|---|---|---|
403 | FORBIDDEN | API key lacks permission |
404 | NOT_FOUND | Template or instance not found |
422 | VALIDATION_ERROR | Invalid trigger payload |