POST
/api/automation/workflows🔒 Bearer JWTBody
| الحقل | النوع | الوصف |
|---|---|---|
name* | string | اسم الـ workflow. |
description | string | وصف اختياري. |
triggerType* | enum | EVENT | CRON | WEBHOOK | KEYWORD | MANUAL | AGENT |
triggerConfig | object | يعتمد على triggerType (eventName / cronExpression / keywords / إلخ). |
nodes | array | عقد الـ DAG. كل عقدة {id, type, config, next?}. |
edges | any | اختياري — للـ visual builder. |
isActive | boolean | افتراضي false. فعّل بـ true لبدء الاستماع. |
domain | enum | GENERAL | WHATSAPP | PROJECTS | CLIENTS | AGENTS. |
tags | string[] | tags اختيارية للتنظيم. |
مثال طلب
curl -X POST https://operix.operixdigital.com/api/automation/workflows \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "ترحيب آلي",
"triggerType": "EVENT",
"triggerConfig": { "eventName": "client.created" },
"isActive": true,
"domain": "CLIENTS",
"nodes": [
{
"id": "send",
"type": "send_whatsapp",
"config": {
"phone": "{{triggerData.phone}}",
"text": "مرحباً {{triggerData.name}}!"
}
}
]
}'مثال استجابة
{
"id": "clx456def",
"name": "ترحيب آلي",
"triggerType": "EVENT",
"isActive": true,
"createdAt": "2026-05-27T10:15:00Z",
...
}سلوك خاص: CRON
لو
triggerType=CRON + triggerConfig.cronExpression صحيح + isActive=true، ينشأ WorkflowSchedule تلقائياً ويُسجَّل cron job في SchedulerRegistry.Errors
| الكود | الرسالة | السبب |
|---|---|---|
| 400 | name is required | حقول مطلوبة ناقصة. |
| 400 | triggerType is required | |
| 401 | Unauthorized |