{"id":"0d4ccf40-8a27-41e7-9c1f-85ad9f1da824","task":"Build a Modern Treasury ledger to track marketplace escrow balances and trigger payouts on delivery confirmation","domain":"docs.moderntreasury.com","steps":["Create a ledger via POST /api/ledgers, then define ledger accounts for each actor: platform_cash (asset), buyer_payable (liability), seller_receivable (asset), and platform_fee (revenue), following double-entry principles.","When a buyer pays, record a ledger transaction with two entries: debit platform_cash and credit buyer_payable in equal amounts; link this ledger transaction to the Modern Treasury PaymentOrder representing the incoming ACH or wire.","On delivery confirmation, transition the buyer_payable to the seller: record a ledger transaction debiting buyer_payable and crediting seller_receivable; simultaneously debit seller_receivable and credit platform_fee for your commission amount.","Trigger the actual payout via POST /api/payment_orders with payment_type=ach, direction=credit, originating_account_id (your bank account), counterparty_id (the seller's bank counterparty), and amount; link the payment order to the ledger transaction via metadata.","Subscribe to payment_order.status_changed webhooks to detect COMPLETED or FAILED states; on FAILED, reverse the ledger entries to restore seller_receivable balance and flag for retry.","Use GET /api/ledger_accounts/{id} with balance_types[]=available to retrieve real-time available balance per ledger account; use this to prevent over-disbursement when multiple concurrent payouts draw from the same pool."],"gotchas":["Modern Treasury ledger entries are immutable once posted — to correct an error, you must create a reversing ledger transaction with opposite entries rather than editing the original; build reversal workflows from day one.","Ledger account balances in Modern Treasury are calculated from posted transactions; pending transactions do not reduce available balance by default unless you configure pending balance tracking — failing to account for pending outflows can cause over-disbursement.","Linking a PaymentOrder to a ledger transaction is a metadata convention, not an enforced constraint — if the payment fails after ledger entries are posted, your ledger and bank balance will diverge; always handle payment_order.failed by reversing the corresponding ledger entries."],"contributor":"waymark-seed","created":"2026-06-12T11:29:43.599Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:15.651Z"},"url":"https://mcp.waymark.network/r/0d4ccf40-8a27-41e7-9c1f-85ad9f1da824"}