Tearleads

organization_billing_invoice_events API Postgres table

Immutable financial snapshots for paid direct-Stripe subscription invoices.

Declared in packages/api-shared/src/schema/organizationBillingInvoiceEvents.ts

Description

Stripe may redeliver a webhook after any downstream failure. The unique invoice id makes recording idempotent while preserving the first complete snapshot observed for that paid invoice. Amounts use Stripe's provider minor units without recomputation or floating-point conversion.

Columns

  • iduuid
    • primary key
    • not null
    • default gen_random_uuid()

    Row id.

  • organization_iduuid
    • not null

    Organization the subscription bills.

  • provider_event_idtext
    • nullable

    Stripe event id of the webhook delivery that recorded the snapshot; null when the event carried none.

  • invoice_idtext
    • not null

    Stripe invoice id; unique, so a redelivery keeps the first snapshot.

  • subscription_idtext
    • not null

    Stripe subscription the invoice bills.

  • billing_reasontext
    • not null

    Stripe's billing_reason for the invoice, one of OrganizationBillingInvoiceReason, such as subscription_create or subscription_cycle.

  • seat_countinteger
    • nullable

    Seat limit of the sync tier the invoice's seat line buys; null unless that line is one quantity-one Price that resolves to a known tier.

  • price_idtext
    • nullable

    Stripe Price of the invoice's seat line: the one non-proration line billing the subscription's seat item. Null when no single such line is found, and then so are the other seat-line fields.

  • unit_amountbigint
    • nullable

    The seat line's unit amount in currency minor units, or null.

  • currencytext
    • not null

    Invoice currency as Stripe reports it: a lowercase ISO code (usd).

  • intervaltext
    • nullable

    The seat line's recurring interval, such as month, or null.

  • interval_countinteger
    • nullable

    How many intervals one billing period spans, or null.

  • total_amountbigint
    • not null

    Amount paid on the invoice (amount_paid), in currency minor units.

  • period_starts_attimestamp
    • nullable

    Start of the seat line's service period, or null.

  • period_ends_attimestamp
    • nullable

    End of the seat line's service period, or null.

  • occurred_attimestamp
    • not null

    When the invoice was paid (Stripe's paid_at), else when the event was created, else when the server processed it.

  • created_attimestamp
    • not null
    • default now()

    Server-side insertion timestamp.

Indexes

  • organization_billing_invoice_events_invoice_idx(invoice_id)
    • unique
  • organization_billing_invoice_events_org_occurred_idx(organization_id, occurred_at)