Skip to content

Data Models

BoxBilling uses 50+ SQLAlchemy models organized into logical domains. All entities use UUID primary keys (stored as String(36)) and include audit timestamps (created_at, updated_at) with timezone-aware DateTime. Monetary amounts use Numeric(12,4) for precision, with column names suffixed _cents. All tenant-scoped models include an organization_id foreign key for multi-tenancy isolation.

Organization
├── BillingEntity
├── Customer
│ ├── Subscription ──→ Plan ──→ Charge ──→ BillableMetric
│ │ ├── Invoice ──→ Fee
│ │ │ ├── Payment
│ │ │ ├── InvoiceSettlement
│ │ │ └── CreditNote ──→ CreditNoteItem
│ │ ├── DailyUsage
│ │ ├── AppliedUsageThreshold
│ │ └── UsageAlert ──→ UsageAlertTrigger
│ ├── Wallet ──→ WalletTransaction
│ ├── AppliedCoupon ──→ Coupon
│ ├── AppliedAddOn ──→ AddOn
│ ├── PaymentMethod
│ └── PaymentRequest ──→ PaymentRequestInvoice
├── Tax ──→ AppliedTax (polymorphic)
├── UsageThreshold
├── Commitment
├── Feature ──→ Entitlement
├── Integration ──→ IntegrationCustomer, IntegrationMapping, IntegrationSyncHistory
├── DunningCampaign ──→ DunningCampaignThreshold
├── WebhookEndpoint ──→ Webhook ──→ WebhookDeliveryAttempt
├── DataExport
├── AuditLog
├── Notification
├── IdempotencyRecord
├── Event
└── ApiKey

The root tenant entity. All resources are scoped to an organization.

ColumnTypeDescription
idUUIDPrimary key
nameString(255)Organization name
default_currencyString(3)Default currency (default: USD)
timezoneString(50)Default timezone (default: UTC)
hmac_keyString(255)Key used for webhook signature signing
logo_urlString(2048)Organization logo URL
portal_accent_colorString(7)Hex color for customer portal
portal_welcome_messageString(500)Portal welcome text

Supports multi-entity billing — each entity can have its own invoice numbering, address, and payment terms.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
codeString(100)Unique entity code
nameString(255)Display name
legal_nameString(255)Legal entity name
address_line1, address_line2String(255)Street address
city, state, country, zip_codeStringLocation details (country is ISO 3166 alpha-2)
tax_idString(100)Tax identification number
emailString(255)Contact email
currencyString(3)Default currency (default: USD)
timezoneString(50)Timezone (default: UTC)
document_localeString(10)Invoice locale (default: en)
invoice_prefixString(20)Invoice number prefix
next_invoice_numberIntegerNext sequential invoice number (default: 1)
invoice_grace_periodIntegerGrace period days (default: 0)
net_payment_termIntegerDays until invoice due (default: 30)
invoice_footerString(1024)Footer text on invoices
is_defaultBooleanWhether this is the default billing entity
ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
external_idString(255)Unique external identifier
nameString(255)Customer name
emailString(255)Contact email
currencyString(3)Billing currency (default: USD)
timezoneString(50)Customer timezone (default: UTC)
billing_metadataJSONCustom key-value metadata (default: {})
invoice_grace_periodIntegerOverride grace period (default: 0)
net_payment_termIntegerOverride payment term (default: 30)
billing_entity_idUUIDFK → billing_entities (optional)
ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
key_hashString(255)SHA-256 hash of the API key (unique)
key_prefixString(20)Display prefix (e.g. bxb_live_abc...)
nameString(255)Human-readable key name
statusString(50)active or revoked
expires_atDateTimeOptional expiration
last_used_atDateTimeLast successful auth
ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
codeString(255)Unique plan code
nameString(255)Display name
descriptionTextPlan description
intervalString(20)weekly, monthly, quarterly, yearly
amount_centsIntegerBase subscription fee (default: 0)
currencyString(3)Plan currency (default: USD)
trial_period_daysIntegerDefault trial length (default: 0)
ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
external_idString(255)Unique external identifier
customer_idUUIDFK → customers
plan_idUUIDFK → plans
statusString(20)pending, active, paused, canceled, terminated
billing_timeString(20)calendar or anniversary
pay_in_advanceBooleanBill at start of period (default: false)
trial_period_daysIntegerTrial duration (default: 0)
trial_ended_atDateTimeWhen trial ended
subscription_atDateTimeSubscription anchor date
previous_plan_idUUIDFK → plans — pending downgrade target
downgraded_atDateTimeWhen downgrade was scheduled
billing_entity_idUUIDFK → billing_entities (optional)
on_termination_actionString(30)generate_invoice, generate_credit_note, skip (default: generate_invoice)
started_atDateTimeActivation timestamp
ending_atDateTimeScheduled termination timestamp
canceled_atDateTimeCancellation timestamp
paused_atDateTimeWhen subscription was paused
resumed_atDateTimeWhen subscription was resumed

