Skip to content

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).


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.

ConceptPurpose
AccountsChart of accounts — each account has a code, name, and currency
Journal EntriesDouble-entry records: draft → posted → voided
InvoicesBill customers: draft → sent → paid (or voided)
PaymentsRecord outgoing payments to vendors and service providers
Bank AccountsTrack bank relationships: open → active → closed
Payroll RunsProcess payroll: draft → approved → processed

Set up the accounts your entity needs. Common account codes for a startup:

Terminal window
corp finance create-account --account-code cash --account-name "Cash" --currency usd
corp finance create-account --account-code accounts_receivable --account-name "Accounts Receivable" --currency usd
corp finance create-account --account-code accounts_payable --account-name "Accounts Payable" --currency usd
corp finance create-account --account-code accrued_expenses --account-name "Accrued Expenses" --currency usd
corp finance create-account --account-code founder_capital --account-name "Founder Capital" --currency usd
corp finance create-account --account-code revenue --account-name "Revenue" --currency usd
corp finance create-account --account-code operating_expenses --account-name "Operating Expenses" --currency usd
corp finance create-account --account-code cogs --account-name "Cost of Goods Sold" --currency usd
Terminal window
curl -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.

Terminal window
# CLI
corp finance accounts
# API
curl http://localhost:8000/v1/entities/$ENTITY_ID/accounts \
-H "Authorization: Bearer $CORP_API_KEY"
Terminal window
# API
curl -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 '{}'

Every journal entry has two or more lines. Total debits must equal total credits — the API rejects unbalanced entries.

Record a $50,000 founder investment (debit cash, credit founder capital):

Terminal window
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"}
]'
Terminal window
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.

Terminal window
# Post a draft entry (makes it permanent)
corp finance post-entry $ENTRY_ID
# Void a posted entry (reversal)
corp finance void-entry $ENTRY_ID
Terminal window
# Post
curl -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 '{}'
# Void
curl -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 '{}'
Terminal window
# CLI
corp finance journal-entries
# API
curl http://localhost:8000/v1/entities/$ENTITY_ID/journal-entries \
-H "Authorization: Bearer $CORP_API_KEY"

Invoices follow a state machine: draft → sent → paid (or voided at any stage before payment).

Terminal window
corp finance create-invoice \
--customer "Acme Corp" \
--amount-cents 1500000 \
--currency usd \
--description "Q1 consulting" \
--due-date 2026-04-30
Terminal window
curl -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"
}'
Terminal window
# Send the invoice to the customer
corp finance send-invoice $INVOICE_ID
# Mark as paid
corp finance pay-invoice $INVOICE_ID
# Void (cancel) an invoice
corp finance void-invoice $INVOICE_ID
Terminal window
# Send
curl -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 '{}'
# Pay
curl -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 '{}'
# Void
curl -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 '{}'

Record outgoing payments to vendors, contractors, or service providers.

Terminal window
corp finance create-payment \
--recipient-name "AWS" \
--amount-cents 250000 \
--method ach \
--reference "Invoice #1234"
Terminal window
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"
}'
Terminal window
# CLI
corp finance payments
# API
curl http://localhost:8000/v1/entities/$ENTITY_ID/payments \
-H "Authorization: Bearer $CORP_API_KEY"

Bank accounts follow a lifecycle: open → active → closed.

Terminal window
# Open a new bank account
corp 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 account
corp finance close-bank-account $BANK_ID
Terminal window
# Create
curl -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"
}'
# Activate
curl -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 '{}'
# Close
curl -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 '{}'
Terminal window
# CLI
corp finance bank-accounts
# API
curl http://localhost:8000/v1/entities/$ENTITY_ID/bank-accounts \
-H "Authorization: Bearer $CORP_API_KEY"

Payroll follows a lifecycle: draft → approved → processed.

Terminal window
# Create a payroll run
corp 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
Terminal window
# Create
curl -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
}'
# Approve
curl -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 '{}'
# Process
curl -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 '{}'
Terminal window
# CLI
corp finance payroll-runs
# API
curl http://localhost:8000/v1/entities/$ENTITY_ID/payroll-runs \
-H "Authorization: Bearer $CORP_API_KEY"

ResourceCLI prefixAPI base path
Accountscorp finance *-account/v1/entities/{id}/accounts
Journal Entriescorp finance *-entry/v1/entities/{id}/journal-entries
Invoicescorp finance *-invoice/v1/entities/{id}/invoices
Paymentscorp finance *-payment/v1/entities/{id}/payments
Bank Accountscorp finance *-bank-account/v1/entities/{id}/bank-accounts
Payroll Runscorp finance *-payroll-run/v1/entities/{id}/payroll-runs