Skip to main content
An account statement starts in the ledger. Build an account statement shows how to read the operations of an account from Midaz. This guide adds one step: for each transaction of the statement, you ask System Facts for the facts of that transaction. The ledger stays the source of the statement. Facts add detail to a row. A row without facts is still a correct row.

Before you start


Which transactions have facts


System Facts records a Midaz fact when a transaction reaches APPROVED. The fact type is midaz.transaction_committed. System Facts records the fact after Midaz publishes the event of the transaction, so a lookup made right after the transaction can find nothing yet. A transaction whose event Midaz did not publish has no fact, for example a transaction posted while event publication was off.

Find the facts of each transaction


1

Read the operations of the account

Use List Operations by Account to read the statement period. Each operation carries transactionId, organizationId and ledgerId.One transaction can write more than one operation on the same account. Collect each transactionId once.
2

Find the flow of each transaction

Call Find the flow of a reference with the reference type lerian.midaz.transaction_id. Send the organizationId and the ledgerId of the operation as scope keys.
Follow these rules:
  • Send the transaction id exactly as Midaz returns it. System Facts compares the value character by character, and an upper-case copy of the id does not match.
  • Send both scope keys on every lookup.
  • Send no query parameter other than the two scope keys and the parameters that the operation lists. System Facts reads an unknown parameter as a scope key, and the lookup then answers 404.
3

Read the facts of the flow

The response is the flow that holds the facts of the transaction. facts.items lists the facts in the order of occurredAt.This example is a Pix received through Pix JD. The flow holds the Midaz fact and the Pix JD fact.
A flow can hold the facts of more than one Midaz transaction. Use only the facts that carry the id that you looked up in a lerian.midaz.transaction_id reference.
4

Add the detail to the statement row

Take from the facts the detail that the ledger operation does not carry.The contract of each fact type defines the fields of its facts. Read it with Read a contract version.

Protected values in the facts


The contracts of these facts protect personal values. A caller that holds facts:reveal reads an encrypted field in clear form, and protectedFields then shows protected: false for that field. Any other caller reads a mask. A masked field never comes back in clear form. An application credential created for System Facts holds facts:reveal. Your application therefore reads names, accounts and Pix keys in clear form. Handle the facts as personal data.

When the lookup does not answer 200


A 404 does not mean that the transaction is missing from the ledger. See Which transactions have facts. The error list describes every code.

Reverted transactions


A revert appears on the statement as the operations of a new transaction. Look up the id of that new transaction: the fact of the revert carries that id as its reference, not the id of the original transaction. A fact with action: revert names the transaction that it reverts in data.parentTransactionId.

Read fewer facts


  • Filter. Send type or namespace to read only some facts of the flow, for example type=pix.transaction_settled. Each parameter takes a comma-separated list.
  • Page. A page holds 100 facts by default, and factsLimit takes 1 to 500. When the response carries facts.nextCursor, send it as factsCursor with the same filters to read the next page.