Minimum spend commitments attached to plans.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
plan_idUUIDFK → plans
commitment_typeString(50)minimum_commitment
amount_centsNumeric(12,4)Minimum amount
invoice_display_nameString(255)Custom display name on invoices

Feature definitions for entitlement-based access control.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
codeString(100)Unique feature code (unique per org)
nameString(255)Display name
descriptionStringFeature description
feature_typeString(20)boolean, quantity, custom

Constraint: Unique on (organization_id, code)

Links features to plans, defining what access each plan grants.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
plan_idUUIDFK → plans
feature_idUUIDFK → features
valueStringEntitlement value (e.g. true, 100)

Constraint: Unique on (plan_id, feature_id)

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
codeString(255)Unique metric code
nameString(255)Display name
descriptionTextMetric description
aggregation_typeString(20)count, sum, max, unique_count, weighted_sum, latest, custom
field_nameString(255)Event property to aggregate (for sum, max, unique_count)
recurringBooleanPersists across billing periods (default: false)
expressionTextCustom aggregation expression
rounding_functionString(10)round, ceil, floor
rounding_precisionIntegerDecimal places for rounding

Filters that segment events by property values.

ColumnTypeDescription
idUUIDPrimary key
billable_metric_idUUIDFK → billable_metrics (CASCADE)
keyString(255)Property key to filter on
valuesJSONAllowed values (default: [])

Constraint: Unique on (billable_metric_id, key)

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
transaction_idString(255)Unique idempotency key
external_customer_idString(255)Customer reference
codeString(255)Billable metric code
timestampDateTimeEvent timestamp
propertiesJSONEvent-specific data (default: {})

Indexes: external_customer_id, code, timestamp, and composite on (external_customer_id, code, timestamp)

Pre-aggregated daily usage for performance optimization.

ColumnTypeDescription
idUUIDPrimary key
subscription_idUUIDFK → subscriptions
billable_metric_idUUIDFK → billable_metrics
external_customer_idString(255)Customer reference
usage_dateDateAggregation date
usage_valueNumeric(12,4)Aggregated value (default: 0)
events_countIntegerEvent count (default: 0)

Constraint: Unique on (subscription_id, billable_metric_id, usage_date)

Triggers progressive billing invoices when cumulative usage crosses a threshold.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
plan_idUUIDFK → plans (exactly one of plan_id or subscription_id required)
subscription_idUUIDFK → subscriptions
amount_centsNumeric(12,4)Threshold amount
currencyString(3)Currency (default: USD)
recurringBooleanReset each billing period (default: false)
threshold_display_nameString(255)Display name on invoices

Constraint: Exactly one of plan_id or subscription_id must be set.

Monitors usage against a threshold and triggers notifications.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
subscription_idUUIDFK → subscriptions
billable_metric_idUUIDFK → billable_metrics
threshold_valueNumeric(12,4)Alert threshold
recurringBooleanRe-trigger each period (default: false)
nameString(255)Alert name
times_triggeredIntegerTotal trigger count (default: 0)
triggered_atDateTimeLast trigger timestamp

Records of individual alert trigger events.

