---
title: "Replay a webhook delivery"
description: "Pick a delivery from the webhook log and have Polar or Resend send it again, signed, through their own redelivery, from the admin console, DevTools or your own admin code, with each replay recorded."
canonical_url: "https://nuxt-backend.dev/docs/ship/operate/replay"
---
# Replay a webhook delivery

> Pick a delivery from the webhook log and have Polar or Resend send it again, signed, through their own redelivery, from the admin console, DevTools or your own admin code, with each replay recorded.

Version: nuxt-backend 0.6.x · Tab: Ship · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- [Source](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/webhooks.ts)

A webhook that failed leaves state behind: a plan that never switched, an email status stuck at `sent`. Replay sends the delivery again from the app, so you fix the state without a trip to the provider's dashboard. The [delivery log](https://nuxt-backend.dev/docs/ship/security/webhooks#the-delivery-log) the backend keeps gets a **Replay** action. It asks the provider to send the delivery again through its own redelivery: Polar redelivers a webhook event, and Resend replays one. The delivery arrives at the same route, signed by the provider, as the first one did.

## When to replay

- **A handler failed** (`handler_error`) and you deployed the fix. Replay the deliveries it failed.
- **An endpoint was off.** Once it is back on ([Healthy webhook endpoints](https://nuxt-backend.dev/docs/services#healthy-webhook-endpoints)), replay what the provider held back while it was off.

A replay goes through the route like any delivery: verified, deduplicated and logged. A delivery already processed answers `duplicate` and changes nothing, so replaying twice is safe.

The log counts the requests a route refused before any signature verified (`missing_secret`, `invalid_signature`, `oversized`) instead of listing them, so a flood of forged requests cannot fill it. After you fix a secret, redeliver what the provider gave up on from its own dashboard.

## Replay from the admin console

The admin console's **Webhooks** tab shows the delivery log of both providers, newest first, with each delivery's outcome, when it was last replayed and a **Replay** button. Like every administrator's write, a replay takes a recent sign-in, which the tab asks for, and refuses an administrator acting as someone else. A row that counts requests refused before any signature verified has no button: nothing verified is there to send again.

DevTools' Backend tab has the same button on its webhook feed, for a signed-in administrator. With nobody signed in, the feed asks you to sign in as one instead of showing an empty log. DevTools cannot ask for a recent sign-in: when the last one is older than ten minutes, the button says so, and the admin console's tab replays it.

## Replay from your own code

The scaffold's `backend/webhooks.ts` re-exports two administrator-only functions from `setupWebhooks`, from `nuxt-backend/admin`. Each reads the caller's role fresh on every call:

```ts [backend/webhooks.ts]
import { setupWebhooks } from 'nuxt-backend/admin'
import { components } from './_generated/api'

export const webhooks = setupWebhooks(components)

export const { getWebhookDeliveries, replayWebhookDelivery } = webhooks.api
```

- `getWebhookDeliveries({ limit })` lists the log, newest first, for both providers. It moved here from `billing.ts`, so an app without billing reads its email deliveries too. Anyone but an administrator reads `null`.
- `replayWebhookDelivery({ service, deliveryId })` asks the delivery's provider to send it again: `service` is `billing` or `email`, `deliveryId` the delivery's id as the log shows it. Only a delivery the log holds can be replayed (`invalid_input` on `deliveryId` otherwise), and a provider that refuses answers `unavailable`.

`setupWebhooks(components, { adminRoles, adminUserIds })` names the administrators, as `setupAdmin` does.

Each replay stamps the delivery with `replayedAt`, and records `webhook.replayed` on the [activity trail](https://nuxt-backend.dev/docs/build/auth/admin/audit-log), with the service, the delivery's id and its type. So who replayed what, and when, stays on the record.

## Limits

- **The provider keys need their full scopes.** Polar's redelivery needs the access token's `webhooks:write` scope, and Resend's replay a full-access key, which lists the team's webhooks to find this deployment's: the one at this deployment's `/email/events`, or the only one at an `/email/events` route.
- **Not on a sandbox.** A deployment with `BACKEND_ENVIRONMENT=sandbox`, such as the public demo, refuses a replay as `not_ready`, reason `sandbox`, as it refuses a broadcast. A replay runs on `production` and `development` alone: a preview, or a deployment whose `BACKEND_ENVIRONMENT` is unset or mistyped, refuses it as reason `environment` ([Deploy a demo or staging app](https://nuxt-backend.dev/docs/ship/deploy/staging#what-a-demo-refuses)).
- **Only what the log keeps.** The log keeps the newest 200 verified deliveries. Replay an older one from the provider's dashboard.

## Try it in development

Replay uses the providers' own redelivery, so it works the same on their test modes. On a cloud dev deployment, a checkout in Polar's sandbox and a send to `delivered@resend.dev` each leave real deliveries in the log to replay ([Develop on real sandboxes](https://nuxt-backend.dev/docs/develop/sandboxes)). A local deployment needs a tunnel for the providers to reach it.

## Related

- [Register webhooks](https://nuxt-backend.dev/docs/ship/security/webhooks): the routes, their outcomes and the delivery log.
- [Respond to incidents](https://nuxt-backend.dev/docs/ship/operate/runbooks): what to check when webhooks fail, arrive late or arrive twice.
- [Apply the provider settings](https://nuxt-backend.dev/docs/services#recommended-settings): endpoint health, and replay after an endpoint comes back.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
