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"},
],
})What is checked before it is saved
- Every step id is unique and well formed; there are at most 30.
- Every step type exists, and its own required configuration is present.
- Every
{{steps.…}}reference names a step that exists and is upstream. - The graph has exactly one edge from the trigger, no cycle, and no unreachable step.
- A condition has a
trueand afalseedge; a switch has one per case plusdefault; a merge has at least two inputs. - Anything that acts outside the account has a
humanstep upstream. - An
agent.runnames only tools that exist.
{{steps.draft.output.text}} on a step that runs before draft is caught here rather than producing an empty string at run time. Validation is strict because a workflow fails where nobody is watching.
Agent tools are serialised for you
{ 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"],
}}Written as an object it becomes the array the platform stores. Written as an array already, it is sent as it is — and an unknown tool name is refused with the list of the ones that exist.
Errors
Everything above comes back as invalid_workflow (400), with a message naming the step and the problem. There is one code because there is one answer: fix the definition.