Appearance
Workflows
A workflow agent runs a graph: agents, conditions, parallel branches, loops, HTTP calls, knowledge searches, human approvals and waits, wired together by edges. Workflow runs are durable: every node's state is stored, a crash resumes from the last finished node, and a run can pause for hours or days without holding resources.
You build workflows in the console's graph editor. This page documents the stored graph format (what the editor produces, AgentConfig.workflow) and how runs behave, so you can reason about and call your workflows precisely.
Graph format
json
{
"nodes": [
{ "id": "start", "type": "start" },
{
"id": "extract",
"type": "agent",
"agentId": "1c9e…",
"input": { "text": "$input.letter" }
},
{
"id": "route",
"type": "condition",
"cases": [{ "handle": "urgent", "when": "$nodes.extract.output.urgency = 'high'" }]
},
{
"id": "review",
"type": "approval",
"message": "'Urgent letter from ' & $nodes.extract.output.sender",
"data": "$nodes.extract.output",
"timeoutHours": 24
},
{ "id": "done", "type": "output", "output": "$nodes.extract.output" },
{ "id": "rejected", "type": "fail", "message": "'Rejected by reviewer'" }
],
"edges": [
{ "id": "e1", "source": "start", "target": "extract" },
{ "id": "e2", "source": "extract", "target": "route" },
{ "id": "e3", "source": "route", "target": "review", "sourceHandle": "urgent" },
{ "id": "e4", "source": "route", "target": "done", "sourceHandle": "default" },
{ "id": "e5", "source": "review", "target": "done", "sourceHandle": "approved" },
{ "id": "e6", "source": "review", "target": "rejected", "sourceHandle": "rejected" },
{ "id": "e7", "source": "review", "target": "done", "sourceHandle": "timeout" }
],
"vars": { "today": "$now()" }
}| Field | Type | Notes |
|---|---|---|
nodes | array of nodes (max 200) | see node types |
edges | array of {id, source, target, sourceHandle?} (max 500) | sourceHandle absent or null = the main output |
vars | map of name → expression, optional | evaluated once from the input when the run starts; $vars.name |
The workflow agent's inputSchema validates the run input; its outputSchema (optional) validates the output node's result.
Node ids and handles
Node ids use letters, digits, _ and - (1 to 64 characters); they appear in expressions ($nodes.extract) and in approval and event URLs.
Edges leave a node from an output handle:
| Node | Handles |
|---|---|
| most nodes | main output (no handle) |
condition | each case's handle, and default |
approval | approved, rejected, and timeout when timeoutHours is set (no main output) |
wait | main output, and timeout in event mode with timeoutHours |
any node with onError: "error_edge" | additionally error |
output, fail | none: they end the run |
Node types
Every node has these common fields:
| Field | Default | Meaning |
|---|---|---|
id | unique node id | |
type | node type | |
label | display name (max 200 chars); shown in the approvals inbox | |
position | {x, y} in the editor | |
retry | {attempts, backoffMs}: attempts 1 to 10 (total tries, default 1), backoffMs fixed delay (default 1000) | |
timeoutMs | the node fails with NODE_TIMEOUT after this time | |
onError | fail | fail: fail the run; continue: mark the node failed and follow its main output; error_edge: follow its error edge |
start
The entry point; exactly one per workflow, no incoming edges. Output: the run input.
agent
Runs an agent of the project (its current published version) as a child run (source: "workflow").
| Field | Meaning |
|---|---|
agentId | the agent to run |
input | map of input field → expression (default {}) |
files | optional expression giving the run's input files (see Files) |
Output: the agent's output ({text} or schema JSON). The mapping must cover the target's required input fields (conversational agents: message); when the target's schema has additionalProperties: false, unknown fields are rejected. Targets may be workflows (run as nested workflow runs the node waits for), but not realtime agents, not the workflow itself and not agents that call it back. A failed child run fails the node with CHILD_RUN_FAILED.
llm
One model call defined inline, without creating a separate agent. It runs as a child run of the workflow agent (source: "workflow"), metered like any agent run.
| Field | Default | Meaning |
|---|---|---|
model | {modelId, temperature?, maxOutputTokens?, reasoningEffort?} | |
instructions | "" | system instructions (plain text) |
prompt | expression giving the user message; non-strings are sent as JSON | |
files | optional expression giving input files (see Files) |
Output: {text}. Publishing requires an enabled chat model and a non-empty prompt. A failed model call fails the node with CHILD_RUN_FAILED. For tools, knowledge or structured output, use an agent node.
condition
| Field | Meaning |
|---|---|
cases | [{handle, when}], at least one; handle unique, not default or error |
Cases are evaluated in order; the first truthy when selects its handle, otherwise default. Output: { "handle": "<selected>" }. Truthiness: null, false, 0, "", empty arrays and empty objects are false.
parallel
No fields. Fans out: connect several edges from its main output; all targets run concurrently. Output: null.
join
| Field | Default | Meaning |
|---|---|---|
mode | all | all: wait for every taken incoming branch; any: run on the first |
Output: an object of the taken incoming branches' outputs by node id.
map
Runs an agent once per item of an array.
| Field | Default | Meaning |
|---|---|---|
items | expression giving an array (else ITEMS_NOT_ARRAY) | |
agentId | the agent run for each item (not a workflow) | |
input | {} | input mapping; $item is the item, $index its 0-based index |
concurrency | 4 | items run at once (1 to 20) |
Output: the array of item outputs, in item order. An empty array gives [] at once. A failed item fails the node (ITEM_FAILED).
loop
Runs an agent repeatedly.
| Field | Default | Meaning |
|---|---|---|
agentId | the agent run each iteration (not a workflow) | |
input | {} | input mapping; $iteration (1, 2, …) and $last (previous output, null first) |
until | expression evaluated after each iteration ($iteration, $last = that iteration's output); truthy stops | |
maxIterations | 10 | 1 to 100 |
Output: the last iteration's output.
transform
| Field | Meaning |
|---|---|
expression | JSONata expression; its value is the output |
http
Calls an external API through the platform's SSRF-safe client.
| Field | Default | Meaning |
|---|---|---|
method | GET | GET, POST, PUT, PATCH, DELETE |
url | expression giving the URL string | |
headers | {} | literal header values; may contain {{secret:NAME}} |
body | expression; objects are sent as JSON (ignored for GET) |
When a header uses a secret, the url expression must fix the host: it must be one quoted URL ("https://api.example.com/items") or start with a quoted literal "scheme://host[:port]/" followed by & concatenation ("https://api.example.com/items/" & $input.id). Expressions that compute the host ($input.url, "https://" & $input.host & "/x", functions, conditions) fail validation on workflow.nodes.<i>.url, and at run time a request whose origin differs from the literal one is refused (SECRET_ORIGIN_CHANGED). See Secrets only go to a fixed host.
Output: {status, body, truncated} (body parsed as JSON when possible, kept up to 256 KB). A non-2xx status fails the node (HTTP_STATUS).
search
Searches indexed data sources without an agent.
| Field | Default | Meaning |
|---|---|---|
dataSourceIds | one or more indexed sources | |
query | expression giving the query text | |
topK | 5 | 1 to 50 |
Output: { "results": [{chunkId, documentId, dataSourceId, title, text, metadata, score}] }. Query embedding tokens are metered on the workflow run.
ocr
Reads the text of one image or PDF with Tesseract and returns where every line and word is.
| Field | Default | Meaning |
|---|---|---|
file | expression giving one image or PDF: a file id or file object ($files[0]) | |
languages | server | Tesseract codes joined by +, e.g. eng+deu |
maxPages | 5 | PDF pages read from the first one (1 to 50) |
Output:
json
{
"text": "Full name\nDate of birth",
"pageCount": 1,
"pages": [
{
"page": 1,
"width": 1654,
"height": 2339,
"lines": [
{
"id": "p1-l1",
"text": "Full name",
"confidence": 93.5,
"bbox": { "x": 0.08, "y": 0.12, "w": 0.11, "h": 0.012 },
"words": [
{
"text": "Full",
"confidence": 94.1,
"bbox": { "x": 0.08, "y": 0.12, "w": 0.04, "h": 0.012 }
}
]
}
]
}
],
"warnings": []
}Boxes are fractions (0 to 1) of the page's width and height, x, y being the top-left corner, so they can be drawn on the page at any resolution. Line ids (p<page>-l<n>) let an agent refer to lines. OCR pages of this node are not metered. A file that is not an image or PDF fails the node with FILE_REF_INVALID; an unreadable one with DOCUMENT_STEP_FAILED.
annotate
Draws labelled boxes on one image or PDF and stores one PNG per page that has boxes (page 1 when there are none) as project files. They expire like uploaded run inputs.
| Field | Meaning |
|---|---|
file | expression giving the image or PDF to draw on |
boxes | expression giving a list of boxes, or an object whose fields is such a list |
A box is either { bbox: { x, y, w, h, page? }, page?, label?, key?, color? } (the shape of extracted form fields; label falls back to key) or the box fields directly ({ x, y, w, h, page?, label?, color? }, the shape of OCR lines and words). Coordinates are fractions of the page and are clamped to it; page is 1-based (default 1); color is #rrggbb (a palette color otherwise). Items without a usable box are skipped. At most 500 boxes.
Output: { "fileId": "…", "images": [{ "fileId": "…", "page": 1, "width": 1240, "height": 1754 }], "count": 12 }. The console shows the images in the run views. Pass fileId (or the whole output) to another node's files to let an agent look at the preview, e.g. to review its own boxes.
approval
Pauses until a person approves or rejects. See Approvals.
| Field | Meaning |
|---|---|
message | expression; text shown to the approver |
data | expression; data to review, which the approver may edit |
timeoutHours | without a decision in time, the timeout edge is followed |
Output: the edited data sent with the decision, else the evaluated data.
wait
| Field | Meaning |
|---|---|
mode | duration, until or event |
durationMs | duration mode: how long to pause |
until | until mode: expression giving an ISO timestamp (else INVALID_TIME) |
eventName | event mode: the event name to wait for (1 to 200 chars) |
timeoutHours | event mode: without the event in time, the timeout edge is followed |
Output: timers give { "resumedAt": "<ISO time>" } (a time in the past continues at once); events give the event's data. See Waits and events.
output
| Field | Meaning |
|---|---|
output | expression; the run's output |
The first output node reached completes the run; its value is validated against the workflow's outputSchema (OUTPUT_SCHEMA_MISMATCH). No outgoing edges.
fail
| Field | Meaning |
|---|---|
message | expression; the error message |
Fails the run with code WORKFLOW_FAILED and the evaluated message. No outgoing edges.
Expressions
Mappings, conditions, URLs and messages are JSONata expressions evaluated against the run context { input, nodes, vars }:
| Binding | Value |
|---|---|
$input | the run input |
$nodes | { <nodeId>: { output, status } } of the nodes that ran: $nodes.extract.output.total |
$vars | the workflow's vars, evaluated once at the start |
$files | the run's input files: [{id, name, mimeType, size, pages}] ([] without files) |
$item | map nodes: the current item |
$index | map nodes: the item's index, from 0 |
$iteration | loop nodes: the iteration number, from 1 |
$last | loop nodes: the previous iteration's output (null in the first) |
Because the context is also the root, input.letter and $input.letter are equivalent. Examples:
text
$input.customer.email
$nodes.extract.output.lineItems[amount > 100]
$sum($nodes.items.output.amount)
$nodes.review.status = 'succeeded' and $vars.region = 'EU'
{ "text": $nodes.translate.output.text, "lang": $input.lang }
$last.score >= 0.9Evaluation is sandboxed (no I/O) and bounded: 1 s wall time, 200 000 evaluation steps, recursion depth 300 and 100 000 sequence items; an expression may be at most 10 000 characters. Regex literals ($match, $replace, $split, $contains) use RE2 syntax, which has no lookarounds or backreferences, and $eval is not available. A failing expression fails the node with EXPRESSION_ERROR. Expressions are compiled when the draft is saved, so syntax errors show up before publishing.
Files
Upload files first (POST /v1/files) and send their ids with the run (files). The workflow's files settings decide which files it accepts (by default PDF, PNG and JPEG up to 20 MB and 30 pages). In expressions, $files lists them as {id, name, mimeType, size, pages}.
Agent, LLM, map and loop nodes pass files on with their files expression: a file id, a file object with id (an entry of $files, an annotate node's output) or a list of those; empty or null passes none. The files become the child run's input files, so the child agent'sfiles settings apply (accepted types, size, pages, vision or ocr); a file it does not accept fails the node with CHILD_RUN_FAILED. Map and loop nodes evaluate files per item or iteration. A value that is not a file reference fails the node with FILE_REF_INVALID, a file of another project or one that has expired with FILE_NOT_AVAILABLE.
json
{
"id": "fields",
"type": "agent",
"agentId": "…",
"input": { "layout": "$nodes.ocr.output" },
"files": "$files[0]"
}Example: form field detection
The full setup, with agent instructions and schemas, is in Form field detection.
Each step is an agent with a fixed output schema, so steps can be swapped and reused in other workflows:
startwith one uploaded form ($files[0]).ocrreads the form's lines and words with boxes.- An
agentnode runs an extraction agent withinput: { layout: "$nodes.ocr.output" }andfiles: "$files[0]". Its output schema is{ fields: [{ key, label, type, bbox: { page, x, y, w, h }, confidence }] }; it places each field next to the OCR box of its label. - A
loopnode runs a reviewer agent withfiles: "$files[0]"and the draft ($last ? $last : $nodes.fields.output) until$last.approved, at most 3 times. - Optionally an
approvalnode withdata: $nodes.review.outputso a person can correct the fields. annotatewithfile: "$files[0]"andboxes: "$nodes.review.output".outputwith{ "fields": $nodes.review.output.fields, "previewFileId": $nodes.preview.output.fileId }.
Validation
Saving a draft, publishing and playground runs check the graph:
- exactly one
startnode and at least oneoutputnode; unique node and edge ids; - edges between existing nodes, on valid handles; no self-loops; nothing into
start; nothing out ofoutputandfail; anerroredge for every node withonError: "error_edge"; - every node reachable from
start; no cycles (repeat work with aloopnode); - expressions compile;
waitnodes have the field their mode needs; - referenced agents exist in the project, are published, are not realtime, are not the workflow itself and do not call it back;
mapandlooprun non-workflow agents; agent mappings cover required input fields; searchnodes reference indexed data sources of the project.
A draft is stored even when it is incomplete (an agent node without an agent, a search node without data sources, a condition without cases): the save answers valid: false with an error per field (for example workflow.nodes.1.agentId: select an agent), and publishing refuses the draft until they are fixed.
Execution
- A node runs when every incoming edge is settled and at least one was taken. Branches that were not selected are
skipped, and skips propagate downstream. joininallmode waits for all taken branches; inanymode it runs on the first.- Each node run is stored with its input, output, status, attempts and error. Statuses:
pending,running,waiting,succeeded,failed,skipped,cancelled. - A run whose branches all end without reaching an output node fails with
WORKFLOW_NO_OUTPUT. - When a node fails for good with
onError: "fail", the run fails with the node's error code and the messageNode "<id>": <message>.
Retries and errors
retry.attempts is the total number of tries (with backoffMs between them) before the node counts as failed; then onError decides: fail the run, continue on the main output (the node keeps status failed, its output is null; check $nodes.<id>.status downstream), or follow the error edge.
A failed run can be retried: POST /v1/runs/{id}/retry (scope agents:run) re-executes the failed nodes and everything downstream, keeping the results of nodes that succeeded. It answers 202 {runId, status: "running"}; only failed workflow runs can be retried (409 RUN_NOT_RETRYABLE, 409 NOT_A_WORKFLOW_RUN). A run that ended at a fail node (for example after a rejected approval) followed the graph as designed, so it is not retried (409 RUN_ENDED_AT_FAIL_NODE): start a new run instead.
Limits
| Limit | Default | Error |
|---|---|---|
| Nodes per workflow | 200 | validation |
| Edges per workflow | 500 | validation |
| Node executions per run (map items and loop iterations count) | 1000 | WORKFLOW_STEP_LIMIT |
| Run duration, waits included | 24 hours | WORKFLOW_TIMEOUT |
| Nesting depth (agent nodes, nested workflows, agent tools) | 3 | DEPTH_LIMIT |
The step, duration and depth limits are platform settings and may differ on your installation.
Usage
A workflow run's usage is its own usage (search embeddings) plus the usage of its child runs.
Sync, async and stream
Start a workflow like any agent: POST /v1/agents/{slug}/runs. Run files (files) are checked against the workflow's files settings and reach the nodes as $files (see Files).
| Mode | Behaviour |
|---|---|
| sync (default) | waits up to 60 s (platform setting). Finished: 200 with the RunResult. Still running or paused: 202 {runId, status} with status running or waiting |
async: true | 202 {runId, status: "queued"} at once |
stream: true | SSE with run.started, node.started, node.completed, agent nodes' text.delta (with nodeId), then run.completed / run.failed, or run.waiting when the run pauses (the stream ends there) |
Handle 202 in sync calls: poll GET /v1/runs/{id} (scope runs:read) or subscribe to the run.completed, run.failed and run.waiting webhooks. The SDK resolves a 202 as a result with status: "running" or "waiting" and output: null:
ts
let result = await hevkar.agents.run('letter-pipeline', { input: { letter } });
if (result.status === 'running' || result.status === 'waiting') {
const run = await hevkar.runs.waitForCompletion(result.runId, { stopOnWaiting: true });
}GET /v1/runs/{id} of a workflow run includes nodes (the node runs); GET /v1/runs/{id}/steps returns {children, nodes, waits}.
Approvals
An approval node pauses the run (status: "waiting") and creates a pending approval. It shows up in the console's Approvals inbox, and a run.waiting webhook is sent with kind: "approval", the message and the timeoutAt.
Decide in the console (any member of the organization), or from your system with POST /v1/runs/{id}/approvals/{nodeId} (scope workflows:approve; agents:run is not enough, so the key your app uses to start runs for end users cannot approve their human steps):
bash
curl "$HEVKAR_BASE_URL/v1/runs/$RUN_ID/approvals/review" \
-H "Authorization: Bearer $HEVKAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"decision": "approve", "data": {"amount": 120}, "comment": "checked"}'ts
await hevkar.runs.approve(runId, 'review', {
decision: 'approve', // or 'reject'
data: { ...reviewed, amount: 120 }, // optional: replaces the node output
comment: 'checked',
});approve follows the approved edge, reject the rejected edge; data (optional) replaces the node's output. The answer is {runId, status}. A node that is not waiting answers 404 APPROVAL_NOT_FOUND. Every decision is audit-logged with who made it (user:<id> or api_key:<id>).
Waits and events
durationanduntilwaits are timers: the run resumes on the main output when the time comes.eventwaits pause until your system delivers the named event withPOST /v1/runs/{id}/events(scopeworkflows:approve); the node's output is the event'sdata. If no wait node of the run is waiting for that name, the API answers409 EVENT_NOT_EXPECTED.
bash
curl "$HEVKAR_BASE_URL/v1/runs/$RUN_ID/events" \
-H "Authorization: Bearer $HEVKAR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "payment.received", "data": {"amount": 120}}'ts
await hevkar.runs.sendEvent(runId, { name: 'payment.received', data: { amount: 120 } });A run.waiting webhook with kind: "event" and eventName tells you which event a run waits for.
Cancelling
POST /v1/runs/{id}/cancel cancels a workflow run that is queued, running or waiting at once, together with its pending steps, waits and child runs: {runId, status: "cancelled", cancelRequested: false}. Cancelled runs started through the API send a run.failed webhook with error code RUN_CANCELLED.