Stripe Sigma query: failed invoices grouped by decline code
Builds a Stripe Sigma query grouping failed invoices by decline code. Use when payment ops needs to see which decline reasons drive invoice failures. Not for real-time alerting.
TL;DR
A Stripe Sigma query joining failed invoices to their charges and grouping by decline code shows exactly why invoices are failing: insufficientfunds vs donothonor vs expiredcard each need a different recovery play. Write the query against the invoices and charges tables, filter to failed payment attempts in your window, group by the charge's failure code, and order by count. Refresh it on a schedule and hand it to the dunning owner. This turns 'payments are failing' into a prioritized fix list.
The query
Stripe Sigma query: failed invoices grouped by decline codeUse this when
- Payment ops dashboard for invoice failure reasons
- Prioritizing dunning work by decline code
- Writing Sigma queries on Stripe billing data
Not for
- Real-time failed-payment alerts (use webhooks)
- Non-Stripe payment data (Sigma only sees Stripe)
Steps
- Identify the tables: invoices for the billing record, charges for the failure code.
Expected output: You know the join path before writing SQL.
- Filter to the window and to invoices with failed payment attempts.
Expected output: The dataset is scoped to real failures.
- Group by the charge failure code and count, ordered descending.
Expected output: The top decline reasons surface first.
- Save the query and schedule it for the dunning owner.
Expected output: The report lands without manual runs.
- Map each top code to its recovery play (retry, new card, customer contact).
Expected output: The dashboard drives action, not just awareness.
Variant phrasings
Stripe Sigma failed invoices by decline code
Sigma query invoice payment failures
group Stripe charges by failure code Sigma
Root cause
Sigma can answer this because Stripe stores the full payment attempt history with structured decline codes; grouping by code separates recoverable failures (insufficientfunds, try again later) from terminal ones (stolencard, get a new card). Without the grouping, dunning treats every failure the same and wastes retries.
Edge cases
- Sigma data lags real time by hours; do not use it for alerting
- Some failures never produce a charge (no payment method); count those separately from the invoice side
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_SL5r-hRxrP7MNkcfCO9Z5A
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.