> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canary.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# invoke node

> Run another published procedure as a child step and wait for its typed result.

An `invoke` starts one separately published procedure as a child run, waits for it to finish, and
binds its result. Use it to reuse a whole procedure, such as a shared notice or review process,
with its own versions. To run a single function or effect, use
[`call`](https://docs.canary.effectiveai.app/procedures/reference/nodes/call) instead.

## Syntax

Follow whichever version is live when the step runs:

```yaml invoke id=send-notice theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
procedure: catalog:cancellation-notice/live
input:
  policy_number: $inputs.policy_number
  reason: nonpayment
output: notice
```

Or pin one exact published version:

```yaml invoke id=send-notice theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
procedure: catalog:cancellation-notice@3
input:
  policy_number: $inputs.policy_number
  reason: nonpayment
output: notice
```

## Fields

| Field | Type | Required | Default | What it does |
| - | - | - | - | - |
| `procedure` | string | Yes | None | The child procedure. `catalog:<procedure-id>/live` follows the procedure's live version. `catalog:<procedure-id>@<N>` pins version `N`, a positive whole number. Quotes are optional. |
| `input` | object | Yes | None | The child's inputs. Validated against the child's declared inputs. Nothing else passes to the child: not the parent's prose, people, sessions or other values. |
| `output` | name | Yes | None | A new named value that holds the child's declared output. It can't be left out, because the child's result contract is part of the step. |

These selectors are not valid: an ID without `catalog:`, `latest`, version `0` or below, version
ranges, local file paths, and references or other expressions.

## Example

A nonpayment cancellation procedure hands the notice to a separately published procedure:

````markdown nonpayment-cancellation.procedure.md theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
---
kind: procedure@v0
id: nonpayment-cancellation

inputs:
  policy_number: { type: string }
outputs:
  result: { schema: cancellation-result }
---

# Nonpayment cancellation

Send the cancellation notice through the separately published notice
procedure, then report what it returned.

## Send notice

```yaml invoke id=send-notice
procedure: catalog:cancellation-notice/live
input:
  policy_number: $inputs.policy_number
  reason: nonpayment
output: notice
```

```yaml complete id=finish
output: result
value:
  policyNumber: $inputs.policy_number
  noticeSent: $notice.sent
```

## Resources

```yaml schema id=cancellation-result
type: object
additionalProperties: false
required: [policyNumber, noticeSent]
properties:
  policyNumber: { type: string }
  noticeSent: { type: boolean }
```
````

The child, `cancellation-notice`, declares inputs `policy_number` and `reason` and one output with
`policyNumber` and `sent` fields. The parent reads `$notice.sent` from that output.

## On retry and resume

* **The parent waits.** The parent can't move past the invoke until the child finishes or fails.
  There is no fire-and-forget form.
* **`@N` is fixed.** An exact selector always runs those exact child bytes, for every run of the
  parent.
* **`/live` is resolved once per step.** The first time a run reaches the step, it resolves the
  live version to one exact version and records that choice. Retries and resumes use the
  recorded child and never resolve `/live` again. A running or retried child stays on the version
  it started with.
* **Compatible moves need no republish.** Publishing the parent records the child's input and
  output contracts, not a version. When `/live` moves to a version with the same contracts, new
  runs of the parent use it without republishing the parent.
* **Incompatible moves fail before the child starts.** If the live version's input or output
  contract no longer matches what the parent recorded, the step fails before any child starts.
* **Failures fail the step.** A malformed child result or a technical child failure fails the
  invoke. Put business outcomes such as "rejected" in the child's typed output instead.
* **Nesting is bounded.** A chain of invokes can be at most eight levels deep. A procedure can't
  invoke itself through `/live`, and a cycle back to a procedure already running above the child
  is refused when the child would start.

## Common errors

| Code | Cause | Fix |
| - | - | - |
| `PROC-INVOKE-002` | The selector doesn't resolve, for example `Unresolved catalog procedure catalog:cancellation-notice@3.`, or a `/live` selector calls the procedure itself. | Publish the child first, check the ID and version, or remove the self-call. |
| `PROC-FENCE-006` | The body is missing a field, for example `output`, or has an unknown one. | Include `procedure`, `input` and `output`, and nothing else. |
| `PROC-SCHEMA-005` | The input doesn't match the child's declared inputs. | Pass exactly the inputs the child declares. |

At run time, an invoke can also fail because the child version isn't available, its contracts no
longer match, the nesting limit is reached, or a cycle would form.

## See also

* [`call` node](https://docs.canary.effectiveai.app/procedures/reference/nodes/call)
* [`complete` node](https://docs.canary.effectiveai.app/procedures/reference/nodes/complete), which produces the output a child returns
* [Runs and versions](https://docs.canary.effectiveai.app/procedures/concepts/runs-and-versions.md)
* [Run procedures from your system](https://docs.canary.effectiveai.app/guides/procedures.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.