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

# Ledger API

> A programmable double-entry system of record over HTTP.

You model accounts, post balanced transactions, and read balances over a plain HTTP API. The
ledger guarantees the accounting invariants; you write the business logic. You get primitives,
not opinions, which is why a treasury startup, a marketplace, an FX desk and a SaaS company
billing its own usage all build on the same four.

> [card] [Post your first transaction](https://docs.kordio.io/ledger/quickstart.md)
>
> From credentials to a posted transaction, in four calls.

> [card] [Ledger concepts](https://docs.kordio.io/ledger/concepts.md)
>
> Double-entry, corrections, idempotency, multi-currency, value dates.

## The four primitives

### Account

A named bucket of value in one currency. You choose the `id`, which may hold letters, digits,
`_`, `:`, `.` and `-`, and the `currency`. Both are immutable once set. Accounts carry one of five
accounting types (`asset`, `liability`, `revenue`, `expense`, `equity`), which are informational
for reporting.

### Posting

One line of a transaction. It says: this account moved by this amount, in this direction
(`debit` or `credit`), in this currency, effective at this `value_date`.

### Transaction

A set of postings that move together. The ledger enforces `sum(debits) == sum(credits)` per
currency, and rejects anything that does not balance. That is the whole correctness model.
There is no validation of whether a transaction "makes sense", because the balance rule is what
makes a double-entry ledger trustworthy.

### Balance

The net of an account's postings, now or at a historical instant. Derived from postings, never
stored, and computed from `value_date` rather than insertion time.

## A balanced transaction

```json theme={"dark"}
{
  "postings": [
    { "account": "cash:usd", "amount": "1000", "currency": "USD", "direction": "debit" },
    { "account": "revenue:subscriptions", "amount": "1000", "currency": "USD", "direction": "credit" }
  ]
}
```

Monetary values cross the wire as JSON strings of integer minor units. [Parse them with a
big-integer type](https://docs.kordio.io/ledger/concepts.md#integer-minor-units), never a JS `number`.

## What makes it safe

> [card] [Append-only](https://docs.kordio.io/ledger/invariants.md)
>
> Postings are never edited. You correct with a reversal or a refund that references the original.

> [card] [Idempotent](https://docs.kordio.io/ledger/concepts.md#idempotency)
>
> Every write carries an `Idempotency-Key`. A replay returns the original transaction.

> [card] [Multi-currency](https://docs.kordio.io/ledger/concepts.md#multi-currency)
>
> Currency is first class. No code path assumes one, and the balance rule applies per currency.

> [card] [Reconciliation as a primitive](https://docs.kordio.io/ledger/reconciliation.md)
>
> Replayable runs that match an external snapshot against postings.

## Who uses this

Anyone who needs an auditable record of what money meant, separate from whatever moved it.
Kordio's own spend control is one such customer: where the projection is enabled, agent spend
arrives here as balanced postings. The ledger itself knows nothing about agents. It speaks
accounts, postings, transactions and balances, and it does not move money either.

## Next steps

> [card] [Why a ledger API](https://docs.kordio.io/ledger/why.md)
>
> Versus Postgres, a processor, accounting software, and the other ledger APIs.

> [card] [API reference](https://docs.kordio.io/ledger/api-reference/introduction.md)
>
> Every endpoint, generated from the OpenAPI spec.


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