ColumnTypeDescription
idUUIDPrimary key
usage_alert_idUUIDFK → usage_alerts (CASCADE)
current_usageNumeric(16,4)Usage at trigger time
threshold_valueNumeric(12,4)Threshold that was crossed
metric_codeString(255)Billable metric code
triggered_atDateTimeWhen triggered

Tracks when a subscription crosses a usage threshold, linking to the generated invoice.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
usage_threshold_idUUIDFK → usage_thresholds
subscription_idUUIDFK → subscriptions
invoice_idUUIDFK → invoices (optional)
crossed_atDateTimeWhen the threshold was crossed
lifetime_usage_amount_centsNumeric(12,4)Cumulative usage at crossing time

Links a billable metric to a plan with a pricing model.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
plan_idUUIDFK → plans (CASCADE)
billable_metric_idUUIDFK → billable_metrics
charge_modelString(30)Pricing model type
propertiesJSONModel-specific config (default: {})

Charge models: standard, graduated, volume, package, percentage, graduated_percentage, custom, dynamic

Override charge properties for specific metric filter combinations.

ColumnTypeDescription
idUUIDPrimary key
charge_idUUIDFK → charges (CASCADE)
propertiesJSONOverride pricing config (default: {})
invoice_display_nameString(255)Custom line item name

Maps a charge filter to a specific billable metric filter value.

ColumnTypeDescription
idUUIDPrimary key
charge_filter_idUUIDFK → charge_filters (CASCADE)
billable_metric_filter_idUUIDFK → billable_metric_filters (CASCADE)
valueString(255)Selected filter value

Constraint: Unique on (charge_filter_id, billable_metric_filter_id)

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
invoice_numberString(50)Unique invoice number
customer_idUUIDFK → customers
subscription_idUUIDFK → subscriptions (nullable)
billing_entity_idUUIDFK → billing_entities (nullable)
statusString(20)draft, finalized, paid, voided
invoice_typeString(30)subscription, add_on, credit, one_off, progressive_billing
billing_period_startDateTimeStart of billing period
billing_period_endDateTimeEnd of billing period
subtotal_centsNumeric(12,4)Pre-tax amount (default: 0)
tax_amount_centsNumeric(12,4)Total tax (default: 0)
total_centsNumeric(12,4)Final amount (default: 0)
prepaid_credit_amount_centsNumeric(12,4)Wallet credits applied (default: 0)
coupons_amount_centsNumeric(12,4)Coupon discounts applied (default: 0)
progressive_billing_credit_amount_centsNumeric(12,4)Progressive billing credits (default: 0)
currencyString(3)Invoice currency (default: USD)
line_itemsJSONLine item details (default: [])
due_dateDateTimePayment due date
issued_atDateTimeWhen invoice was issued
paid_atDateTimeWhen invoice was paid

Individual charge line items on an invoice.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
invoice_idUUIDFK → invoices (nullable)
charge_idUUIDFK → charges (nullable)
subscription_idUUIDFK → subscriptions (nullable)
customer_idUUIDFK → customers
commitment_idUUIDFK → commitments (nullable)
fee_typeString(20)charge, subscription, add_on, credit, commitment
amount_centsNumeric(12,4)Fee amount (default: 0)
taxes_amount_centsNumeric(12,4)Tax on this fee (default: 0)
total_amount_centsNumeric(12,4)Amount + taxes (default: 0)
unitsNumeric(12,4)Usage units (default: 0)
events_countIntegerEvents counted (default: 0)
unit_amount_centsNumeric(12,4)Per-unit price (default: 0)
payment_statusString(20)pending, succeeded, failed, refunded
descriptionString(500)Fee description
metric_codeString(255)Associated billable metric code
propertiesJSONAdditional fee properties (default: {})

Tracks how invoices are paid (multiple settlement types per invoice).

ColumnTypeDescription
idUUIDPrimary key
invoice_idUUIDFK → invoices
settlement_typeString(20)payment, credit_note, wallet_credit
source_idUUIDPolymorphic reference to payment/credit note/wallet
amount_centsNumeric(12,4)Amount settled

