Workflow
Automation workflows: read, edit, enable/disable, run, trigger.api events. · 16 endpoints
- GET/workflows
- POST/workflows
- GET/workflows/node-types
- GET/workflows/{workflowId}
- PUT/workflows/{workflowId}
- PATCH/workflows/{workflowId}
- DELETE/workflows/{workflowId}
- POST/workflows/{workflowId}/clone
- POST/workflows/{workflowId}/run
- POST/workflows/{workflowId}/simulate
- POST/workflows/events/{eventName}
- GET/workflows/{workflowId}/runs
- DELETE/workflows/{workflowId}/runs
- GET/workflows/{workflowId}/webhook-url
- POST/workflows/{workflowId}/webhook-url/regenerate
- POST/accounts/{accountId}/workflows/clone
List workflows
GET
/api/v1/workflowsScope: workflow:readParameters
account_idquery · optional | string max 200 | Only workflows that apply to this account |
Example request
bash
curl "http://127.0.0.1:9900/api/v1/workflows" \
-H "Authorization: Bearer dpk_xxx"Create a workflow
POST
/api/v1/workflowsScope: workflow:writeRequest body (JSON)
namerequired | string max 200 | |
descriptionoptional | string max 2000 · default "" | |
enabledoptional | boolean default false | |
channeloptional | "zalo" | "facebook" | "telegram_user" | "telegram_bot" default "zalo" | |
account_idsoptional | string[] max 200 items · default [] | Accounts it applies to; empty = all accounts |
nodesrequired | object[] max 500 items | Nodes in the workflow editor's format (see GET /workflows/node-types) |
edgesrequired | object[] max 2000 items |
Example request
bash
curl -X POST "http://127.0.0.1:9900/api/v1/workflows" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"name":"string","nodes":[],"edges":[]}'Node catalog (like the editor's palette) and default configurations
GET
/api/v1/workflows/node-typesScope: workflow:readExample request
bash
curl "http://127.0.0.1:9900/api/v1/workflows/node-types" \
-H "Authorization: Bearer dpk_xxx"Get a workflow (with nodes, edges)
GET
/api/v1/workflows/{workflowId}Scope: workflow:readParameters
workflowIdpath · required | string max 200 |
Example request
bash
curl "http://127.0.0.1:9900/api/v1/workflows/{workflowId}" \
-H "Authorization: Bearer dpk_xxx"Overwrite a workflow (keeps its id and creation date)
PUT
/api/v1/workflows/{workflowId}Scope: workflow:writeParameters
workflowIdpath · required | string max 200 |
Request body (JSON)
namerequired | string max 200 | |
descriptionoptional | string max 2000 · default "" | |
enabledoptional | boolean default false | |
channeloptional | "zalo" | "facebook" | "telegram_user" | "telegram_bot" default "zalo" | |
account_idsoptional | string[] max 200 items · default [] | Accounts it applies to; empty = all accounts |
nodesrequired | object[] max 500 items | Nodes in the workflow editor's format (see GET /workflows/node-types) |
edgesrequired | object[] max 2000 items |
Example request
bash
curl -X PUT "http://127.0.0.1:9900/api/v1/workflows/{workflowId}" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"name":"string","nodes":[],"edges":[]}'Enable / disable a workflow
PATCH
/api/v1/workflows/{workflowId}Scope: workflow:writeParameters
workflowIdpath · required | string max 200 |
Request body (JSON)
enabledrequired | boolean |
Example request
bash
curl -X PATCH "http://127.0.0.1:9900/api/v1/workflows/{workflowId}" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"enabled":false}'Delete a workflow
DELETE
/api/v1/workflows/{workflowId}Scope: workflow:writeParameters
workflowIdpath · required | string max 200 |
Example request
bash
curl -X DELETE "http://127.0.0.1:9900/api/v1/workflows/{workflowId}" \
-H "Authorization: Bearer dpk_xxx"Duplicate a workflow to another account
POST
/api/v1/workflows/{workflowId}/cloneScope: workflow:writeParameters
workflowIdpath · required | string max 200 |
Request body (JSON)
target_account_idrequired | string max 200 |
Example request
bash
curl -X POST "http://127.0.0.1:9900/api/v1/workflows/{workflowId}/clone" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"target_account_id":"string"}'Run the workflow now with arbitrary trigger data (like the "Test run" button, "Chạy thử")
POST
/api/v1/workflows/{workflowId}/runScope: workflow:runParameters
workflowIdpath · required | string max 200 |
Request body (JSON)
trigger_dataoptional | object default {} |
Example request
bash
curl -X POST "http://127.0.0.1:9900/api/v1/workflows/{workflowId}/run" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"trigger_data":{}}'Simulated run (no real messages are sent)
POST
/api/v1/workflows/{workflowId}/simulateScope: workflow:runParameters
workflowIdpath · required | string max 200 |
Request body (JSON)
trigger_dataoptional | object default {} |
Example request
bash
curl -X POST "http://127.0.0.1:9900/api/v1/workflows/{workflowId}/simulate" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"trigger_data":{}}'Fire an event for workflows that have a "When called by API/plugin" node ("Khi API/plugin gọi", trigger.api)
POST
/api/v1/workflows/events/{eventName}Scope: workflow:runWorkflows matching the event name run asynchronously (like any trigger). Inside the workflow, use {{ $trigger.payload.<field> }}.
Parameters
eventNamepath · required | string max 100 |
Request body (JSON)
payloadoptional | object default {} | |
account_idoptional | string max 200 | Only run workflows that apply to this account |
Example request
bash
curl -X POST "http://127.0.0.1:9900/api/v1/workflows/events/{eventName}" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"payload":{"order_id":"DH2291","phone":"0901234567"}}'Example response
json
{
"success": true,
"data": {
"matched": 1,
"workflow_ids": [
"8c1f…"
]
},
"request_id": "3f0c0b6e-6d0a-4b8e-9d1a-1d2f3a4b5c6d"
}Recent run history
GET
/api/v1/workflows/{workflowId}/runsScope: workflow:readParameters
workflowIdpath · required | string max 200 | |
limitquery · optional | integer ≥ 1 · ≤ 200 · default 50 |
Example request
bash
curl "http://127.0.0.1:9900/api/v1/workflows/{workflowId}/runs" \
-H "Authorization: Bearer dpk_xxx"Clear the workflow's run history
DELETE
/api/v1/workflows/{workflowId}/runsScope: workflow:writeParameters
workflowIdpath · required | string max 200 |
Example request
bash
curl -X DELETE "http://127.0.0.1:9900/api/v1/workflows/{workflowId}/runs" \
-H "Authorization: Bearer dpk_xxx"Public webhook URL of the "External webhook" node ("Webhook bên ngoài")
GET
/api/v1/workflows/{workflowId}/webhook-urlScope: workflow:readParameters
workflowIdpath · required | string max 200 |
Example request
bash
curl "http://127.0.0.1:9900/api/v1/workflows/{workflowId}/webhook-url" \
-H "Authorization: Bearer dpk_xxx"Regenerate the webhook token (the old link stops working immediately)
POST
/api/v1/workflows/{workflowId}/webhook-url/regenerateScope: workflow:writeParameters
workflowIdpath · required | string max 200 |
Example request
bash
curl -X POST "http://127.0.0.1:9900/api/v1/workflows/{workflowId}/webhook-url/regenerate" \
-H "Authorization: Bearer dpk_xxx"Copy all of this account's workflows to another account
POST
/api/v1/accounts/{accountId}/workflows/cloneScope: workflow:writeSame as "Copy workflows to account" (Sao chép workflow sang tài khoản) in the app: the copies apply to the target account and keep their on/off state.
Parameters
accountIdpath · required | string max 200 |
Request body (JSON)
to_account_idrequired | string max 200 |
Example request
bash
curl -X POST "http://127.0.0.1:9900/api/v1/accounts/{accountId}/workflows/clone" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"to_account_id":"string"}'