> ## 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.

# Cheat sheet

> Every procedure node and declaration on one page, with its shortest useful form and a link to its full reference.

Each block below is the shortest useful form of a node or declaration. Every node needs a unique
`id`. Nodes run in document order; declarations can sit anywhere. Follow a heading's link for
every field, the behavior on retry and resume, and common errors.

## Document

[Procedure document](https://docs.canary.effectiveai.app/procedures/reference/document.md): front matter names the procedure and its
inputs and output.

```markdown theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
---
kind: procedure@v0
id: policy-check
inputs:
  policy_number: { type: string }
outputs:
  result: { schema: result }
---
```

Refer to data with `$inputs.policy_number` or `$named_value.field`, build strings with
`'Policy {{ $inputs.policy_number }}'`, and fall back with `$a.note ?? ""`.

## Do work

[`call`](https://docs.canary.effectiveai.app/procedures/reference/nodes/call): run a function or effect declared in the document.

```yaml call id=read-policy theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
function: '@local.read-policy'
input:
  policyNumber: $inputs.policy_number
output: policy
```

[`invoke`](https://docs.canary.effectiveai.app/procedures/reference/nodes/invoke): run another published procedure as a child run.

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

[`value`](https://docs.canary.effectiveai.app/procedures/reference/nodes/value): build a typed value without running code.

```yaml value id=normalize-approval theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
schema: normalized-approval
output: normalized_approval
value:
  approved: $approval.value.approved
  note: $approval.value.note ?? ""
```

[`agent`](https://docs.canary.effectiveai.app/procedures/reference/nodes/agent): start an agent session and wait for its typed
result. Read it as `$output.value`.

```yaml agent id=summarize-claim theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
title: Summarize claim {{ $inputs.claim.claimNumber }}
instructions: |
  Summarize the claim file in one paragraph.
input:
  schema: claim-input
  value: $inputs.claim
result:
  schema: claim-summary
agent:
  preset: general-agent
output: summary
```

[`task`](https://docs.canary.effectiveai.app/procedures/reference/nodes/task): ask people to decide, and wait for an answer that
matches the result schema. Read it as `$output.value`.

```yaml task id=approve-payout theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
assignees:
  - group:claims-managers
title: Approve the payout on {{ $inputs.claim.claimNumber }}?
instructions: |
  Check the estimate against the invoice, then approve or deny.
input:
  schema: payout-input
  value: $inputs.claim
result:
  schema: payout-decision
output: payout_approval
```

## Control flow

[`choice`](https://docs.canary.effectiveai.app/procedures/reference/nodes/choice): route on a boolean or a fixed set of values.
A case can continue, jump to a section, or complete the run.

```yaml choice id=route-decision theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
on: $decision.status
cases:
  'approved': continue
  'needs-review': '#manual-review'
  'rejected': { complete: { status: rejected } }
```

[`repeat`](https://docs.canary.effectiveai.app/procedures/reference/nodes/repeat): run a section in bounded rounds until a round's
result passes a test.

```yaml repeat id=review-notice theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
body: '#review-round'
until:
  value: $review.value.verdict
  in: [approved]
max_rounds: 3
on_exhausted:
  fail: notice-not-approved
```

[`for-each`](https://docs.canary.effectiveai.app/procedures/reference/nodes/for-each): run a section once per item and collect the
results in item order.

```yaml for-each id=send-notices theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
items: $inputs.policies
item:
  name: policy
  schema: policy
body: '#send-one-notice'
concurrency: 5
collect:
  receipts:
    schema: receipt-list
    from: $mail_receipt
```

[`parallel`](https://docs.canary.effectiveai.app/procedures/reference/nodes/parallel): run independent sections at the same time and
continue when all finish.

```yaml parallel id=check-in-parallel theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
branches:
  billing: '#confirm-balance'
  underwriting: '#underwriting-review'
join: all
outputs:
  balance: { schema: balance }
  uw_decision: { schema: uw-decision }
```

## Wait and finish

[`wait`](https://docs.canary.effectiveai.app/procedures/reference/nodes/wait): pause for a duration, until an instant, until an
outside system reports a state, or until a task is answered.

```yaml wait id=let-billing-settle theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
duration: 10m
```

```yaml wait id=wait-for-effective-date theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
until: $inputs.cancel_at
```

[`complete`](https://docs.canary.effectiveai.app/procedures/reference/nodes/complete): end the run and return the declared output.

```yaml complete id=finish theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
output: result
value: $prepared
```

## Declarations

[`schema`](https://docs.canary.effectiveai.app/procedures/reference/nodes/schema): a named JSON Schema for inputs, outputs, code,
tasks and waits.

```yaml schema id=policy-ref theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
type: object
additionalProperties: false
required: [policyNumber]
properties:
  policyNumber: { type: string, minLength: 1 }
```

[`secret`](https://docs.canary.effectiveai.app/procedures/reference/nodes/secret): a named credential an effect can read. Its value
is set in Effective, never in the source.

```yaml secret id=policy-admin-token theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
format: text
```

[Functions and effects](https://docs.canary.effectiveai.app/procedures/reference/nodes/function-and-effect.md): the TypeScript a `call`
runs. A function is pure; an effect declares what it may use.

```ts function id=pro-rata-refund input=refund-input result=refund theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
({ termPremium, termDays, daysInForce }) => {
  const unearnedDays = Math.max(termDays - daysInForce, 0);
  return { amount: Math.round((termPremium * unearnedDays * 100) / termDays) / 100 };
};
```

```text theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
ts effect id=cancel-policy input=cancel-request result=cancellation uses=fetch,secrets secrets=pas-token retry=pas-write-retry timeout=1m
```

[`retry`](https://docs.canary.effectiveai.app/procedures/reference/nodes/retry): how many times a function or effect may run, and
how long to wait between attempts. Without one, code gets three attempts.

```yaml retry id=pas-write-retry theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
maximum_attempts: 5
initial_interval: 2s
backoff_coefficient: 2
maximum_interval: 30s
```

[Fragments and modules](https://docs.canary.effectiveai.app/procedures/reference/nodes/include.md): split a procedure across files, or
reuse a typed block of steps.

```yaml fragment id=intake-checks theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
fragment: './shared/intake-checks.procedure.fragment.md'
```

```yaml module id=underwriting-gate theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
module: './modules/approval-gate.procedure.module.md'
input:
  group: group:underwriting
  summary: $intake.summary
outputs:
  decision: underwriting_decision
```

## Start runs without a person

[Triggers](https://docs.canary.effectiveai.app/procedures/reference/triggers.md) start a published procedure on a schedule, when a file
lands in a folder, or when an event happens, such as an email arriving.


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