Before you start
- Your deployment runs System Facts with its worker, and Midaz and Pix JD publish their events. See Where facts come from.
- Your application has an application credential for System Facts. See Machine-to-machine access.
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 Follow these rules:
lerian.midaz.transaction_id. Send the organizationId and the ledgerId of the operation as scope keys.- 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. 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
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.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
typeornamespaceto read only some facts of the flow, for exampletype=pix.transaction_settled. Each parameter takes a comma-separated list. - Page. A page holds 100 facts by default, and
factsLimittakes 1 to 500. When the response carriesfacts.nextCursor, send it asfactsCursorwith the same filters to read the next page.

