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

# Actions

> Every action type of the rule language, with each field, its type, its meaning, and where it runs.

After you read this page, you can write the actions of a rule and know on which network and for which account kind each action runs.

An action is one item of the `actions` list of a rule. Its `type` field selects one of five types:

| `type` | What it does | Moves funds |
| - | - | - |
| [`send_one`](#send_one) | Pays one address. | yes |
| [`send_batch`](#send_batch) | Pays a list of addresses, all or nothing. | yes |
| [`exchange`](#exchange) | Swaps one token for another inside the account. | yes |
| [`notify`](#notify) | Sends an email. | no |
| [`off_ramp`](#off_ramp) | Pays euros to a bank account from EURe. | yes |

Each type accepts only its own fields. Another field is refused with `unknown field '<key>' in <type> action`, for example `unknown field 'slippage' in exchange action`. An unknown `type` is refused with `unknown action type '<value>'`.

## Where each action runs

| Action | `polygon` | `xlayer` | `polygon-amoy` | `safe_module` | `erc20_allow` |
| - | - | - | - | - | - |
| `send_one` | yes | yes | yes | yes | ERC-20 tokens only |
| `send_batch` | yes | yes | yes | yes | ERC-20 tokens only |
| `exchange` | yes | yes | no | yes | ERC-20 tokens only, if the adapter runs swaps |
| `notify` | yes | yes | yes | yes | yes |
| `off_ramp` | no | no | yes | yes | no |

A "no" in this table is a refusal at staging. The texts are on [Validation](https://docs.ana.fi/rules/validation.md#network-refusals).

## How actions run

* The actions of one rule run in list order.
* Each action runs on its own. A failed action does not stop the next action of the same rule.
* One `send_batch` is all or nothing. If one of its transfers fails, none of them happens.
* Rules fire independently. The engine does not join two rules into one transaction.
* Rules with the same trigger fire in document order.
* An action of one rule does not fire another rule of the same account. The engine skips the transactions that it made for the account. See [what does not count as a transfer](https://docs.ana.fi/rules/triggers.md#what-does-not-count-as-a-transfer).

Each payment goes through the adapter of the account. The checks of each adapter are on [Contracts overview](https://docs.ana.fi/contracts/overview.md) and [Redeem](https://docs.ana.fi/contracts/redeem.md). The status of each fire is on [Activity](https://docs.ana.fi/concepts/activity.md).

## send\_one

Pays one address.

| Field | Type | Required | Meaning |
| - | - | - | - |
| `type` | text | yes | `send_one` |
| `to` | address | yes | The recipient: `"0x"` and 40 hex characters, or `"$name"`. |
| `value` | value expression | yes | The amount and the token. See [Values](https://docs.ana.fi/rules/values.md). |

Rules:

* `value` must be an amount of a token, or `trigger.value` in a transfer rule. A bare percent or number is refused, for example `send_one value must be a token amount; got percentage`.
* `to` must be on `global.recipient_allowlist`, if the list is present.
* Every token in `value` must be on `global.token_allowlist`, if the list is present.
* The stage refuses a `to` that is the account itself: `rule '<rule>': This is your own Anafi account. Choose another destination.`
* The stage refuses the zero address: `rule '<rule>': This is the zero address. Funds sent there are lost. Choose another destination.`
* The value can be the native coin, such as `"1 POL"`, for a `safe_module` account. An `erc20_allow` account can send only ERC-20 tokens.

```yaml theme={null}
# Pay 1500 USDC to the landlord.
- type: send_one
  to: "$landlord"
  value: "1500 USDC"
```

```yaml theme={null}
# In an incoming_tx rule: forward 90% of the payment, at most 500 USDC.
- type: send_one
  to: "$savings"
  value: "min(trigger.value * 90%, 500 USDC)"
```

## send\_batch

Pays a list of addresses in one transaction, all or nothing.

| Field | Type | Required | Meaning |
| - | - | - | - |
| `type` | text | yes | `send_batch` |
| `recipients` | list, 1 to 24 items | yes | One item per payment. |

Each item of `recipients`:

| Field | Type | Required | Meaning |
| - | - | - | - |
| `to` | address | yes | The recipient. |
| `value` | value expression | yes | The amount and the token for this recipient. |

Rules:

* Each item has its own `value`. There is no shared `value` and no `share` field. To split an amount, write a percent of `trigger.value` in each item.
* The language does not check that the percents add up to 100%. The rest stays in the account.
* The batch settles in one on-chain transaction. If the account does not hold enough for every item, or one transfer reverts, no item is paid.
* An empty list is refused with `send_batch recipients must not be empty`.
* The stage refuses more than 24 items: `rule '<rule>': send_batch has <count> recipients, but this chain's limit is 24`.
* Each `to` and each `value` follows the rules of [`send_one`](#send_one).

```yaml theme={null}
# Pay three bills on one schedule.
- type: send_batch
  recipients:
    - { to: "$landlord", value: "1500 USDC" }
    - { to: "$utilities", value: "150 USDC" }
    - { to: "$gym", value: "50 USDC" }
```

```yaml theme={null}
# In an incoming_tx rule: split each payment 50/30/20.
- type: send_batch
  recipients:
    - { to: "$cold_wallet", value: "trigger.value * 50%" }
    - { to: "$brokerage", value: "trigger.value * 30%" }
    - { to: "$spending", value: "trigger.value * 20%" }
```

## exchange

Swaps one token for another. The bought tokens stay in the account.

| Field | Type | Required | Meaning |
| - | - | - | - |
| `type` | text | yes | `exchange` |
| `in` | value expression | yes | The amount to sell, in the sold token. |
| `out` | token symbol | yes | The token to buy. |

Rules:

* `in` and `out` must be different tokens. A swap of a token to itself is refused, for example ``exchange `in` and `out` are both USDC; a swap must name two different tokens``.
* `in` must be an amount of a token, or `trigger.value` in a transfer rule.
* Both tokens must be on `global.token_allowlist`, if the list is present.
* Both tokens must have a contract on the network, or be the native coin. The [token tables](https://docs.ana.fi/rules/values.md#tokens-per-network) list them.
* `in` must not be zero. `"0 USDC"` validates, and every fire refuses it.
* There is no slippage field, no price field and no route field. The engine gets a price for each fire and sets the minimum output of the swap. The on-chain checks are on [Swap executor](https://docs.ana.fi/contracts/swap-executor.md).
* The swap runs as one on-chain transaction. Either the full swap happens, or nothing happens.

Where it runs:

* `polygon` and `xlayer` have a swap venue. `polygon-amoy` has none. The stage refuses every `exchange` there: ``rule '<rule>': network polygon-amoy has no swap aggregator, so an `exchange` could never execute here``.
* A `safe_module` account can sell or buy the native coin.
* An `erc20_allow` account cannot sell or buy the native coin. It can sell only a token that the document names: a literal amount, or `trigger.value` under a range. Its adapter must also run swaps. See [account kind refusals](https://docs.ana.fi/rules/validation.md#account-kind-refusals).

```yaml theme={null}
# Buy WETH for 100 USDC.
- type: exchange
  in: "100 USDC"
  out: WETH
```

```yaml theme={null}
# In an incoming_tx rule with value "10.. USDT0": convert each USDT0 arrival to USDC.
- type: exchange
  in: "trigger.value"
  out: USDC
```

## notify

Sends an email to the inbox of the document.

| Field | Type | Required | Meaning |
| - | - | - | - |
| `type` | text | yes | `notify` |
| `channel` | text | yes | `email`, `push` or `telegram`. |
| `message` | text | yes | The body of the email. |

Rules:

* Email is the only delivery. The engine accepts `push` and `telegram`, ignores the value, and sends an email. Write `channel: email`.
* Another channel, such as `sms`, is refused with `unknown notify channel 'sms'`.
* The email goes to `global.notification_email`. There is no per-action address. See [notification\_email](https://docs.ana.fi/rules/document.md#notification_email).
* Without `global.notification_email`, the action fires and delivers nothing. The engine gives a warning for each such rule.
* The engine sends `message` as written. It does not replace `${...}` or any other placeholder.
* `notify` moves no funds. It is valid in each rule, on each network, for each account kind.

```yaml theme={null}
# Tell the owner that a salary arrived.
- type: notify
  channel: email
  message: "Salary received"
```

```yaml theme={null}
# After a swap action in the same rule.
- type: notify
  channel: email
  message: "Weekly WETH purchase sent to the swap venue"
```

## off\_ramp

Pays euros to a bank account. The engine burns EURe from the account through Monerium, and Monerium pays the same amount in euros by SEPA transfer. No token goes to an on-chain address.

| Field | Type | Required | Meaning |
| - | - | - | - |
| `type` | text | yes | `off_ramp` |
| `provider` | text | yes | `monerium`. Another value is refused with `unknown off_ramp provider '<value>'`. |
| `value` | value expression | yes | The amount, in `EURe`. |
| `to` | mapping | yes | The bank account. See below. |
| `memo` | text | no | The text on the bank statement of the recipient: 5 to 140 characters. |

The `to` mapping:

| Field | Type | Required | Meaning |
| - | - | - | - |
| `iban` | IBAN | yes | A canonical IBAN or `"$name"`. |
| `first_name` | text | for a person | The first name as the bank knows it. |
| `last_name` | text | for a person | The last name as the bank knows it. |
| `company_name` | text | for a company | The registered company name. |
| `country` | text | yes | Two uppercase letters, ISO 3166-1 alpha-2, for example `"DE"`. |

Write a person as `first_name` and `last_name`, or a company as `company_name`. Never write both. No name may be blank.

| Problem | Refusal text |
| - | - |
| No holder name | ``off_ramp recipient needs the account holder: `first_name` and `last_name` for a person, or `company_name` for a business`` |
| Person and company | ``off_ramp recipient names both a person and a `company_name`; write exactly one holder`` |
| Only one of the two person names | `` off_ramp recipient names a person by half; write both `first_name` and `last_name` `` |
| A blank name | ``off_ramp recipient's `first_name` must not be blank``, and the same for `last_name` and `company_name` |
| Lowercase country | `bad country (expected an ISO 3166-1 alpha-2 code such as DE) 'de'` |
| IBAN with spaces or lowercase | `bad IBAN (expected an uppercase IBAN without spaces, or a $variable reference) '<value>'` |
| Memo too short or too long | `off_ramp memo must be 5 to 140 characters, at least 5 of them past any leading or trailing spaces` |

The IBAN rules:

* Write it in canonical form: uppercase letters and digits, no spaces, for example `"DE89370400440532013000"`.
* It has 15 to 34 characters: two letters, two check digits, then letters and digits.
* The check digits must be correct (ISO 13616, remainder 1 under modulo 97).
* The language does not check that the account exists.

The amount rules:

* `value` must be an amount of `EURe`. Another token is refused with `off_ramp value must be an amount of EURe, the token its provider redeems; got amount of USDC`.
* A literal amount must name whole cents. `"1.005 EURe"` is refused with `off_ramp value '1.005 EURe' names a fraction of a cent, which no bank transfer can carry`.
* An amount computed at the fire is rounded down to whole cents. An amount under one cent is not paid.
* `trigger.value` must have the token `EURe`. Use a transfer trigger with an `EURe` range, such as `value: "100.. EURe"`. Without a range, `trigger.value` is refused with `off_ramp value must be an amount of EURe, the token its provider redeems; got polymorphic`.
* The IBAN must be on `global.iban_allowlist`, if the list is present.

Where it runs:

* Only on `polygon-amoy`. Another network refuses it at staging: `rule '<rule>': network <network> carries no fiat rail, so an off_ramp through monerium could never execute here`.
* Only for a `safe_module` account. An `erc20_allow` account refuses it: `rule '<rule>' has an off_ramp, which the ERC20Allow leg does not serve`.
* The Safe must be linked to a Monerium account first.
* The Safe can keep a list of IBANs on chain, in the off-ramp policy of its fallback handler. `global.iban_allowlist` is a different list, part of the rule document. The engine checks it at staging and again at the commit. Nothing keeps the two lists equal. See [Off-ramp handler](https://docs.ana.fi/contracts/off-ramp-handler.md) and [Bank payouts](https://docs.ana.fi/flows/bank-payouts.md).

```yaml theme={null}
# Pay monthly rent to a person.
- type: off_ramp
  provider: monerium
  value: "1500 EURe"
  to:
    iban: "$landlord_iban"
    first_name: "Erika"
    last_name: "Mustermann"
    country: "DE"
  memo: "Monthly rent"
```

```yaml theme={null}
# In an incoming_tx rule with value "100.. EURe": send each arrival to a company account.
- type: off_ramp
  provider: monerium
  value: "trigger.value"
  to:
    iban: "$savings_iban"
    company_name: "Musterhaus GmbH"
    country: "GB"
  memo: "Savings sweep"
```


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