Skip to content

Ledger Rail

Double-entry accounting and ledger management endpoints.

Overview

The Ledger rail provides:

  • Double-entry bookkeeping
  • Real-time balance tracking
  • Account hierarchies
  • Audit trails

Powered by our high-performance ledger engine for high-performance, strongly consistent transactions.

Endpoints

Create Account

http
POST /v1/ledger/accounts
typescript
const account = await iof.ledger.createAccount({
  name: "Customer Deposits",
  type: "liability",
  currency: "USD",
  parent: "acc_parent",
});

Response:

json
{
  "id": "acc_xyz",
  "name": "Customer Deposits",
  "type": "liability",
  "currency": "USD",
  "balance": 0,
  "createdAt": "2024-01-15T10:30:00Z"
}

Get Balance

http
GET /v1/ledger/accounts/:id/balance
typescript
const balance = await iof.ledger.getBalance("acc_xyz");

Create Entry

http
POST /v1/ledger/entries
typescript
const entry = await iof.ledger.createEntry({
  description: "Murabaha payment received",
  lines: [
    { account: "acc_cash", debit: 5000 },
    { account: "acc_receivable", credit: 5000 },
  ],
  metadata: {
    contractId: "contract_123",
  },
});

Response:

json
{
  "id": "entry_abc",
  "status": "committed",
  "lines": [
    { "account": "acc_cash", "debit": 5000, "credit": 0 },
    { "account": "acc_receivable", "debit": 0, "credit": 5000 }
  ],
  "createdAt": "2024-01-15T10:30:00Z"
}

List Entries

http
GET /v1/ledger/entries
typescript
const entries = await iof.ledger.listEntries({
  account: "acc_xyz",
  startDate: "2024-01-01",
  endDate: "2024-01-31",
  limit: 100,
});

Get Statement

http
GET /v1/ledger/accounts/:id/statement
typescript
const statement = await iof.ledger.getStatement("acc_xyz", {
  startDate: "2024-01-01",
  endDate: "2024-01-31",
});

Account Types

TypeNormal BalanceDescription
assetDebitResources owned
liabilityCreditObligations owed
equityCreditOwner's stake
revenueCreditIncome earned
expenseDebitCosts incurred

Entry Status

StatusDescription
pendingAwaiting commit
committedSuccessfully recorded
voidedEntry voided

Consistency Guarantees

  • All entries are ACID compliant
  • Balances are strongly consistent
  • No double-spending possible
  • Complete audit trail

Webhooks

EventDescription
ledger.entry.createdEntry recorded
ledger.balance.changedBalance updated

Next Steps

Licensed under the Apache License 2.0