# create()

Canonical URL: https://developers.iagenify.com/ar/sdk/ref/workflows/create/
Language: ar

`api.workflows.create(definition) → Promise<Workflow>`

كل ما يمكن التحقق منه هو مؤكّد هنا -- حيث لا تزال تقرأ الرسالة.

Status: POST /api/workflows · validated on save · tools are serialised

```javascript
const workflow = await api.workflows.create({
  name: "Triage",
  trigger: { type: "manual" },
  steps: [
    { id: "classify", type: "model.generate", config: { model: "gemini-3.5-flash",
        prompt: "Is this urgent? {{input.text}}", schema: { type: "object", properties: { urgent: { type: "boolean" } } } } },
    { id: "check",    type: "condition", config: { left: "{{steps.classify.output.urgent}}", operator: "eq", right: true } },
    { id: "approve",  type: "human", config: { title: "Send the alert?" } },
    { id: "alert",    type: "mail.send", config: { box: "ops@example.com", to: "team@example.com",
        subject: "Urgent", text: "{{input.text}}" } },
    { id: "file",     type: "storage.write", config: { storage: "…", action: "insert", collection: "tickets",
        documents: [{ text: "{{input.text}}" }] } },
  ],
  edges: [
    { from: "__trigger", to: "classify" },
    { from: "classify", to: "check" },
    { from: "check", to: "approve", branch: "true" },
    { from: "check", to: "file",    branch: "false" },
    { from: "approve", to: "alert" },
  ],
});
```

## ما هو مُحَكَّر قبل هو مُنْ {#validated}

- كل خطوة هي فريدة وجيدة التشكيل، هناك في أكثرها 30.
- كل نوع خطوة موجود، والتشكيل المطلوب الخاص به موجود.
- كل `{{steps.…}}` أسماء المُراجع المرجعية **فيكون في مُنْج**.
- الرسم البياني له بالضبط حافة واحدة من الزناد، لا دورة، ولا خطوة غير قابلة للوصل.
- (أ) يكون الشرط `true` وأن تكون `false` ; a مُزِل له 1 لكل حالة زائد `default`(أ) المزلاج له مدخلان على الأقل.
- أيّ أيّ أيّ أيّ شيء يعمل خارج الحساب لديه `human` (ج) تُدرج في اتجاه أعلى.
- A `agent.run` اسماء فقط الأدوات الموجودة.

> **A قالب هو الأكثر رفضاً**
>
> {{steps.draft.output.textعلى خطوة تمر قبل أن يتم ضبط المشروع هنا بدلاً من إنتاج سلسلة فارغة في وقت التنفيذ. التحقق صارم لأن تدفق العمل يفشل حيث لا يراقب أحد.

## تمّ تهسل أدوات الوكيل لك {#tools}

```javascript
{ id: "research", type: "agent.run", config: {
    model: "gemini-3.5-flash",
    tools: { search: api.tools.search, fetch: api.tools.fetch },   // the SDK serialises this
} }
```

ككتابة كائن يصبح المصفوفة منصة تخزين. كتابة كمصفوفة ، يتم إرسالها كما هي - و اسم أداة مجهول مرفوض مع قائمة من موجود.

## الأخطاء {#errors}

كل شيء فوق كل شيء يعود كما `invalid_workflow` (400) مع رسالة تسمي الخطوة و المشكلة. هناك رمز واحد لأن هناك إجابة واحدة: أصلح التعريف.

- [تعريف سير العمل](/ar/sdk/workflows): ما يحمله التعريف، وما يرفضه.
- [خطوات سير العمل](/ar/sdk/workflows/steps): الأنواع الثلاثة والعشرون.
- [runStep()](/ar/sdk/ref/workflow/run-step): -يحاولون القيام بخطوة واحدة قبل إنقاذ السلسلة

```python
workflow = api.workflows.create({
    "name": "Triage",
    "trigger": {"type": "manual"},
    "steps": [
        {"id": "classify", "type": "model.generate", "config": {"model": "gemini-3.5-flash",
            "prompt": "Is this urgent? {{input.text}}",
            "schema": {"type": "object", "properties": {"urgent": {"type": "boolean"}}}}},
        {"id": "check", "type": "condition", "config": {"left": "{{steps.classify.output.urgent}}", "operator": "eq", "right": True}},
        {"id": "approve", "type": "human", "config": {"title": "Send the alert?"}},
        {"id": "alert", "type": "mail.send", "config": {"box": "ops@example.com", "to": "team@example.com",
            "subject": "Urgent", "text": "{{input.text}}"}},
        {"id": "file", "type": "storage.write", "config": {"storage": "…", "action": "insert", "collection": "tickets",
            "documents": [{"text": "{{input.text}}"}]}},
    ],
    "edges": [
        {"from": "__trigger", "to": "classify"},
        {"from": "classify", "to": "check"},
        {"from": "check", "to": "approve", "branch": "true"},
        {"from": "check", "to": "file", "branch": "false"},
        {"from": "approve", "to": "alert"},
    ],
})
```

```python
# In Python, an agent.run step names its built-in tools; the server runs them
{"id": "research", "type": "agent.run", "config": {
    "model": "gemini-3.5-flash",
    "tools": ["search", "fetch"],
}}
```
