Track dunning recovery from failed invoices

Measure failed-payment recovery from invoice failure through retry, card update, recovery, or cancellation for subscription revenue.

Published

difficulty intermediate · time to value 5 minutes

Start from this

Build a dunning recovery funnel: invoice failed → retry scheduled → payment method updated → payment recovered or subscription canceled.

Why this matters

Failed payments are often recoverable churn. A dunning funnel shows whether users update cards, retries recover revenue, or accounts silently cancel.

What you get

  • Recovery rate after failed invoices
  • Time to recovery
  • Cancellations after dunning
  • Revenue at risk and recovered

Walk through it

You

How effective is our dunning flow?

Agent

I’ll stitch billing webhook events into a recovery funnel.

POST /v1/projects/:project_id/analytics/query {
  project_id: "default",
  hogql: "SELECT event, count(DISTINCT properties.invoice_id) AS invoices, sum(toFloat(properties.amount)) AS amount FROM events WHERE event IN ('invoice_payment_failed','payment_method_updated','invoice_payment_recovered','subscription_canceled') AND timestamp > now() - INTERVAL 60 DAY GROUP BY event ORDER BY invoices DESC"
}

The output

The agent returns recovery rate, lost revenue, and suggested actions such as improving retry timing or card-update emails.

Setting it up

Emit billing lifecycle events from Stripe or your subscription provider webhook handler.

Variations

  • “Segment recovery by plan.”
  • “Find accounts with repeated payment failures.”
  • “Draft a Slack digest for at-risk revenue.”

Try this recipe in your own agent.

Ask your agent to adapt the starter prompt to your saved signal map and live events, then run it against your data.

Install agentry.sh/install.md for me
Agent will onboard itself and then your app