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)
const api = process.env.PROVENANCE_API;
const headers = { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" };
const endpoint = await (
await fetch(`${api}/v1/webhook_endpoints`, {
method: "POST",
headers,
body: JSON.stringify({ url: "http://localhost:4242/webhooks", event_types: ["mandate.intent.revoked"] }),
})
).json();
import os, httpx
api = os.environ["PROVENANCE_API"]
headers = {"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}
endpoint = httpx.post(f"{api}/v1/webhook_endpoints", headers=headers, json={"url": "http://localhost:4242/webhooks", "event_types": ["mandate.intent.revoked"]}).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 /. 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"
const test = await (await fetch(`${api}/v1/webhook_endpoints/${endpoint.id}/test`, { method: "POST", headers })).json();
const delivery = await (await fetch(`${api}/v1/webhook_endpoints/${endpoint.id}/deliveries/${test.id}`, { headers })).json();
test = httpx.post(f"{api}/v1/webhook_endpoints/{endpoint['id']}/test", headers=headers).json()
delivery = httpx.get(f"{api}/v1/webhook_endpoints/{endpoint['id']}/deliveries/{test['id']}", headers=headers).json()
{
"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:
| Field | What it holds |
|---|---|
status_, error | Your endpoint's HTTP status, or why there was no answer |
duration_ | How long your endpoint took |
response_ | Content type and length, date, server, Retry-After and request IDs |
response_ | The first 4 KB of the body |
trigger | automatic (a scheduled attempt or retry) or resend |
2. Resend a delivery
Fix your endpoint, then send the delivery again with POST /. 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"
const resent = await (await fetch(`${api}/v1/webhook_deliveries/${test.id}/resend`, { method: "POST", headers })).json();
resent = httpx.post(f"{api}/v1/webhook_deliveries/{test['id']}/resend", headers=headers).json()
{ "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 /. 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"] }'
const replay = await (
await fetch(`${api}/v1/webhook_endpoints/${endpoint.id}/replay`, {
method: "POST",
headers,
body: JSON.stringify({ since: "2026-11-01T00:00:00Z", types: ["mandate.intent.revoked"] }),
})
).json();
replay = httpx.post(f"{api}/v1/webhook_endpoints/{endpoint['id']}/replay", headers=headers, json={"since": "2026-11-01T00:00:00Z", "types": ["mandate.intent.revoked"]}).json()
{ "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.tgzprovenance 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.
| Command | What it does |
|---|---|
provenance login | Stores 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_ | Resends one delivery |
Forwarding works with sandbox keys only; live events go to your registered endpoints.
Errors you might see
| Symptom | Cause | Fix |
|---|---|---|
409 webhook_ | The endpoint is disabled | Re-enable it with PATCH /, then resend. |
429 rate_ | Too many resends or replays | Wait Retry-After seconds. |
503 webhooks_ | Webhook delivery is turned off on this deployment | Retry later. |
403 sandbox_ from the CLI | The key is a live key | Log in with a prv_ key. |
See also
- Webhooks
- Logs and events
- CLI
- Test texts in the sandbox, the next step before going live
- Errors