Skip to main content
After you read this page, you can write the frame of any rule document: its variables, its global settings, its rules, and the YAML scalars inside them.

Top level

A document is one YAML mapping. These are the only keys it accepts: The document must have the key rules, the key agent_envelope, or both. If it has neither, it is refused with DslDocument must contain at least one of 'rules' or 'agent_envelope'. This check looks at the key, not at the number of rules:
  • rules: {} is valid. It means “run nothing”. Commit it to stop every rule of the account and keep the permission in place. An erc20_allow account needs global.fees_method in this document too.
  • A bare rules: with no value is a YAML null. It is refused with expected a mapping; got null.
Any other top-level key is refused with unknown field '<key>' in document.
The commit of a document with rules: {} retires every rule of the account. The engine keeps only the new empty document. Keep your own copy of the rules before you replace them.

variables

variables gives a name to an address or to an IBAN, so that the rules can refer to it as $name.
Address positions: incoming_tx.account, incoming_tx.from, outgoing_tx.account, outgoing_tx.to, send_one.to, the to of each send_batch recipient, each entry of global.recipient_allowlist, and agent_envelope.to and agent_envelope.recipient_allowlist. IBAN positions: off_ramp.to.iban and each entry of global.iban_allowlist. A $name in a value expression, such as value: "$budget", is refused. A variable never holds an amount. See Values.

global

global holds settings for the full document. Every key is optional. An unknown key is refused with unknown field '<key>' in global constraints.
The three allowlists are described in full on Limits. An empty list is refused, for example global.token_allowlist must not be empty. Omit the key to set no limit.

fees_method

Without fees_method, the fees are paid in the native coin of the network. The fee token must be the native coin or a dollar stablecoin of the network. Another token is refused at staging with fee token <TOKEN> is not allowed on this chain; use the native coin or a dollar stablecoin. Two more rules apply:
  • If global.token_allowlist is present, it must contain the fee token. This includes the native coin when you omit fees_method. Otherwise the document is refused with global.token_allowlist does not contain fee token <TOKEN>.
  • An erc20_allow account must set fees_method, and the token must not be the native coin. The adapter of that account can pull only ERC-20 tokens. See what each account kind accepts.
The fee amounts and terms are on Fees.

notification_email

notification_email is the only inbox of the document. Every notify action of every rule sends its email there. The rule language does not check the address syntax. An address that has a non-ASCII character, a space inside it, or one of the characters <, >, ,, ; or " can never match a verified address. The engine reads the address when it adopts the document. It does not read it again when a rule fires. If the owner verifies a different address later, the mail goes to the old address until a new document is committed. A new document that still names the old address is refused.
Do not put an address in notification_email that the owner did not verify. The stage refuses the document. The owner verifies an inbox through a sign-in that names the domain of the Anafi dapp, app.ana.fi. An integration on another domain cannot complete that flow today. See Notification email.
The SDK function documentWithNotificationEmail(yaml, canonicalEmail) returns the document with global.notification_email set to a canonical address. See Notification email in the SDK.

rules

rules is a mapping. Each key is a rule name, and each value is a rule. A document can hold at most 32 rules. More are refused with document defines <count> rules; at most 32 are allowed.
Any other key is refused with unknown field '<key>' in rule. An error inside a rule names the rule: rule '<name>': <error>.

Rule names and identity

The engine identifies a rule by its name and by the full content of its trigger. When you commit a new document, the engine compares it with the current one:
Do not rename a rule to edit it. Keep every rule name that a document already has. A rename retires the rule and starts a different one.

enabled

enabled accepts a YAML boolean (true, false and their capitalized forms) or the exact texts "true" and "false". A disabled rule stays in the document and in the commitment. It does not fire. Commit the document again with enabled: true to fire it again.

start and expiry

start and expiry are RFC 3339 instants with a date, a time and an offset, for example "2027-01-01T00:00:00Z" or "2027-01-01T09:00:00+01:00". A bare date such as "2027-01-01" is refused with bad ISO-8601 timestamp '2027-01-01'. Neither bound removes the rule. A rule after its expiry stays in the document and fires again if a later commit moves expiry.

agent_envelope

agent_envelope declares limits for an agent key that spends from the account. The engine accepts it and enforces none of its fields. No fee, no transfer and no check comes from it.
Do not rely on agent_envelope to limit an agent. Put each automation that must run in a rule. Put each limit that must hold on chain in the permission of the adapter. See Limits.
The parser checks the shape of each field: the addresses, the token symbols, the amounts and the instant. Any other key is refused with unknown field '<key>' in agent_envelope.

YAML scalar rules

The engine reads the document with a YAML 1.2 parser. A plain scalar, without quotes, can become a number or a boolean. These rules prevent surprises: Comments, blank lines, indentation width, flow style ({ ... }, [ ... ]) and block style are all valid. They do not change what the engine reads. They do change the bytes of the document, and so the commitment.

Size limits

The engine checks these limits before it parses the YAML: The deepest valid document nests 7 levels: the document, rules, a rule, actions, an action, recipients, and a recipient. Other limits apply to parts of the document: