Preview. Stack v4.0 has not been released, and what is documented here can still change before it does. The current release is v3.2, which covers this as Working with the Ledger.Go to v3.2
Ledger

Write Transactions

Create, retry, reuse, and correct Ledger transactions.

A transaction records an immutable set of postings. Start with explicit postings when your application already knows every movement. Use Numscript when Ledger must resolve routing, balances, or splits at execution time.

Every production write should carry an idempotency key. Add a transaction reference — a business identifier Ledger keeps unique for the life of the ledger — when the operation already has one.