Index: Composite on (settlement_type, source_id)

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
numberString(50)Unique (e.g. CN-20250214-0001)
invoice_idUUIDFK → invoices
customer_idUUIDFK → customers
credit_note_typeString(20)credit, refund, offset
statusString(20)draft, finalized
credit_statusString(20)available, consumed, voided
refund_statusString(20)pending, succeeded, failed
reasonString(30)duplicated_charge, product_unsatisfactory, order_change, order_cancellation, fraudulent_charge, other
descriptionTextAdditional description
credit_amount_centsNumeric(12,4)Available credit (default: 0)
refund_amount_centsNumeric(12,4)Refund amount (default: 0)
balance_amount_centsNumeric(12,4)Remaining credit (default: 0)
total_amount_centsNumeric(12,4)Total credit note amount (default: 0)
taxes_amount_centsNumeric(12,4)Tax amount (default: 0)
currencyString(3)Currency
issued_atDateTimeWhen credit note was issued
voided_atDateTimeWhen credit note was voided
ColumnTypeDescription
idUUIDPrimary key
credit_note_idUUIDFK → credit_notes
fee_idUUIDFK → fees
amount_centsNumeric(12,4)Credited amount
ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
invoice_idUUIDFK → invoices
customer_idUUIDFK → customers
amount_centsNumeric(12,4)Payment amount
currencyString(3)Payment currency (default: USD)
statusString(20)pending, processing, succeeded, failed, refunded, canceled
providerString(50)stripe, manual, ucp, gocardless, adyen
provider_payment_idString(255)External payment reference
provider_checkout_idString(255)Provider checkout session ID
provider_checkout_urlTextCheckout redirect URL
failure_reasonTextReason for payment failure
payment_metadataJSONProvider-specific metadata (default: {})
completed_atDateTimeWhen payment completed

Stored payment methods for customers.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
customer_idUUIDFK → customers
providerString(50)stripe, gocardless, adyen
provider_payment_method_idString(255)External payment method ID
typeString(50)card, bank_account, direct_debit
is_defaultBooleanDefault payment method (default: false)
detailsJSONMethod details (last4, brand, exp, etc.) (default: {})

Manual payment requests linking multiple invoices, used by dunning campaigns.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
customer_idUUIDFK → customers
dunning_campaign_idUUIDFK → dunning_campaigns (nullable)
amount_centsNumeric(12,4)Total request amount
amount_currencyString(3)Currency
payment_statusString(20)pending (default)
payment_attemptsIntegerNumber of attempts (default: 0)
ready_for_payment_processingBooleanReady to process (default: true)

Links payment requests to invoices.

ColumnTypeDescription
idUUIDPrimary key
payment_request_idUUIDFK → payment_requests (CASCADE)
invoice_idUUIDFK → invoices
ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
customer_idUUIDFK → customers
nameString(255)Wallet name
codeString(255)Wallet code
statusString(20)active, terminated
balance_centsNumeric(12,4)Available balance (default: 0)
credits_balanceNumeric(12,4)Credit units (default: 0)
consumed_amount_centsNumeric(12,4)Total consumed in cents (default: 0)
consumed_creditsNumeric(12,4)Total consumed credits (default: 0)
rate_amountNumeric(12,4)Credits-to-cents conversion rate (default: 1)
currencyString(3)Wallet currency (default: USD)
expiration_atDateTimeOptional expiration
priorityIntegerConsumption priority — lower = first (default: 1)

Constraint: Unique on (customer_id, code)

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
wallet_idUUIDFK → wallets
customer_idUUIDFK → customers
transaction_typeString(20)inbound, outbound
transaction_statusString(20)purchased, granted, voided, invoiced (default: granted)
sourceString(20)manual, interval, threshold
statusString(20)pending, settled, failed (default: pending)
amountNumeric(12,4)Transaction amount (default: 0)
credit_amountNumeric(12,4)Credit units (default: 0)
invoice_idUUIDFK → invoices (for consumption)
ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
codeString(255)Unique coupon code
nameString(255)Display name
descriptionTextCoupon description
coupon_typeString(20)fixed_amount, percentage
amount_centsNumeric(12,4)Discount amount (for fixed_amount)
amount_currencyString(3)Currency (for fixed_amount)
percentage_rateNumeric(5,2)Discount percentage (for percentage)
frequencyString(20)once, recurring, forever
frequency_durationIntegerNumber of periods (for recurring)
reusableBooleanCan be applied to multiple customers (default: true)
expirationString(20)no_expiration, time_limit
expiration_atDateTimeExpiration date (for time_limit)
statusString(20)active, terminated

