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

# Operations

> Understand Operations as the smallest units of ledger activity in Midaz — single debit or credit entries on an Account, grouped into balanced Transactions.

An operation is the smallest unit of a transaction. Every transaction contains two or more operations (*Figure 1*). Each operation records a change in the balance of one account:

* A **Debit operation** records value that moves **out of** an account — the source.
* A **Credit operation** records value that moves **into** an account — the destination.

The effect on the stored balance depends on the balance `direction`. A normal account (the common case) shrinks on a debit and grows on a credit.

A transaction is a set of operations that must net to zero from the ledger's view. For example, a P2P payment with a fee includes:

* a **\$100 debit** from the sender's account.
* a **\$98 credit** to the recipient's account.
* a **\$2 credit** to the platform's fee account.

Midaz makes sure a transaction balances before it commits.

Operations also carry metadata such as timestamps and references to the transaction they belong to. You create a transaction through the Midaz JSON API. For each transaction, you specify a set of operations. Each operation has an amount, an asset, and a source or destination account. Midaz then checks that the operations balance before it commits them.

## Key characteristics

***

* Each operation belongs to a transaction and references a specific account and asset.
* Operations include metadata like amount, direction (debit/credit), type, timestamps, references, and more.
* Midaz creates operations when you start a transaction and fills them with the data you provide.
* Midaz validates all operations against the configured rules before it commits them to the ledger.

<Note>
  Every operation has a **`direction`** (`debit` or `credit`) and a **`type`**. The `direction` is the double-entry backbone described above. The `type` classifies the movement. Beyond the standard `CREDIT` and `DEBIT`, the `type` marks special movements:

  * `ON_HOLD` and `RELEASE` — two-phase fund reservations.
  * `OVERDRAFT` — system-generated companion operations on the internal overdraft balance.
  * `BLOCK` and `UNBLOCK` — the label applied to every operation of a transaction created through the dedicated [block and unblock endpoints](/en/midaz/transactions#blocking-and-unblocking-funds). The label overrides only the operation `type`, never its direction or amount.

  The `direction` always keeps its debit or credit meaning, regardless of `type`.
</Note>

## Operation Routes

***

With Accounting Routes, each operation connects to structured validation logic. That logic lives in [Operation Routes](/en/midaz/transaction-routing-entities).

### What is an Operation Route?

An **Operation Route** is a validation rule. It defines which account types or specific accounts a transaction component can use. It also sets the accounting direction (source or destination) and a descriptive annotation.

It works as a validation layer between transaction input and ledger structure. Each operation you submit must meet the account requirements and business rules.

<Note>
  In short: transactions contain multiple operations. Operation Routes validate each operation against the configured validation rules.
</Note>

### Operation > Operation Route relationship

When you submit a transaction to Midaz, it contains multiple **Operations**. With **Account Types and Accounting Routes enabled**, Midaz validates each operation against the rules in the Operation Routes. This makes sure that:

* The specified account matches the expected account type or specific account requirement.
* The operation direction (debit/credit) aligns with the route definition.

This adds a layer of validation, consistency, and integrity to transaction processing. It matters most for structured financial requirements.

<Danger>
  If the operations you submit do not match the configured Operation Route requirements, Midaz fails the validation and rejects the transaction.
</Danger>

## Managing Operations

***

Midaz generates operations automatically as part of a transaction flow. You cannot create an operation directly. You can query an operation as needed.

* [List Operations by Account](/en/reference/midaz/list-operations-by-account) — View all Operations linked to a specific Account.
* [Retrieve an Operation by Account](/en/reference/midaz/retrieve-an-operation-by-account) — Get details of a specific Operation for that Account.
