Create a Workflow draft
POST /v1/workflows
| Property | Value |
|---|---|
| Operation | create_workflow |
| Group | Workflows |
| Scope | workflows:write |
| Route class | control |
| Idempotency | Idempotency-Key accepted: a retry with the same key replays the first answer |
| Audit | Audited workflow.create (mutation) |
| Released in | 1.59.0 |
| Phase 0 host | Served (the hosted api pins 1.65.0) |
Creates a Workflow draft at revision 1 (1.59.0). The definition is checked as a publish checks it: a process-scope Workflow, a node type or field the release does not build and a decision that names a Ruleset are refused with capability_not_available (WorkflowCapabilityCode); every issue of workflows-and-processes.md section 5.3 and of conversation scope with validation_failed (WorkflowIssueCode), each naming the node; an agent_id that names no Agent of the Organization is workflow_agent_unknown.
Request
Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the workflows:write scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.
curl -X POST "$VOCAL_API/v1/workflows" \
-H "Authorization: Bearer $VOCAL_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{
"name": "<name>",
"scope": "conversation",
"entry": "<entry>",
"limits": {
"max_steps": 1
},
"nodes": [
{
"id": "<id>",
"type": "say"
}
]
}'const response = await fetch(`${process.env.VOCAL_API}/v1/workflows`, {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.VOCAL_API_KEY}`,
'Idempotency-Key': crypto.randomUUID(),
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "<name>",
"scope": "conversation",
"entry": "<entry>",
"limits": {
"max_steps": 1
},
"nodes": [
{
"id": "<id>",
"type": "say"
}
]
}),
});
console.log(response.status, await response.text());import os
import uuid
import requests
response = requests.post(
f"{os.environ['VOCAL_API']}/v1/workflows",
headers={
"Authorization": f"Bearer {os.environ['VOCAL_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"name": "<name>",
"scope": "conversation",
"entry": "<entry>",
"limits": {
"max_steps": 1,
},
"nodes": [
{
"id": "<id>",
"type": "say",
},
],
},
)
print(response.status_code, response.text)Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
idempotency-key | header | string | no | A client-chosen key, kept 24 hours per Organization, environment and route. A replay returns the stored response. |
Request body
Content type application/json, required: WorkflowCreateRequest.
| Field | Type | Required | Description |
|---|---|---|---|
agent_id | AgentId | no | Conversation scope only, and required there: the default Agent, which supplies voice, transcriber, model, Policies, Tools and destinations. |
correlation | WorkflowCorrelationInput | no | |
description | string | no | For reviewers; never spoken or sent to a model. |
entry | WorkflowNodeId | yes | |
inputs | map of WorkflowFieldInput | no | Call variables (conversation) or start inputs (process). |
limits | WorkflowLimitsInput | yes | |
name | string | yes | Kebab-case, unique per Organization. |
nodes | array of WorkflowNodeInput | yes | Exactly one entry node; at most 200 nodes, loop bodies included (target). |
outputs | map of WorkflowFieldInput | no | The typed result returned to a parent or a starting Process. |
scope | WorkflowScope | yes | |
settings | map of WorkflowSetting | no | Process scope: named thresholds and constants that evaluate nodes read. |
slots | map of WorkflowFieldInput | no | Conversation scope: the Session's typed slots. |
vars | map of WorkflowFieldInput | no | Process scope: the instance's working data. |
Responses
| Status | Content type | Shape | Error codes |
|---|---|---|---|
201 | application/json | Workflow | |
400 | application/json | ErrorEnvelope | invalid_request |
401 | application/json | ErrorEnvelope | unauthenticated |
403 | application/json | ErrorEnvelope | forbidden, org_suspended |
409 | application/json | ErrorEnvelope | idempotency_in_progress, idempotency_key_reused |
422 | application/json | ErrorEnvelope | validation_failed, capability_not_available |
429 | application/json | ErrorEnvelope | rate_limited |
500 | application/json | ErrorEnvelope | internal_error |
Fields of the 201 answer
The shape is Workflow.
| Field | Type | Required | Description |
|---|---|---|---|
active_version | integer or null | yes | The version the next Agent version publish pins, or null when none is active. |
agent_id | AgentId | no | Conversation scope only, and required there: the default Agent, which supplies voice, transcriber, model, Policies, Tools and destinations. |
archived_at | Timestamp or null | yes | When DELETE archived the Workflow, or null. An archived Workflow takes no write, publish or activation (409 workflow_archived); its pinned versions keep running. |
correlation | WorkflowCorrelation | no | |
created_at | Timestamp | yes | |
description | string or null | yes | For reviewers; never spoken or sent to a model. |
entry | WorkflowNodeId | yes | |
id | WorkflowId | yes | |
inputs | map of WorkflowField | no | Call variables (conversation) or start inputs (process). |
latest_version | integer or null | yes | The highest published version, or null before the first publish. |
limits | WorkflowLimits | yes | |
name | string | yes | Kebab-case, unique per Organization. |
nodes | array of WorkflowNode | yes | Exactly one entry node; at most 200 nodes, loop bodies included (target). |
object | "workflow" | yes | |
organization_id | OrganizationId | yes | |
outputs | map of WorkflowField | no | The typed result returned to a parent or a starting Process. |
revision | integer | yes | Counts writes to the draft; returned as the ETag and required in If-Match. |
scope | WorkflowScope | yes | |
settings | map of WorkflowSetting | no | Process scope: named thresholds and constants that evaluate nodes read. |
slots | map of WorkflowField | no | Conversation scope: the Session's typed slots. |
updated_at | Timestamp | yes | |
vars | map of WorkflowField | no | Process scope: the instance's working data. |