Tracks a coupon applied to a specific customer.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
coupon_idUUIDFK → coupons
customer_idUUIDFK → customers
amount_centsNumeric(12,4)Override discount amount
amount_currencyString(3)Override currency
percentage_rateNumeric(5,2)Override percentage
frequencyString(20)Applied frequency
frequency_durationIntegerTotal periods
frequency_duration_remainingIntegerRemaining periods
statusString(20)active, terminated
terminated_atDateTimeWhen terminated

One-time charges applied to customers.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
codeString(255)Unique add-on code
nameString(255)Display name
descriptionTextAdd-on description
amount_centsNumeric(12,4)Default price
amount_currencyString(3)Currency (default: USD)
invoice_display_nameString(255)Custom name on invoices

Tracks an add-on applied to a customer.

ColumnTypeDescription
idUUIDPrimary key
add_on_idUUIDFK → add_ons
customer_idUUIDFK → customers
amount_centsNumeric(12,4)Charged amount
amount_currencyString(3)Currency
ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
codeString(255)Unique tax code
nameString(255)Display name
descriptionTextTax description
rateNumeric(5,4)Tax rate (e.g. 0.0875 for 8.75%)
categoryString(100)Tax category
applied_to_organizationBooleanDefault org-wide tax (default: false)

Polymorphic association — can be applied to any entity type.

ColumnTypeDescription
idUUIDPrimary key
tax_idUUIDFK → taxes
taxable_typeString(50)Entity type (e.g. customer, plan, invoice)
taxable_idUUIDEntity ID
tax_rateNumeric(5,4)Snapshot of rate at apply time
tax_amount_centsNumeric(12,4)Calculated amount (default: 0)

Constraint: Unique on (tax_id, taxable_type, taxable_id) Index: Composite on (taxable_type, taxable_id)

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
integration_typeString(30)payment_provider, accounting, crm, tax
provider_typeString(50)stripe, gocardless, adyen, netsuite, xero, hubspot, salesforce, anrok, avalara
statusString(20)active, inactive, error
settingsJSONProvider-specific configuration (default: {})
last_sync_atDateTimeLast successful sync
error_detailsJSONError information (if status is error)

Constraint: Unique on (organization_id, provider_type) — one integration per provider per org.

Maps a BoxBilling customer to an external system customer.

ColumnTypeDescription
idUUIDPrimary key
integration_idUUIDFK → integrations (CASCADE)
customer_idUUIDFK → customers (CASCADE)
external_customer_idString(255)External system customer ID
settingsJSONCustomer-specific integration settings

Constraint: Unique on (integration_id, customer_id)

Polymorphic mapping between BoxBilling entities and external system resources.

ColumnTypeDescription
idUUIDPrimary key
integration_idUUIDFK → integrations (CASCADE)
mappable_typeString(50)Entity type
mappable_idUUIDEntity ID
external_idString(255)External resource ID
external_dataJSONCached external data
last_synced_atDateTimeLast sync timestamp

Constraint: Unique on (integration_id, mappable_type, mappable_id)

Tracks individual sync operations for auditing and debugging.

