metarequired table
Key/value facts about this database. Required: schema, schema_version, as_of, data_hash, source_built_at, base_currency.
| Field | Type | Required | Meaning |
|---|---|---|---|
key | TEXT | no | |
value | TEXT | no |
Standards / billing@1
billing@1 customers, subscriptions over time, invoices and their lines, payments, refunds and MRRCustomers subscribe to prices. What each subscription bills is kept as state over time: subscription_items has one row per stretch of days during which one item kept the same price, quantity and recurring discount, and subscription_pauses holds the stretches when collection was paused. MRR and its movements are computed from that state, never from invoices alone (an invoice tells you what was billed for a period, including prorations and one-off charges; it is not the recurring value). Invoices, payments, refunds and credit notes are the money that actually moved, for payments, dunning and refund views.
Check a database or a board against it: dashremix spec check. Start a new board on it: dashremix new <id> --schema billing@1. Hash 4e8f89f2704d695b…
Required tables must exist in every database that says it follows billing@1; required fields must be filled. Columns a board adds start with x_.
metarequired tableKey/value facts about this database. Required: schema, schema_version, as_of, data_hash, source_built_at, base_currency.
| Field | Type | Required | Meaning |
|---|---|---|---|
key | TEXT | no | |
value | TEXT | no |
customersrequired tableOne customer (a person or a company that pays). Never the email address: only a hash of it.
| Field | Type | Required | Meaning |
|---|---|---|---|
customer_id | TEXT | yes | stripe:<account>:cus_... or the source's own id, namespaced |
name | TEXT | no | display name as the source has it (company or description); optional, boards blur it under privacy |
created_at | TEXTinstant | no | ISO 8601 UTC instant the customer was created at the source |
country | TEXTcountry | no | ISO 3166-1 alpha-2 billing country, when known |
currency | TEXTcurrency | no | ISO 4217 currency the customer is billed in (e.g. EUR) |
segment | TEXT | no | free label the person sets (SMB, mid-market ...); never inferred |
email_hash | TEXT | no | first 16 hex of sha256(lower(trim(email))); never the email itself |
payment_terms_days | INTEGER | no | (1.1) the customer's usual payment terms in days (30 = net 30), when the source has them |
source | TEXT | no | connector id that wrote the row: stripe | stripe-csv | billing-csv | manual |
source_ref | TEXT | no | where in the source: file:line (customers.csv:12) or the API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant of the import (left out of meta.data_hash) |
plansrequired tableA price customers subscribe to (Stripe price, older Stripe plan). unit_amount is per interval_count intervals.
| Field | Type | Required | Meaning |
|---|---|---|---|
price_id | TEXT | yes | stripe:<account>:price_... |
product | TEXT | no | product id the price belongs to |
product_name | TEXT | no | product display name (Growth) |
nickname | TEXT | no | price nickname (Growth yearly) |
interval | TEXTintervals | yes | month | year | week | day (vocab intervals) |
interval_count | INTEGER | yes | bills every interval_count intervals (3 + month = quarterly) |
unit_amount | REAL | no | major units per unit per billing period; NULL for tiered or metered prices |
currency | TEXTcurrency | yes | ISO 4217 |
usage_type | TEXTusage_types | no | licensed (quantity known upfront: counts in MRR) | metered (billed on usage: not in MRR) |
active | INTEGER | no | 1 = can still be sold |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
couponsA coupon. Only discounts that recur (duration repeating or forever) are carried onto subscription_items and so reduce MRR; a once-only coupon is a one-off on one invoice and never moves MRR.
| Field | Type | Required | Meaning |
|---|---|---|---|
coupon_id | TEXT | yes | stripe:<account>:<coupon id> |
name | TEXT | no | display name |
percent_off | REAL | no | share off, as a decimal (0.2 = 20%); NULL when amount_off is set |
amount_off | REAL | no | major units off each invoice; NULL when percent_off is set |
currency | TEXTcurrency | no | ISO 4217 of amount_off |
duration | TEXTcoupon_durations | yes | once | repeating | forever (vocab coupon_durations) |
duration_in_months | INTEGER | no | repeating: how many months it applies from when it is applied |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
subscriptionsrequired tableOne subscription of one customer. Its status is the source's current status; what it billed over time is in subscription_items, pauses in subscription_pauses. A subscription stops counting in MRR at ended_at (the day the service ended, e.g. the end of the paid period after a cancellation), not at canceled_at (the day it was cancelled).
| Field | Type | Required | Meaning |
|---|---|---|---|
subscription_id | TEXT | yes | stripe:<account>:sub_... |
customer_id | TEXT | yes | |
status | TEXTsubscription_status | yes | trialing | active | past_due | unpaid | paused | canceled | incomplete | incomplete_expired (vocab) |
created_at | TEXTinstant | no | ISO 8601 UTC instant it was created |
started_at | TEXTinstant | yes | ISO 8601 UTC instant it started (trial included) |
trial_start | TEXTinstant | no | ISO 8601 UTC instant a free trial began, if any |
trial_end | TEXTinstant | no | ISO 8601 UTC instant the trial ended (or ends); no MRR before it |
trial_converted | INTEGER | no | after a trial: 1 = its first invoice was paid (MRR from trial_end), 0 = invoiced but never paid (never MRR), NULL = no invoice seen (counts) |
cancel_at_period_end | INTEGER | no | 1 = cancelled, ends at the end of the paid period |
canceled_at | TEXTinstant | no | ISO 8601 UTC instant the cancellation was made |
ended_at | TEXTinstant | no | ISO 8601 UTC instant it stopped (no MRR from this day on) |
cancel_reason | TEXT | no | as the source gives it (cancellation_requested, payment_failed ...) |
collection | TEXTcollection_methods | no | auto (card charged) | invoice (sent to pay) |
currency | TEXTcurrency | no | ISO 4217 the subscription bills in |
confidence | TEXTconfidence | no | source (as delivered) | detected (inferred, e.g. from invoices) | manual |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
subscription_itemsrequired tableWhat a subscription billed, over time: one row per stretch during which one item kept the same price, quantity and recurring discount. A change (upgrade, seats, a coupon starting or ending) closes one row and opens the next. Dates are days: a row covers "start" <= day < "end" ("end" NULL = still running). Monthly value of a row: (COALESCE(unit_amount, plans.unit_amount) x quantity x (1 - discount_pct) - discount_amount) normalised to a month (year / 12, week x 52 / 12, day x 365 / 12, divided by interval_count), never below zero.
| Field | Type | Required | Meaning |
|---|---|---|---|
segment_id | TEXT | yes | <subscription_id>:<item>:<start>, stable for the same state |
subscription_id | TEXT | yes | |
item_id | TEXT | no | the source's subscription item id (stripe:<account>:si_...), when known |
price_id | TEXT | yes | |
quantity | REAL | yes | seats or units |
unit_amount | REAL | no | price per unit per billing period when it differs from the plan's (custom or legacy price); NULL = plans.unit_amount |
discount_pct | REAL | no | recurring share off, decimal (0.2 = 20%) |
discount_amount | REAL | no | recurring amount off each billing period, major units of the price currency |
coupon_id | TEXT | no | the coupon behind the discount, when known |
start | TEXTdate | yes | YYYY-MM-DD first day of this state |
end | TEXTdate | no | YYYY-MM-DD first day it no longer held (exclusive); NULL = still running |
confidence | TEXTconfidence | no | source | detected (rebuilt from invoices: check on the board) | manual |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id (si_..., in_... for a row rebuilt from an invoice) |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
subscription_pausesA pause in collection (Stripe pause_collection, a paused subscription). No MRR while paused: boards show it as its own movement (pause / resume), never as churn.
| Field | Type | Required | Meaning |
|---|---|---|---|
pause_id | TEXT | yes | <subscription_id>:pause:<start> |
subscription_id | TEXT | yes | |
start | TEXTdate | yes | YYYY-MM-DD first paused day |
end | TEXTdate | no | YYYY-MM-DD first day collected again (exclusive); NULL = still paused |
behavior | TEXT | no | the source's pause behaviour (void, keep_as_draft, mark_uncollectible) |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
subscription_eventsThe change log behind subscription state (the events MRR movements are made of): when a subscription started, a trial ended, an item changed, it paused, resumed, was cancelled or ended. Optional and descriptive: MRR comes from subscriptions, subscription_items and subscription_pauses; this table lets a board show why.
| Field | Type | Required | Meaning |
|---|---|---|---|
event_id | TEXT | yes | the source's event id, or <subscription_id>:<kind>:<at> |
subscription_id | TEXT | yes | |
customer_id | TEXT | no | the subscription's customer |
at | TEXT | yes | ISO 8601 UTC instant (or YYYY-MM-DD) it took effect |
kind | TEXTevent_kinds | yes | vocab event_kinds: started, trial_ended, item_changed, discount_changed, paused, resumed, cancel_scheduled, canceled, ended |
price_id | TEXT | no | the price after the change, when it is about one |
quantity | REAL | no | the quantity after the change |
detail | TEXT | no | short words from the source (never personal data) |
confidence | TEXTconfidence | no | source | detected | manual |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
invoicesAn invoice. total is what was billed after discounts and tax; amount_paid what was collected.
| Field | Type | Required | Meaning |
|---|---|---|---|
invoice_id | TEXT | yes | stripe:<account>:in_... |
number | TEXT | no | the invoice number shown to the customer |
customer_id | TEXT | no | |
subscription_id | TEXT | no | the subscription it bills, NULL for a one-off invoice |
created_at | TEXTinstant | yes | ISO 8601 UTC instant |
period_start | TEXTinstant | no | ISO 8601 UTC instant the billed period starts |
period_end | TEXTinstant | no | ISO 8601 UTC instant the billed period ends |
billing_reason | TEXT | no | subscription_create | subscription_cycle | subscription_update | manual ... |
subtotal | REAL | no | before discounts and tax |
discount | REAL | no | discounts on this invoice (positive) |
tax | REAL | no | tax on this invoice |
total | REAL | yes | billed: subtotal - discount + tax |
amount_due | REAL | no | left to collect when it was finalised |
amount_paid | REAL | no | collected |
amount_remaining | REAL | no | still open |
currency | TEXTcurrency | yes | ISO 4217 |
status | TEXTinvoice_status | yes | draft | open | paid | uncollectible | void (vocab invoice_status) |
attempt_count | INTEGER | no | payment attempts so far (more than 1 = dunning) |
paid_at | TEXTinstant | no | ISO 8601 UTC instant it was paid |
due_date | TEXTinstant | no | ISO 8601 UTC instant it is due (invoice collection) |
issue_date | TEXTdate | no | (1.1) YYYY-MM-DD date printed on the invoice, in the seller's calendar (tz) |
due_on | TEXTdate | no | (1.1) YYYY-MM-DD local due date (a date-only source keeps its date; an instant is converted in tz, never via UTC) |
sent_on | TEXTdate | no | (1.1) YYYY-MM-DD local day it was first sent; NULL = not sent or not known |
paid_on | TEXTdate | no | (1.1) YYYY-MM-DD local day it was paid in full; NULL = not paid in full or the source has no paid date |
closed_on | TEXTdate | no | (1.1) YYYY-MM-DD local day it was voided or written off |
written_off | REAL | no | (1.1) amount written off as uncollectible (positive), so total = amount_paid + amount_remaining + written_off |
source_status | TEXT | no | (1.1) the tool's own status word (sent, viewed, partial, overdue, written off ...); status keeps the five standard values |
reference | TEXT | no | (1.1) purchase order or project reference printed on the invoice |
tz | TEXT | no | (1.1) IANA time zone the local dates are in (Europe/London) |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
invoice_lines(1.1) the lines of an invoice (services, time, products, expenses, discounts). amount is the line total before tax (quantity x unit_amount less any line discount; negative for a discount line); the invoice's subtotal is their sum.
| Field | Type | Required | Meaning |
|---|---|---|---|
line_id | TEXT | yes | <invoice_id>:<position>, or the source's line id |
invoice_id | TEXT | yes | |
position | INTEGER | no | 1-based order on the invoice |
description | TEXT | no | the line text (private: boards blank it in shared copies) |
kind | TEXTline_kinds | no | service | time | product | expense | discount | other (vocab line_kinds) |
quantity | REAL | no | hours, days or units |
unit_amount | REAL | no | price per unit, major units |
amount | REAL | yes | line total before tax, major units |
tax_rate | REAL | no | decimal (0.2 = 20%) |
tax_amount | REAL | no | tax on this line |
currency | TEXTcurrency | yes | ISO 4217, the invoice's currency |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
paymentsA payment attempt (Stripe charge): succeeded, failed or pending. A failed attempt is a row too (dunning).
| Field | Type | Required | Meaning |
|---|---|---|---|
payment_id | TEXT | yes | stripe:<account>:ch_... or py_... |
invoice_id | TEXT | no | the invoice it pays |
customer_id | TEXT | no | the customer |
created_at | TEXTinstant | yes | ISO 8601 UTC instant of the attempt |
amount | REAL | yes | attempted amount, major units (positive) |
amount_refunded | REAL | no | refunded so far (refunds holds each refund) |
fee | REAL | no | processor fee, when known |
net | REAL | no | amount - fee, when known |
currency | TEXTcurrency | yes | ISO 4217 |
status | TEXTpayment_status | yes | succeeded | failed | pending (vocab payment_status) |
failure_code | TEXT | no | card_declined, insufficient_funds, expired_card ... when failed |
refunded | INTEGER | no | 1 = fully refunded |
paid_on | TEXTdate | no | (1.1) YYYY-MM-DD local day the money arrived (partial payments: one row each) |
method | TEXTpayment_methods | no | (1.1) bank_transfer | card | cash | check | other (vocab payment_methods) |
confidence | TEXTconfidence | no | (1.1) source (a payment row in the source) | detected (one payment built from an invoice's paid date and amount paid) |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
refundsA refund of a payment. Refunds and credit notes reduce revenue collected; they never move MRR (MRR is the recurring value of subscriptions, not cash).
| Field | Type | Required | Meaning |
|---|---|---|---|
refund_id | TEXT | yes | stripe:<account>:re_... |
payment_id | TEXT | no | the payment refunded |
customer_id | TEXT | no | the customer |
created_at | TEXTinstant | yes | ISO 8601 UTC instant |
amount | REAL | yes | refunded, major units (positive) |
currency | TEXTcurrency | yes | ISO 4217 |
reason | TEXT | no | duplicate | fraudulent | requested_by_customer | other |
status | TEXT | no | succeeded | pending | failed | canceled |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
credit_notesA credit note against an invoice (money owed back or credited to the customer's balance).
| Field | Type | Required | Meaning |
|---|---|---|---|
credit_note_id | TEXT | yes | stripe:<account>:cn_... |
invoice_id | TEXT | no | the invoice it credits |
customer_id | TEXT | no | the customer |
created_at | TEXTinstant | yes | ISO 8601 UTC instant |
amount | REAL | yes | credited, major units (positive) |
currency | TEXTcurrency | yes | ISO 4217 |
reason | TEXT | no | duplicate | fraudulent | order_change | product_unsatisfactory | other |
status | TEXT | no | issued | void |
source | TEXT | no | connector id |
source_ref | TEXT | no | file:line or API object id |
imported_at | TEXTinstant | no | ISO 8601 UTC instant |
fx_ratesRecorded exchange rates into the reporting currency. Boards use the latest rate on or before a date and stop (never guess) when a currency has no rate. The person records them (inputs) or a connector delivers them.
| Field | Type | Required | Meaning |
|---|---|---|---|
date | TEXTdate | yes | YYYY-MM-DD the rate applies from |
ccy | TEXTcurrency | yes | ISO 4217 currency converted |
base_ccy | TEXTcurrency | yes | ISO 4217 reporting currency |
base_per_unit | REAL | yes | units of base_ccy for one unit of ccy (EUR->USD 1.08) |
source | TEXT | no | where the rate comes from (inputs.yaml, ECB reference rate ...) |
mrr_monthlyDerived by a board's importer from the tables above (never written by a connector): each customer's MRR at each month's snapshot (the month's last day, or the as-of date for the current month), one row per customer, currency and month from the customer's first MRR month to the as-of month, zeros included (so a month-to-month diff finds churn). Trials, ended subscriptions, metered prices and paused subscriptions count 0 (paused_native keeps what the paused ones would bill).
| Field | Type | Required | Meaning |
|---|---|---|---|
customer_id | TEXT | yes | the customer |
month | TEXTmonth | yes | YYYY-MM |
currency | TEXTcurrency | yes | ISO 4217 of mrr_native |
snapshot | TEXTdate | yes | YYYY-MM-DD the state was read at |
mrr_native | REAL | yes | MRR in currency, major units, rounded to cents |
paused_native | REAL | yes | what paused subscriptions would add, in currency |
fx_rate | REAL | yes | base units per unit of currency on the snapshot day (1 for the base currency) |
mrr | REAL | yes | round(mrr_native x fx_rate, 2), in meta.base_currency |
n_subscriptions | INTEGER | yes | subscriptions counting in MRR at the snapshot |
price_ids | TEXT | no | JSON list of the prices counting at the snapshot (plan mix) |
import_issuesRows the importer or a connector could not read, or left out on purpose (platform table).
| Field | Type | Required | Meaning |
|---|---|---|---|
issue_id | TEXT | yes | stable id: <file>:<line> or <file>:<kind> |
severity | TEXTseverities | yes | info | warn | error |
kind | TEXT | yes | skipped_row | missing_column | fx_missing | metered_price | detected_history ... |
file | TEXT | no | the source file name (never its contents) |
line | INTEGER | no | 1-based line in that file, when the issue is one row |
detail | TEXT | yes | what happened |
handling | TEXT | yes | what was done about it |
source | TEXT | no | connector id |
overridesCorrections the person made to imported values, with the reason (platform table).
| Field | Type | Required | Meaning |
|---|---|---|---|
override_id | TEXT | yes | stable id |
target | TEXT | yes | table.key.column the override applies to |
field | TEXT | no | column name |
old_value | TEXT | no | value before |
new_value | TEXT | no | value after |
reason | TEXT | yes | why, in the person's words |
evidence | TEXT | no | where it comes from |
author | TEXT | no | person or assistant |
created_at | TEXT | no | ISO 8601 instant |
annotationsNotes on metrics and pages (platform table). Numbers only through {{metric:...}} placeholders.
| Field | Type | Required | Meaning |
|---|---|---|---|
annotation_id | TEXT | yes | stable id |
target | TEXT | yes | metric id or page id |
kind | TEXT | yes | note | caveat | flag | decision | open_item |
body | TEXT | yes | the note text |
author | TEXT | no | person or assistant |
source_ref | TEXT | no | where it came from |
created_at | TEXT | no | ISO 8601 instant |
data_hash | TEXT | no | hash of the cited metric values when written (stale when they change) |
status | TEXT | no | active | stale | retired |
metric_registryThe board's metrics, installed from metrics.sql by the importer (platform table).
| Field | Type | Required | Meaning |
|---|---|---|---|
metric_id | TEXT | yes | e.g. kpi.mrr |
version | INTEGER | no | the metric's own version |
unit | TEXT | no | usd | rows | pct | date | count ... |
params | TEXT | no | comma list of parameters it honours |
description | TEXT | no | the @desc line |
sql | TEXT | no | expanded SQL |
test | TEXT | no | the @test line (check that covers it) |
Shared word lists, so every board and connector means the same thing by the same word.
collection_methods2 valuesauto · invoice
confidence3 valuessource · detected · manual
coupon_durations3 valuesonce · repeating · forever
event_kinds9 valuesstarted · trial_ended · item_changed · discount_changed · paused · resumed · cancel_scheduled · canceled · ended
intervals4 valuesmonth · year · week · day
invoice_status5 valuesdraft · open · paid · uncollectible · void
line_kinds6 valuesservice · time · product · expense · discount · other
payment_methods5 valuesbank_transfer · card · cash · check · other
payment_status3 valuessucceeded · failed · pending
severities3 valuesinfo · warn · error
subscription_status8 valuestrialing · active · past_due · unpaid · paused · canceled · incomplete · incomplete_expired
usage_types2 valueslicensed · metered
invoices: local dates in the seller's calendar (issue_date, due_on, sent_on, paid_on, closed_on) with the IANA tz they are in, written_off (so total = amount_paid + amount_remaining + written_off), source_status (the tool's own word: sent, viewed, partial, overdue, written off) and reference (PO or project). status keeps its five values: a sent or partly paid invoice is open, a written-off one uncollectible; "overdue" and "partly paid" are derived from due_on and amount_paid, never stored as a status.invoice_lines (new table): one row per line, amount before tax, tax, kind (vocab line_kinds).payments: paid_on (local day the money arrived; partial payments are one row each), method (vocab payment_methods) and confidence (detected = one payment built from an invoice's paid date and amount paid).customers.payment_terms_days.invoice_lines_valid and invoice_local_dates_valid at fail (they read only what is new in 1.1, which a 1.0 database holds empty), invoice_due_after_issue, invoice_balance_consistent and payments_within_invoice at warn.customers, plans, coupons, subscriptions, subscription_items (state over time: one row per stretch with the same price, quantity and recurring discount), subscription_pauses, subscription_events, invoices, payments, refunds, credit_notes, fx_rates, the derived mrr_monthly, and the platform tables (meta, import_issues, overrides, annotations, metric_registry).ended_at, recurring discounts only, constant-currency movements with an explicit fx line, refunds and credit notes never move MRR.mrr_monthly consistent; provenance and source_built_at at warn.library/pending/stripe.json; the next dashremix sync writes library/billing.db (ids now carry the account: stripe:<account>:<id>). The pending file can be deleted.calendar@1Calendar: events and tracked timecode@1Code: pull requests, reviews, issues, deployments, releases, commits, CI, uptime, dependencies and sprintscommerce@1Commerce: orders, refunds and tax, ticket sales, point-of-sale summaries, supplier costs and partnershipscrm@1CRM: organizations, deals, activities, tickets and survey responsesfinance@2Finance: accounts, balances, transactions, budgets and recurring chargeshealth@1Health: daily body metrics, sleep sessions with stages, workouts, food eaten and body measurements from wearables, scales and health appslegal@1Legal records: entities, contracts, obligations and renewalslibrary@1Library: the books you read, are reading and want to readpeople@1People: team staffing, hiring, time off and scored surveysrental@1Rental: short-term rental listings, reservations, payouts, calendar and coststracker@1Tracker: habits, mood, activities and journal entries you log by handtravel@1Travel: days present in each countryvehicle@1Vehicle: odometer, fuel and charging, and maintenance recordsweb@1Web: search, site traffic, creator audiences, content and campaign performance