api.workflows

create()

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

Valida la definizion completa e la salva. Tutto che puè essere verificat è verificat qui — in cui ancora si lee il messaggio.

POST /api/workflowsvalidated on savetools are serialised
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

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

Qua che è verificat prima di ser salvat

  • Ogni id passo è unico e ben format; non sono al may 30.
  • Ogni tipo di passo existe, e la sua configurazion esigente è presente.
  • Ogni reference {{steps.…}} nomeia un passo che existe e che è a monte.
  • Il grafo ha esattamente un bordo del trigger, senza ciclo, e non step inalcançabile.
  • Una condizione ha un true e un false bord; un commutator ha un per caso plus default; un fusione ha almeno due inputs.
  • Qualsiasi cosa che agissât al lòs del cont ha un human step amont.
  • Un agent.run nomi solo utensilis che existient.
Un template de pendatura è il rejet più diffus

{{steps.draft.output.text}} in un passo che corre prima di brochura è preso aqui, invece de produrre una stringa vazia a tempo di run. Validazione è severa, perché un flusso de trabalho failure dove ninguém sta observando.

Serialized per te i tools d'agente

{ id: "research", type: "agent.run", config: {
    model: "gemini-3.5-flash",
    tools: { search: api.tools.search, fetch: api.tools.fetch },   // the SDK serialises this
} }
# 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"],
}}

Script ca un oggetto diventa il array de la plataforma stokes. Script ca un array ya, il enviat tal cum è — e un nome de utensilio descognot è negat con la lista de quelli che existie.

Erros

Tutto sopra torna come invalid_workflow (400), con un messaggio che nomea il pas e il problema. Existe un codio perché existe una risposta: fix la definizion.