# create()

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

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

Validiert die gesamte Definition und speichert sie. Alles, was überprüft werden kann, wird hier überprüft – wo Sie die Nachricht noch lesen.

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" },
  ],
});
```

## Was überprüft wird, bevor es gespeichert wird {#validated}

- Jeder Schritt id ist einzigartig und gut geformt; es gibt höchstens 30.
- Jeder Schritttyp existiert, und seine eigene erforderliche Konfiguration ist vorhanden.
- Jeder `{{steps.…}}`-Referenzname bezeichnet einen Schritt, der ** existiert und der vorgelagert ist **.
- Der Graph hat genau eine Kante vom Trigger, keinen Zyklus und keinen unerreichbaren Schritt.
- Eine Bedingung hat einen `true` und einen `false` Rand; ein Schalter hat einen pro Fall plus `default`; ein Zusammenführen hat mindestens zwei Eingänge.
- Alles, was außerhalb des Kontos handelt, hat eine `human` Schritt vorwärts.
- Ein `agent.run` nennt nur Werkzeuge, die existieren.

> **Eine baumelnde Vorlage ist die häufigste Ablehnung**
>
> {{steps.draft.output.text}} auf einem Schritt, der vor dem Draft läuft, wird hier gefangen anstatt einen leeren String zur Laufzeit zu erzeugen. Die Validierung ist streng, weil ein Workflow fehlschlägt, wo niemand zusieht.

## Agenten-Tools sind für Sie serialisiert {#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
} }
```

Als Objekt geschrieben wird es zum Array, das die Plattform speichert. Bereits als Array geschrieben, wird es so gesendet, wie es ist – und ein unbekannter Toolname wird mit der Liste der existierenden verweigert.

## Fehler {#errors}

Alles oben kommt zurück als `invalid_workflow` (400), mit einer Nachricht, die den Schritt und das Problem. Es gibt einen Code, weil es eine Antwort: beheben Sie die Definition.

- [Workflow-Definition](/de/sdk/workflows): Was eine Definition enthält und was abgelehnt wird.
- [Workflow-Schritte](/de/sdk/workflows/steps): Die 23 Typen.
- [runStep()](/de/sdk/ref/workflow/run-step): Einen Schritt vor dem Speichern der Kette versuchen.

```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"],
}}
```
