# Creating nodes ## What is a custom node graph? A **node graph** is a directed acyclic graph of steps that defines a workflow. Each graph must have one `start` node (entry point) and at least one `end` node (exit point; a `branch` can end each path in its own `end`). Intermediate nodes perform actions — enrichments, transformations, branching, AI calls, etc. — and are linked together via `childrenUuids`. Pass a custom node graph to override a tool's deployed release: ```bash cargo-ai orchestration run create \ --workflow-uuid \ --data '{"domain":"acme.com"}' \ --nodes '[...]' ``` Also works with `batch create --nodes`. Cannot be combined with `--release-uuid`. **Always validate first** — use `node validate` to catch structural errors before running: ```bash cargo-ai orchestration node validate --nodes '[...]' ``` **Then show it before you deploy it.** `node validate` proves the graph is well-formed, not that it does what the user wanted. Render it as a Mermaid flowchart — [`node-diagram.md`](node-diagram.md) — and let them check the routing and the paid steps against their intent. The two go together: validate, diagram, ask, deploy. ## Node shape Every node in the `--nodes` JSON array has these fields: | Field | Required | Description | | ------------------- | -------- | -------------------------------------------------------------------------- | | `uuid` | yes | Unique ID within the graph — must be a valid UUIDv4 (e.g. `"550e8400-e29b-41d4-a716-446655440000"`) | | `slug` | yes | Human-readable identifier (`start` and `end` are reserved) | | `kind` | yes | `native`, `connector`, `tool`, `agent`, or `worker` | | `config` | yes | Action-specific configuration (`{}` for start) | | `childrenUuids` | yes | UUIDs of downstream nodes — array length **must match** the `childrenCount` for the node's action (see native actions tables below) | | `fallbackOnFailure` | yes | Continue to the next node even if this one fails | | `position` | yes | `{"x": 0, "y": 0}` — layout only, no runtime effect | | `fallbackChildUuid` | no | UUID of a fallback node to run on failure | | `retry` | no | `{"maximumAttempts": 3, "initialInterval": 1, "backoffCoefficient": 2}` (`initialInterval` is seconds, not milliseconds) | | `name` | no | Display name | | `description` | no | Description | ## Node kinds Each kind requires additional fields beyond the common shape. ### `native` Built-in workflow actions (start, end, branch, filter, variables, etc.). | Field | Required | Description | | ------------ | -------- | -------------------------- | | `actionSlug` | yes | Which native action to run | ### `connector` Third-party integration actions (Clearbit, HubSpot, HTTP, etc.). Discover identifiers first: ```bash cargo-ai connection integration list # → integrationSlug cargo-ai connection integration get-documentation # → actionSlug + config fields cargo-ai connection connector list # → connectorUuid ``` | Field | Required | Description | | ----------------- | -------- | ---------------------------------------- | | `integrationSlug` | yes | Integration identifier (e.g. `clearbit`) | | `actionSlug` | yes | Action within the integration | | `connectorUuid` | yes | Your connected account UUID | `childrenCount` for connector nodes equals the integration action's `children` array length if defined, otherwise defaults to **1**. Most connector actions have exactly 1 child. **Config values from autocomplete:** When you run `integration get `, some actions include a `uiSchema` alongside the `jsonSchema`. If a field has `"ui:widget": "IntegrationAutocompleteWidget"` in the `uiSchema`, you **must** fetch its allowed values using `connector autocomplete` rather than guessing or using freeform input. See `cargo-connection/SKILL.md` for the full autocomplete workflow. ### `tool` Embeds another tool (sub-workflow) as a node. The tool's deployed release config fields become the node's `config`. | Field | Required | Description | | -------------- | -------- | -------------------------------------------------------- | | `toolUuid` | yes, to validate | Target tool UUID — get from `cargo-ai orchestration tool list` | | `templateSlug` | no | Template slug — use when instantiating from a template | | `releaseUuid` | no | Pin to a specific release of the tool | `node validate` rejects a `tool` node without `toolUuid` (`toolInvalid`), and also when the tool has no deployed release and no `releaseUuid` pins one. `childrenCount` is **1**. ```bash # Find toolUuid cargo-ai orchestration tool list # → Extract tool.uuid ``` ### `agent` Embeds a saved AI agent as a node. The agent runs to completion and its output is available to downstream nodes. | Field | Required | Description | | -------------- | -------- | ---------------------------------------------------- | | `agentUuid` | yes, to validate | Target agent UUID — get from `cargo-ai ai agent list` | | `templateSlug` | no | Template slug — use when instantiating from a template | | `releaseUuid` | no | Pin to a specific release of the agent | `node validate` rejects an `agent` node without `agentUuid` (`agentInvalid`), and also when the agent has no deployed release and no `releaseUuid` pins one. `childrenCount` is **1**. ```bash # Find agentUuid cargo-ai ai agent list # → Extract agent.uuid ``` The `config` for an `agent` node takes two fields: | Field | Description | | -------- | ---------------------------------------------------------------------- | | `prompt` | The user message sent to the agent — string or expression object | | `output` | How to parse the agent's response — `{ type: "text" }` or `{ type: "jsonSchema", jsonSchema: {...} }` | `prompt` can be a plain string or an expression object: ```json "prompt": "Summarize the company {{nodes.start.domain}}" ``` ```json "prompt": { "kind": "templateExpression", "expression": "Classify {{nodes.start.company}} into a category", "instructTo": "none", "fromRecipe": false } ``` `output` is a discriminated union on `type`: | `output.type` | Additional field | Description | | -------------- | --------------------------------- | ---------------------------------------- | | `"text"` | *(none)* | Returns the agent's raw text response | | `"jsonSchema"` | `jsonSchema` — a JSON Schema object | Forces structured JSON output matching the schema | ```json "output": { "type": "text" } ``` ```json "output": { "type": "jsonSchema", "jsonSchema": { "type": "object", "properties": { "category": { "type": "string" }, "confidence": { "type": "number" } }, "required": ["category", "confidence"], "additionalProperties": false } } ``` > **Reading agent output downstream — the `.answer` wrapper.** The parsed JSON is exposed under `.answer`, not directly on the node. Use `{{nodes..answer.}}` (e.g. `{{nodes.classify.answer.category}}`). Referencing `{{nodes.classify.category}}` resolves to undefined silently — branch conditions evaluate to false, end-node variables come out empty, and the run still reports `success`. This bites hard because nothing errors. Same path applies to `output.type: "text"` results — read them via `{{nodes..answer}}`. ## Config values and expressions Config fields that need dynamic data use **expression objects**: ```json { "kind": "templateExpression", "expression": "{{nodes.start.domain}}", "instructTo": "none", "fromRecipe": false } ``` | Field | Values | Description | | ------------ | ---------------------------------------- | ------------------------------------------------------------------------------------------- | | `kind` | `"templateExpression"`, `"jsExpression"` | Template expressions use `{{...}}` syntax; JS expressions are raw JS | | `expression` | string | The expression to evaluate | | `instructTo` | `"none"`, `"ai"` | `"none"` = JS evaluation; `"ai"` = AI fills the value from the expression as an instruction | | `fromRecipe` | boolean | `false` for inline expressions | ### Data flow Each node's output is stored under its slug. Reference it in downstream nodes with `{{nodes..}}`. ``` {{nodes.start.domain}} — input data field {{nodes.enrich_company.name}} — output from the "enrich_company" node {{nodes.enrich_company.metrics.employeesRange}} — nested field access {{nodes.start.email.split('@')[1]}} — JS expressions work inside {{ }} ``` Inside a `group` loop, use `{{parentNodes..}}` to access the parent run's context. ### Static values For config fields that don't need expressions, pass the value directly: ```json { "minutes": 5 } ``` ## Native actions reference These are the `actionSlug` values available for `kind: "native"` nodes. ### Workflow entry/exit | actionSlug | Purpose | childrenCount | Config | | ---------- | ------------------------- | -------- | -------------------------------------------- | | `start` | Entry point | 1 | `{}` | | `end` | Exit point, define output | 0 | `{"variables": [{"name", "type", "value"}]}` | The `end` node's `variables` array defines the workflow output. Each variable has: - `name` — output field name - `type` — `"string"`, `"number"`, `"boolean"`, `"date"`, `"array"`, `"object"`, or `"any"` - `value` — an expression object or static value ### Routing | actionSlug | Purpose | childrenCount | Config | | ---------- | --------------------- | -------- | -------------------------------------------------------------------------- | | `filter` | Continue only if true | 1 | `{"filter": }` | | `branch` | If/else split | 2 | `{"condition": }` | | `switch` | Multi-way routing | dynamic | `{"routes": [{"name": "...", "uuid": "...", "value": }]}` | | `split` | Random A/B split | 2 | `{"percentage": <0-100>}` | **`childrenUuids` ordering matters:** - **`branch`**: index 0 = condition matched ("yes"), index 1 = not matched ("no") - **`filter`**: index 0 = condition true (execution stops if false — no child called) - **`switch`**: first route whose `value` evaluates to `true` wins; its index in the `routes` array determines which `childrenUuids` entry to follow - **`split`**: index 0 = random number < percentage ("A"), index 1 = otherwise ("B") ### Data | actionSlug | Purpose | childrenCount | Config | | ----------- | --------------------- | -------- | ------------------------------------------------------------------------ | | `variables` | Create/transform data | 1 | `{"variables": [{"name": "...", "type": "...", "value": }]}` | Same shape as `end` variables, but the output is available to downstream nodes via `{{nodes..}}`. ### Storage Read and write Cargo models from inside a workflow. Use these, **not** an HTTP call to the model's `/records/ingest` webhook: that URL is for systems outside Cargo, and calling it from a node costs an HTTP node, a payload script, and a token in a header. | actionSlug | Purpose | childrenCount | Config | | ------------- | ----------------------------------------------- | -------- | ------------------------------------------------------------------------------------------ | | `modelUpsert` | Update the matching record, or insert one | 1 | `{"modelUuid", "matchingColumnSlug", "matchingValue", "mappings": [{"columnSlug", "value"}]}` | | `modelUpdate` | Update matching records only | 1 | Same as `modelUpsert` | | `modelInsert` | Insert a new record | 1 | `{"modelUuid", "mappings": [{"columnSlug", "value"}]}` | | `modelRemove` | Remove matching records | 1 | `{"modelUuid", "matchingColumnSlug", "matchingValue"}` | | `modelSearch` | Read records (filter, sort, limit) | 1 | `{"modelUuid", "filter"?, "sort"?, "limit"?, "selectedColumnSlugs"?}` | Each mapping `value` (and `matchingValue`) is a template expression, so values come straight from upstream nodes with no prep step. `mappings` targets the model's own columns; `customMappings` (same shape) targets its custom columns. A null `matchingValue` fails the node without writing. All of them output an array of records. #### Files Read and write workspace **content files** by path (`reports/2026-q3/summary.md`: folder chain plus name). Use these, not an HTTP node to a storage API or a script that base64-juggles bytes. | actionSlug | Purpose | childrenCount | Config | Output | | ------------ | ---------------------------------------- | -------- | ------ | ------ | | `writeFile` | Store text or base64 bytes at a path | 1 | `{"path", "content", "encoding"?: "text"\|"base64", "contentType"?, "visibility"?: "private"\|"public", "indexMode"?: "none"\|"vectorStore"}` | `{fileUuid, path, size, url, publicUrl?}` | | `readFile` | Read a file by path | 1 | `{"path", "encoding"?: "text"\|"base64"}` | `{fileUuid, path, contentType, size, content}` | | `getFileUrl` | Signed link to a file by path | 1 | `{"path", "expiresInSeconds"?, "download"?}` | `{fileUuid, path, url, expiresAt, publicUrl?}` | - `writeFile` creates missing folders and **overwrites** the newest file of that name in place (same `fileUuid`). A new file is `private`, `indexMode: "none"` (not searchable by agents) and not mirrored to the context repo; an overwritten one keeps its own settings unless the node sets them. `contentType` defaults to `text/plain; charset=utf-8` (text) or `application/octet-stream` (base64). - `writeFile` / `readFile` cap at **10 MB**; a larger read fails and points at `getFileUrl`. A **preview (dry) run of `writeFile` writes nothing** — it returns a zero `fileUuid` and no `url`. - `url` is a signed link **anyone holding it can open** — 1 hour from `writeFile`, `expiresInSeconds` (default 3600, max 10800) from `getFileUrl`. `publicUrl` is the stable no-auth link, present only when the file is `public`. Do not route either to a third party unless the play's purpose is to share that file. - All three fail without retry: `File not found at `, `File not written: ` (`invalidPath`, `folderReadOnly`, …). Path model, defaults per surface, and the public link: [`../../cargo-content/references/objects.md`](../../cargo-content/references/objects.md). ### Human review `humanReview` posts content to Slack with buttons and waits for a person. **2 children**: child 0 = approved (or edited), child 1 = declined. | Config | Notes | | --- | --- | | `connectorUuid`, `channelId` | Slack connector and channel (required; `channelId` autocompletes via `listChannels`) | | `title`, `content` | `title` is the posting username; `content` is Slack mrkdwn | | `threadTs`? | Post the review as a **reply in that thread** instead of a new message | | `enabledButtons`? | Subset of `["approve","decline","edit"]` (default all). An empty set fails: `At least one button (Approve, Decline, or Edit) must be enabled` | | `approveButtonLabel`?, `declineButtonLabel`?, `editButtonLabel`? | ≤ 75 characters each; `""` falls back to the default. The edit modal's submit button reuses the approve label only if it is ≤ 24 characters | | `timeoutMilliseconds`? | Default 24 h | Output: `{approved?, user?: {id, username, name}, content, channelId?, messageTs?}` — after an edit, `content` is the edited text and the run takes child 0. **A timeout errors the node** (`Human review timed out`, no retry) rather than taking a branch; give it a `fallbackOnFailure` path when a non-answer should route somewhere. ### Flow control | actionSlug | Purpose | childrenCount | Config | | ---------- | --------------------- | -------- | ----------------------------------------------------------- | | `delay` | Wait before next node | 1 | `{"minutes": }` | | `group` | Loop over array items | 1 | `{"items": , "failOnItemFailure": false, "_nodes": [...]}` | The `group` node iterates over `items`, running the child subgraph once per item. Each iteration can access the current item via `{{nodes.start.value}}` (for simple values) or `{{nodes.start.}}` (for object items). Use `{{parentNodes..}}` to reference the parent run's data. > **Reading group results downstream:** the group node's output is an **array**, one entry per iteration, where each entry is that iteration's final (`end`) node output. Access it by index: `{{nodes.[0].}}`. There is **no `.results` wrapper**, so `{{nodes..results[0]...}}` does not work. To collapse the array into one value, use an expression: `{{nodes..map(x => x.field).filter(Boolean).join(", ")}}` or `.reduce(...)` works inline, with no code node. > **`delay` and context:** prior node outputs are **not** lost across a `delay` — the full run context is checkpointed and restored, so `{{nodes....}}` still resolves after the delay regardless of node kind. The checkpoint is JSON, though, so values you read after a delay must be JSON-serializable. Materialize anything you need post-delay into a `variables` node (plain strings/numbers/objects) before the delay rather than relying on a `python` node's `result`. **Group sub-graph (`_nodes`):** The `_nodes` array inside the group's config defines the internal workflow executed for each item. It follows the **exact same rules** as a top-level node graph: - Must have a `start` node and an `end` node - Every node's `childrenUuids` must contain **exactly the number of entries shown in the `childrenCount` column** of the native actions tables above (e.g. `start` → 1, `variables` → 1, `branch` → 2, `end` → 0). This rule applies identically at both the top level and inside `_nodes` - The `end` node must have `childrenUuids: []` - Reference the current item with `{{nodes.start.value}}` or `{{nodes.start.}}` - Reference parent workflow data with `{{parentNodes..}}` **Important:** Do NOT leave the last sub-node with `childrenUuids: []` unless it is the `end` node. Every other node type (variables, connector, tool, agent, etc.) requires exactly 1 child. Always terminate the sub-graph with an explicit `end` node. ### AI and code | actionSlug | Purpose | childrenCount | Config | | ---------- | ------------------- | -------- | ------------------------------------------------------------------------------------------------------ | | `agent` | Inline AI agent | 1 | `{"prompt": "...", "advancedSettings": {"connectorUuid": "...", "languageModelSlug": "gpt-4.1-mini"}}` | | `classify` | Typed yes/no, choice and score answers about one input | 1 | `{"state": , "questions": [...]}` — see below | | `python` | Run Python code | 1 | `{"script": "..."}` | | `script` | Run JavaScript code | 1 | `{"script": "..."}` | The `agent` action requires `advancedSettings.connectorUuid` (an AI provider connector — get it from `connector list`). Optional fields: `tools` (not `actions`), `resources`, `capabilities`, `mcpClients`, `output` (structured output with `{"type": "jsonSchema", "jsonSchema": {...}}`), `advancedSettings.temperature`, `advancedSettings.maxSteps`, `advancedSettings.systemPrompt`. #### `classify` — typed questions, no connector, no model to pick Every question is answered in one call, with probabilities. It runs on Cargo's own key, so there is no `connectorUuid` and no model choice (`model` is optional and defaults to `jev-latest`). Priced **0.01 credits per started 1,000 input tokens** (output tokens free), plus the 0.01 node execution charge. ```json { "state": "{{nodes.start}}", "questions": [ {"type": "noul", "id": "isB2b", "instructions": "Does this company sell to businesses?", "trueCriteria": "Sells primarily to companies", "falseCriteria": "Sells primarily to consumers"}, {"type": "choice", "id": "segment", "instructions": "Which market segment fits best?", "options": [{"option": "SMB"}, {"option": "Mid-market"}, {"option": "Enterprise", "description": "1,000+ employees"}]}, {"type": "score", "id": "fit", "instructions": "How well does it match our ICP?", "levels": ["poor", "weak", "good", "strong"]} ] } ``` - **Yes/no is `"type": "noul"`** — not `yesNo` or `boolean`. `trueCriteria` / `falseCriteria` are optional. Choice takes 2–255 `options`; score takes 2–10 `levels`, lowest first. `id` names the output key and is not sent to the model. - Output: `{model, answers: {: …}, usage: {input_tokens, output_tokens}}` — read `{{nodes..answers..…}}` (**no `.answer` wrapper**, unlike `agent`): - yes/no → `{type: "noul", noul}` — the **probability of yes**, 0–1; branch on `{{nodes..answers.isB2b.noul > 0.5}}`, not on a boolean. - choice → `{type: "choice", choice, confidence, probabilities: {