Skip to main content
Every transaction in the Idem Ledger follows the principles of double-entry bookkeeping: every debit must be matched by an equal credit, and the ledger will reject any request where the lines do not balance. This guide walks you through constructing and posting a valid transaction — whether you are recording a fiat rail transfer or settling an on-chain stablecoin movement.

Prerequisites

Before you post your first transaction, make sure you have the following in place:
  • An API key with the TRANSACTIONS_WRITE and ACCOUNTS_READ scopes granted.
  • At least two accounts already created in the ledger (one to debit, one to credit).
  • The account UUIDs for the accounts you want to use in your transaction lines.

Post a transaction

Each request to POST /api/v1/transactions must include an Idempotency-Key header and a body containing at least two journal lines. The lines array accepts between 2 and 1 000 entries per request.
Use OnChainEntryDto when recording a stablecoin transfer that has already occurred or is expected on-chain. Provide the transaction hash, block number, wallet address, and token contract so the ledger can correlate the entry against settlement expectations.

Idempotency

Every POST /api/v1/transactions request requires an Idempotency-Key header containing a unique string of up to 255 characters. The idempotency key protects you against duplicate transactions when a network timeout or server error forces you to retry a request. The rules are straightforward:
  • If your request succeeds and you send the same key again, the API returns the original committed transaction without creating a new one.
  • If a request with a given key is still in progress when you retry, the API returns 409 Conflict — back off and retry after a short delay.
  • If your request fails with a client error (4xx), the key is not consumed, so you can correct the body and resubmit with the same key.
Generate deterministic idempotency keys from your internal identifiers — for example, combine your order ID with a fixed prefix: txn-ORD-9921. This way, even if your application restarts before it persists the response, you will always produce the same key and can safely retry without creating a duplicate ledger entry.

Transaction metadata

The metadata field accepts a flat object of string key-value pairs. Use it to attach your own business context to a transaction — such as an order ID, customer reference, or processing region — without embedding that information in the journal line descriptions.
Metadata is stored alongside the transaction and returned in read responses, but it does not affect ledger logic. Keys and values must both be strings.

Error reference