View as Markdown

Integrate · Guide

Test and recover webhooks

Use delivery attempts, resend and replay to see what your endpoint answered and to recover from an outage, and the Provenance CLI to receive sandbox events on your machine while you build. Each delivery keeps every attempt with your endpoint's status, latency, a few headers and the first 4 KB of its response.

Before you begin: export the sandbox account key and create an endpoint. In the sandbox an endpoint can be http://localhost; nothing needs to listen there for these steps.

export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -s $PROVENANCE_API/v1/webhook_endpoints \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "http://localhost:4242/webhooks", "event_types": ["mandate.intent.revoked"] }' | tee endpoint.json
export ENDPOINT_ID=$(jq -r .id endpoint.json)
{ "object": "webhook_endpoint", "url": "http://localhost:4242/webhooks", "status": "active" }

1. See a delivery's attempts

Send a test event, then open its delivery with GET /v1/webhook_endpoints/{id}/deliveries/{delivery_id}. delivery_attempts lists every attempt, oldest first.

curl -s -X POST $PROVENANCE_API/v1/webhook_endpoints/$ENDPOINT_ID/test \
  -H "Authorization: Bearer $PROVENANCE_KEY" | tee delivery.json
export DELIVERY_ID=$(jq -r .id delivery.json)
curl -s $PROVENANCE_API/v1/webhook_endpoints/$ENDPOINT_ID/deliveries/$DELIVERY_ID \
  -H "Authorization: Bearer $PROVENANCE_KEY"
{
  "id": "dlv_01M6V8P0YPD4F7M02AF88SPDP6",
  "object": "webhook_delivery",
  "event_type": "ping",
  "status": "failed",
  "attempts": 1,
  "delivery_attempts": [
    {
      "object": "webhook_delivery_attempt",
      "attempt_no": 1,
      "trigger": "automatic",
      "status_code": null,
      "error": "connection failed",
      "response_body": null
    }
  ]
}

Each attempt has these fields:

FieldWhat it holds
status_code, errorYour endpoint's HTTP status, or why there was no answer
duration_msHow long your endpoint took
response_headersContent type and length, date, server, Retry-After and request IDs
response_bodyThe first 4 KB of the body
triggerautomatic (a scheduled attempt or retry) or resend

2. Resend a delivery

Fix your endpoint, then send the delivery again with POST /v1/webhook_deliveries/{id}/resend. It is a new attempt on the same delivery, signed fresh, with the same event ID, so your handler's dedupe still works. A failed resend leaves the automatic retries as they were.

curl -s -X POST $PROVENANCE_API/v1/webhook_deliveries/$DELIVERY_ID/resend \
  -H "Authorization: Bearer $PROVENANCE_KEY"
{ "object": "webhook_delivery", "event_type": "ping" }

Send an Idempotency-Key to make a retried resend safe. You can resend 30 deliveries a minute.

3. Replay events after an outage

When your endpoint was down, replay every stored event since a time with POST /v1/webhook_endpoints/{id}/replay. Each event the endpoint subscribes to (and that's in types, when you pass it) gets a fresh delivery, oldest first, with its original event ID.

curl -s -X POST $PROVENANCE_API/v1/webhook_endpoints/$ENDPOINT_ID/replay \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "since": "2026-11-01T00:00:00Z", "types": ["mandate.intent.revoked"] }'
{ "object": "webhook_replay", "max_events": 10000, "capped": false, "resume_since": null }

One call queues up to 10,000 events. When capped is true, call again with resume_since as since. Replay reaches back as far as your plan keeps events (see logs and events); an account can replay 10 times an hour.

4. Forward events to your machine

The Provenance CLI receives your sandbox events as they happen and posts each one, signed, to a local URL, so you can build a handler without a public endpoint.

This package isn't on npm yet. Until then, every request in these docs runs over HTTP against the sandbox.

With access to the private Provenance repository, which your Provenance contact grants, install from it:

git clone https://github.com/michaelnbane-jpg/provenance.git provenance
cd provenance && pnpm install && pnpm build
node scripts/check-publishable.mjs --out ../provenance-packs
cd ../your-project
npm install ../provenance-packs/provenanceauth-cli-1.0.0.tgz
provenance login
provenance listen --forward-to http://localhost:3000/webhooks

provenance login asks for a sandbox key and keeps it in your OS keychain (or a file only you can read). provenance listen prints the signing secret it uses, a whsec_ value that stays the same for your account; give it to your handler and verify the Provenance-Signature header exactly as for a registered endpoint. Pass --events mandate.approval.approved,mandate.approval.declined to forward only some types.

CommandWhat it does
provenance loginStores a sandbox key for the CLI
provenance listen [--forward-to URL] [--events types]Prints, and optionally forwards, each sandbox event as it happens
provenance events resend <delivery_id>Resends one delivery

Forwarding works with sandbox keys only; live events go to your registered endpoints.

Errors you might see

SymptomCauseFix
409 webhook_endpoint_disabledThe endpoint is disabledRe-enable it with PATCH /v1/webhook_endpoints/{id}, then resend.
429 rate_limit_exceededToo many resends or replaysWait Retry-After seconds.
503 webhooks_unavailableWebhook delivery is turned off on this deploymentRetry later.
403 sandbox_only from the CLIThe key is a live keyLog in with a prv_test_ key.

See also