Treasury & Finance Guide
A practical walkthrough of the treasury domain: chart of accounts, double-entry journal entries, invoicing, payments, bank accounts, and payroll.
All monetary amounts are in whole cents (e.g., $50,000.00 = 5000000).
Overview
Section titled “Overview”The treasury domain implements a double-entry general ledger (GL) with supporting workflows for invoicing customers, recording payments, managing bank accounts, and running payroll. Every financial mutation is tracked as a journal entry with balanced debits and credits.
| Concept | Purpose |
|---|---|
| Accounts | Chart of accounts — each account has a code, name, and currency |
| Journal Entries | Double-entry records: draft → posted → voided |
| Invoices | Bill customers: draft → sent → paid (or voided) |
| Payments | Record outgoing payments to vendors and service providers |
| Bank Accounts | Track bank relationships: open → active → closed |
| Payroll Runs | Process payroll: draft → approved → processed |
1. Chart of Accounts
Section titled “1. Chart of Accounts”Set up the accounts your entity needs. Common account codes for a startup:
corp finance create-account --account-code cash --account-name "Cash" --currency usdcorp finance create-account --account-code accounts_receivable --account-name "Accounts Receivable" --currency usdcorp finance create-account --account-code accounts_payable --account-name "Accounts Payable" --currency usdcorp finance create-account --account-code accrued_expenses --account-name "Accrued Expenses" --currency usdcorp finance create-account --account-code founder_capital --account-name "Founder Capital" --currency usdcorp finance create-account --account-code revenue --account-name "Revenue" --currency usdcorp finance create-account --account-code operating_expenses --account-name "Operating Expenses" --currency usdcorp finance create-account --account-code cogs --account-name "Cost of Goods Sold" --currency usdcurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/accounts \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "account_code": "cash", "account_name": "Cash", "currency": "usd" }'Repeat for each account code. Save the returned account_id values — you’ll reference them in journal entry lines.
List accounts
Section titled “List accounts”# CLIcorp finance accounts
# APIcurl http://localhost:8000/v1/entities/$ENTITY_ID/accounts \ -H "Authorization: Bearer $CORP_API_KEY"Deactivate an account
Section titled “Deactivate an account”# APIcurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/accounts/$ACCOUNT_ID/deactivate \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'2. Journal Entries (Double-Entry)
Section titled “2. Journal Entries (Double-Entry)”Every journal entry has two or more lines. Total debits must equal total credits — the API rejects unbalanced entries.
Create a journal entry
Section titled “Create a journal entry”Record a $50,000 founder investment (debit cash, credit founder capital):
corp finance create-entry \ --date 2026-01-15 \ --description "Founder investment" \ --lines '[ {"account_id": "'$CASH_ACCOUNT_ID'", "amount_cents": 5000000, "side": "debit"}, {"account_id": "'$FOUNDER_CAPITAL_ACCOUNT_ID'", "amount_cents": 5000000, "side": "credit"} ]'curl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/journal-entries \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "date": "2026-01-15", "description": "Founder investment", "lines": [ {"account_id": "'$CASH_ACCOUNT_ID'", "amount_cents": 5000000, "side": "debit"}, {"account_id": "'$FOUNDER_CAPITAL_ACCOUNT_ID'", "amount_cents": 5000000, "side": "credit"} ] }'Entry lifecycle: draft → posted → voided
Section titled “Entry lifecycle: draft → posted → voided”Journal entries start as draft. Post them to commit to the ledger, or void them to cancel.
# Post a draft entry (makes it permanent)corp finance post-entry $ENTRY_ID
# Void a posted entry (reversal)corp finance void-entry $ENTRY_IDAPI — post and void
Section titled “API — post and void”# Postcurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/journal-entries/$ENTRY_ID/post \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'
# Voidcurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/journal-entries/$ENTRY_ID/void \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'List journal entries
Section titled “List journal entries”# CLIcorp finance journal-entries
# APIcurl http://localhost:8000/v1/entities/$ENTITY_ID/journal-entries \ -H "Authorization: Bearer $CORP_API_KEY"3. Invoicing
Section titled “3. Invoicing”Invoices follow a state machine: draft → sent → paid (or voided at any stage before payment).
Create an invoice
Section titled “Create an invoice”corp finance create-invoice \ --customer "Acme Corp" \ --amount-cents 1500000 \ --currency usd \ --description "Q1 consulting" \ --due-date 2026-04-30curl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/invoices \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customer": "Acme Corp", "email": "[email protected]", "amount_cents": 1500000, "currency": "usd", "description": "Q1 consulting", "due_date": "2026-04-30" }'Send, pay, and void
Section titled “Send, pay, and void”# Send the invoice to the customercorp finance send-invoice $INVOICE_ID
# Mark as paidcorp finance pay-invoice $INVOICE_ID
# Void (cancel) an invoicecorp finance void-invoice $INVOICE_IDAPI — invoice transitions
Section titled “API — invoice transitions”# Sendcurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/invoices/$INVOICE_ID/send \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'
# Paycurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/invoices/$INVOICE_ID/pay \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'
# Voidcurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/invoices/$INVOICE_ID/void \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'4. Payments
Section titled “4. Payments”Record outgoing payments to vendors, contractors, or service providers.
corp finance create-payment \ --recipient-name "AWS" \ --amount-cents 250000 \ --method ach \ --reference "Invoice #1234"curl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/payments \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "recipient_name": "AWS", "amount_cents": 250000, "method": "ach", "reference": "Invoice #1234" }'List payments
Section titled “List payments”# CLIcorp finance payments
# APIcurl http://localhost:8000/v1/entities/$ENTITY_ID/payments \ -H "Authorization: Bearer $CORP_API_KEY"5. Bank Accounts
Section titled “5. Bank Accounts”Bank accounts follow a lifecycle: open → active → closed.
# Open a new bank accountcorp finance create-bank-account \ --bank-name "Silicon Valley Bank" \ --account-type checking \ --currency usd
# Activate (after bank confirms the account)corp finance activate-bank-account $BANK_ID
# Close the accountcorp finance close-bank-account $BANK_ID# Createcurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/bank-accounts \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "bank_name": "Silicon Valley Bank", "account_type": "checking", "currency": "usd" }'
# Activatecurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/bank-accounts/$BANK_ID/activate \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'
# Closecurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/bank-accounts/$BANK_ID/close \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'List bank accounts
Section titled “List bank accounts”# CLIcorp finance bank-accounts
# APIcurl http://localhost:8000/v1/entities/$ENTITY_ID/bank-accounts \ -H "Authorization: Bearer $CORP_API_KEY"6. Payroll Runs
Section titled “6. Payroll Runs”Payroll follows a lifecycle: draft → approved → processed.
# Create a payroll runcorp finance create-payroll-run \ --pay-date 2026-03-31 \ --period-start 2026-03-01 \ --period-end 2026-03-31 \ --total-gross-cents 2500000
# Approve (manager sign-off)corp finance approve-payroll-run $RUN_ID
# Process (disburse funds)corp finance process-payroll-run $RUN_ID# Createcurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/payroll-runs \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "pay_date": "2026-03-31", "period_start": "2026-03-01", "period_end": "2026-03-31", "total_gross_cents": 2500000 }'
# Approvecurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/payroll-runs/$RUN_ID/approve \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'
# Processcurl -X POST http://localhost:8000/v1/entities/$ENTITY_ID/payroll-runs/$RUN_ID/process \ -H "Authorization: Bearer $CORP_API_KEY" \ -H "Content-Type: application/json" \ -d '{}'List payroll runs
Section titled “List payroll runs”# CLIcorp finance payroll-runs
# APIcurl http://localhost:8000/v1/entities/$ENTITY_ID/payroll-runs \ -H "Authorization: Bearer $CORP_API_KEY"Summary
Section titled “Summary”| Resource | CLI prefix | API base path |
|---|---|---|
| Accounts | corp finance *-account | /v1/entities/{id}/accounts |
| Journal Entries | corp finance *-entry | /v1/entities/{id}/journal-entries |
| Invoices | corp finance *-invoice | /v1/entities/{id}/invoices |
| Payments | corp finance *-payment | /v1/entities/{id}/payments |
| Bank Accounts | corp finance *-bank-account | /v1/entities/{id}/bank-accounts |
| Payroll Runs | corp finance *-payroll-run | /v1/entities/{id}/payroll-runs |