ColumnTypeDescription
idUUIDPrimary key
integration_idUUIDFK → integrations (CASCADE)
resource_typeString(50)Type of resource synced
resource_idUUIDBoxBilling resource ID
external_idString(255)External resource ID
actionString(50)Sync action performed
statusString(20)Sync result status
error_messageString(1000)Error details
detailsJSONAdditional sync data
started_atDateTimeWhen sync started
completed_atDateTimeWhen sync finished
ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
urlString(2048)Delivery URL
signature_algoString(50)Signature algorithm (default: hmac)
statusString(50)active or inactive
ColumnTypeDescription
idUUIDPrimary key
webhook_endpoint_idUUIDFK → webhook_endpoints
webhook_typeString(100)Event type (e.g. invoice.finalized)
object_typeString(50)Type of the related object
object_idUUIDID of the related object
payloadJSONEvent payload
statusString(50)pending, succeeded, failed
retriesIntegerCurrent retry count (default: 0)
max_retriesIntegerMaximum retry attempts (default: 5)
last_retried_atDateTimeLast retry timestamp
http_statusIntegerLast response status code
responseTextLast response body

Tracks individual delivery attempts for each webhook.

ColumnTypeDescription
idUUIDPrimary key
webhook_idUUIDFK → webhooks (CASCADE)
attempt_numberIntegerSequential attempt number
http_statusIntegerResponse status code
response_bodyTextResponse body
successBooleanWhether delivery succeeded (default: false)
error_messageString(1000)Error details
attempted_atDateTimeWhen attempt was made

Automated payment recovery campaigns for failed or overdue invoices.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
codeString(255)Campaign code
nameString(255)Display name
descriptionTextCampaign description
max_attemptsIntegerMaximum retry attempts (default: 3)
days_between_attemptsIntegerDays between retries (default: 3)
bcc_emailsJSONBCC recipients for dunning emails (default: [])
statusString(20)active or inactive

Currency-specific minimum amounts that trigger a dunning campaign.

ColumnTypeDescription
idUUIDPrimary key
dunning_campaign_idUUIDFK → dunning_campaigns (CASCADE)
currencyString(3)Currency code
amount_centsNumeric(12,4)Minimum amount to trigger dunning

Tracks administrative actions for compliance and debugging.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
resource_typeString(50)Type of resource affected
resource_idUUIDID of resource affected
actionString(50)Action performed (e.g. create, update, delete)
changesJSONBefore/after diff (default: {})
actor_typeString(50)Who performed the action (e.g. api_key, system)
actor_idString(255)Actor identifier
metadataJSONAdditional context

Indexes: resource_type, resource_id, action

Bulk data export jobs.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
export_typeString(30)invoices, customers, subscriptions, events, fees, credit_notes, audit_logs
statusString(20)pending, processing, completed, failed
filtersJSONExport filter criteria
file_pathString(2048)Path to exported file
record_countIntegerNumber of records exported
progressIntegerExport progress percentage
error_messageTextError details (if failed)
started_atDateTimeWhen export started
completed_atDateTimeWhen export finished

Request deduplication to prevent duplicate operations.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
idempotency_keyString(255)Client-provided idempotency key
request_methodString(10)HTTP method
request_pathString(500)Request path
response_statusIntegerCached response status
response_bodyJSONCached response body

Constraint: Unique on (organization_id, idempotency_key)

Internal notifications for organization administrators.

ColumnTypeDescription
idUUIDPrimary key
organization_idUUIDFK → organizations
categoryString(50)Notification category
titleString(255)Notification title
messageString(1000)Notification body
resource_typeString(50)Related resource type
resource_idUUIDRelated resource ID
is_readBooleanRead status (default: false)
  • UUID primary keys — stored as String(36) for SQLite compatibility, generated with uuid.uuid4()
  • Numeric(12,4) for monetary amounts — 4 decimal places of precision, column names suffixed with _cents
  • Organization isolation via organization_id foreign key on all tenant-scoped models, with ondelete="RESTRICT"
  • Polymorphic associations for AppliedTax (taxable_type/taxable_id), IntegrationMapping (mappable_type/mappable_id), InvoiceSettlement (settlement_type/source_id), and AuditLog (resource_type/resource_id)
  • Status-based lifecycle via status columns rather than row deletion (e.g. activeterminated, draftfinalizedpaid)
  • JSON columns for flexible storage (properties, settings, metadata, line_items, details)
  • Foreign key delete policiesRESTRICT by default; CASCADE for child/detail tables; SET NULL for optional references
  • Timezone-aware timestamps — all DateTime columns use timezone=True with server_default=func.now()