الانتقال إلى المحتوى الرئيسي
POST
/
workflows
إنشاء مسار عمل جديد
curl --request POST \
  --url https://api.altostrat.io/workflows \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "إعداد عميل جديد",
  "description": "يرسل بريدًا إلكترونيًا ترحيبيًا عند إنشاء موقع جديد.",
  "is_active": true,
  "authorization_id": "auth_01H...",
  "schedule_type": "manual",
  "nodes": [
    {
      "id": "n1",
      "type": "manual_trigger",
      "position": {
        "x": 100,
        "y": 100
      },
      "data": {
        "componentId": "manual_trigger",
        "description": "قم بتشغيل مسار الإعداد هذا يدويًا."
      }
    },
    {
      "id": "n2",
      "type": "webhook",
      "position": {
        "x": 400,
        "y": 100
      },
      "data": {
        "componentId": "webhook",
        "method": "POST",
        "url": "https://example.com/api/welcome",
        "body": "{\"message\": \"Welcome!\", \"run_id\": \"{{ n1.run_id }}\"}"
      }
    }
  ],
  "edges": [
    {
      "id": "e1-2",
      "source": "n1",
      "target": "n2"
    }
  ]
}'
{
  "id": "fl_01h3j4k5l6m7n8p9q0r1s2t3u4",
  "name": "إعداد العميل",
  "description": "يرسل بريدًا إلكترونيًا ترحيبيًا وينشئ حسابًا.",
  "nodes": [
    {
      "id": "n1",
      "type": "manual_trigger",
      "position": {
        "x": 150,
        "y": 250
      },
      "data": {
        "componentId": "manual_trigger"
      }
    }
  ],
  "edges": [
    {
      "id": "e1-2",
      "source": "n1",
      "target": "n2",
      "sourceHandle": "true"
    }
  ],
  "schedule_type": "manual",
  "schedule_value": "0 9 * * *",
  "next_run_at": "2025-11-01T09:00:00.000000Z",
  "is_active": true,
  "webhook_url": "https://api.altostrat.io/workflows/webhooks/whsec_abc123...",
  "created_at": "2025-10-31T12:00:00.000000Z",
  "updated_at": "2025-10-31T12:30:00.000000Z"
}

Authorizations

Authorization
string
header
required

رمز JWT قياسي لجلسات المستخدم التي يتم الحصول عليها عبر مصادقة Altostrat.

Body

application/json
name
string
required

اسم مسار العمل الجديد.

Example:

"فحص صحة الشبكة اليومي"

authorization_id
string
required

المعرف المسبوق بالبادئة للترخيص (auth_...) لاستخدامه في عمليات تنفيذ مسار العمل هذا.

Example:

"auth_01H..."

nodes
object[]
required

مصفوفة العقد التي تحدد منطق مسار العمل.

Minimum length: 1
edges
object[]
required

مصفوفة الحواف التي تربط عقد مسار العمل.

description
string | null

وصف اختياري لمسار العمل.

is_active
boolean
default:true

اضبط على false لإنشاء مسار العمل في حالة غير نشطة.

schedule_type
enum<string>
default:manual
الخيارات المتاحة:
manual,
interval,
cron,
daily,
weekly,
monthly
schedule_value
string | null

مطلوب إذا كان schedule_type هو interval أو cron.

Example:

"0 4 * * *"

Response

تم إنشاء مسار العمل بنجاح.

id
string

المعرف الفريد المسبوق بالبادئة لمسار العمل.

Example:

"fl_01h3j4k5l6m7n8p9q0r1s2t3u4"

name
string

الاسم القابل للقراءة لمسار العمل.

Example:

"إعداد العميل"

description
string | null

وصف مفصل لما يفعله مسار العمل.

Example:

"يرسل بريدًا إلكترونيًا ترحيبيًا وينشئ حسابًا."

nodes
object[]

مصفوفة من كائنات العقد التي تشكل الرسم البياني لمسار العمل. يتم إرجاعها فقط عند استرداد مسار عمل واحد.

edges
object[]

مصفوفة من كائنات الحواف التي تربط العقد في الرسم البياني لمسار العمل. يتم إرجاعها فقط عند استرداد مسار عمل واحد.

schedule_type
enum<string> | null

نوع الجدول الزمني الذي يشغل مسار العمل.

الخيارات المتاحة:
manual,
interval,
cron,
daily,
weekly,
monthly
Example:

"manual"

schedule_value
string | null

قيمة الجدول الزمني (على سبيل المثال، تعبير cron أو سلسلة زمنية مثل '5 minutes').

Example:

"0 9 * * *"

next_run_at
string<date-time> | null

الوقت المجدول التالي لتشغيل مسار العمل.

Example:

"2025-11-01T09:00:00.000000Z"

is_active
boolean

يشير إلى ما إذا كان مسار العمل نشطًا ويمكن تشغيله.

Example:

true

webhook_url
string<uri> | null

عنوان URL الفريد والآمن لتشغيل مسار العمل هذا إذا كان يستخدم مشغل webhook.

Example:

"https://api.altostrat.io/workflows/webhooks/whsec_abc123..."

created_at
string<date-time>

الطابع الزمني عند إنشاء مسار العمل.

Example:

"2025-10-31T12:00:00.000000Z"

updated_at
string<date-time>

الطابع الزمني عند آخر تحديث لمسار العمل.

Example:

"2025-10-31T12:30:00.000000Z"