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

Operations are the building blocks of transactions. Every transaction is composed of two or more operations (*Figure 1*). Each operation records a change in the balance of one account:

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

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

If we break down a transaction, it’s a collection of operations that together must net to zero from the ledger’s perspective. For example, a P2P payment with a fee might include:

* 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 guarantees that transactions always balance before they are committed.

Operations also carry metadata such as timestamps and references to the transaction they belong to. In Midaz's API or DSL, when creating a transaction, you must specify a set of operations, each with an amount, asset, source/destination account, and so on, and the system validates that they balance out before committing.

## 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.
* Operations are created when you initiate a transaction and populated with the data you provide.
* Midaz validates all operations against configured rules before committing them to the ledger.

<Note>
  Every operation has a **`direction`** (`debit` or `credit`) — the double-entry backbone described above — and a **`type`** that classifies the movement. Beyond the standard `CREDIT` and `DEBIT`, the `type` captures special movements: `ON_HOLD` and `RELEASE` (two-phase fund reservations), `OVERDRAFT` (system-generated companion operations on the internal overdraft balance), and `BLOCK` and `UNBLOCK` (produced by the dedicated [block and unblock endpoints](/en/midaz/transactions#blocking-and-unblocking-funds)). `direction` always keeps its debit/credit meaning regardless of `type`.
</Note>

## Operation Routes

***

With Accounting Routes, the execution of an operation now connects to structured validation logic — and that's where [Operation Routes](/en/midaz/transaction-routing-entities) come in.

### What is an Operation Route?

An **Operation Route** is a validation rule that defines **which account types** or **specific accounts** should be used in a transaction component, along with the accounting direction (source/destination) and descriptive annotation.

It works as a **validation layer between transaction input and ledger structure**, ensuring each operation submitted by users meets the predefined 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 a transaction is submitted to Midaz, it contains multiple **Operations**. With **Account Types & Accounting Routes enabled**, each of these operations is validated against the rules defined in the Operation Routes to ensure:

* 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 powerful layer of validation, consistency, and integrity to transaction processing — especially when dealing with structured financial requirements.

<Danger>
  If the submitted operations don't match the configured Operation Route requirements, the transaction will fail validation and be rejected.
</Danger>

## Managing Operations

***

Midaz automatically generates operations as part of a transaction flow. You can’t create them directly, but 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.
