Webhooks
Webhooks deliver order, payment, bridge, payout and seller dispute updates from Peer Pay to your
server. Each delivery is a signed POST with a JSON body. The event family decides what data
holds; see events and payloads.
- Create a webhook and store the signing secret it returns once.
- Subscribe to the events your fulfillment logic needs.
- Verify the signature and timestamp on every delivery; see verification and handler checklist.
- Skip deliveries you've already processed, keyed on the body's
id. - For order events, reconcile your record from
data.order.idanddata.payment.id. Don't cancel an order becausePAYMENT_EXPIREDarrived, and keep chargeback state in its own field.
Create a webhook
curl -X POST https://api.pay.peer.xyz/api/v1/webhooks \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key" \
-d '{
"url": "https://yoursite.com/webhooks/zkp2p",
"events": ["PAYMENT_SETTLED", "PAYMENT_FAILED", "PAYMENT_EXPIRED", "ORDER_FULFILLED"]
}'
The response is 201 and carries the signing secret:
{
"success": true,
"message": "Webhook created",
"responseObject": {
"webhook": { "id": "...", "url": "...", "events": ["..."], "active": true, "...": "..." },
"secret": "whsec_..."
},
"statusCode": 201
}
Store responseObject.secret now. No other response returns it.
| Field | Required | Description |
|---|---|---|
url | Yes | HTTPS endpoint on port 443 whose hostname resolves to a public address, at most 2048 characters |
events | Yes | One or more event names from events and payloads |
customHeaders | No | Up to 10 { "key", "value" } pairs sent on every delivery, for example a shared bearer token |
A URL that breaks a rule is rejected with 400. For a Peer host, an IP address or a port other
than 443, message names the rule; the other rules share one message. A host that doesn't exist
is also rejected with 400. If the host can't be resolved right now, the request returns 503:
send it again shortly.
- Plain HTTP, private and loopback destinations are rejected, and so are URLs with
embedded credentials, such as
https://user:pass@example.com/hook. - The host must be a hostname. An IP address is rejected, IPv4 or IPv6, public or not.
- Only port 443 is accepted. A URL with any other port, such as
:8443, is rejected. localhostand any hostname ending in.internal,.localor.localhostare rejected whatever they resolve to.- Hosts on
peer.xyzandzkp2p.xyzare rejected. The only exception is the receiver the Peer Pay Telegram bot registers for itself. - Every delivery checks the stored URL against these rules and resolves the host again. A URL that breaks a rule, or whose host resolves to an address that isn't public, fails that delivery at once, with no retries. A host that fails to resolve is retried on the normal schedule.
- Setting
activetotrueon an inactive webhook checks the stored URL again, so a webhook whose URL now breaks a rule can't be switched back on until the URL is changed.
A merchant can have at most 10 active webhooks; live and sandbox count separately, and inactive
webhooks don't count. Creating another, or setting active to true on an 11th, returns 409
with errorCode: "ACTIVE_WEBHOOK_LIMIT_REACHED". Delete or deactivate one first.
- Keys are trimmed, lower-cased, and must be valid HTTP header names. Duplicate keys are rejected.
- Values can't contain CR, LF or NUL.
- Reserved keys are rejected:
x-webhook-id,x-webhook-timestamp,x-webhook-signature,host,content-type,content-length,connection,expect,forwarded,proxy-authenticate,proxy-authorization,te,trailer,transfer-encoding,upgrade,x-real-ip,cf-connecting-ip,true-client-ip, and any key starting withproxy-orx-forwarded-.
Webhooks belong to one environment. A webhook created with the sandbox key receives only sandbox deliveries, and one created with the live key only live deliveries, each with its own secret.
Subscriptions
ORDER_FULFILLEDis the release signal. Subscribe to it, plusPAYMENT_SETTLED,PAYMENT_FAILED,PAYMENT_EXPIRED,ORDER_CANCELLEDandORDER_RESIZEDto learn why an order isn't progressing or that its amount moved.- Add
PAYMENT_CHARGEBACKED,ORDER_PARTIALLY_CHARGEBACKEDandORDER_CHARGEBACKEDif you accept Venmo or PayPal. Cash App payments can't be charged back. - Add
DISPUTE_OPENED,DISPUTE_PAIDandDISPUTE_ESCALATEDto learn when a seller dispute asks you to pay a seller. - Add
ORDER_AMOUNT_SETif you create open-amount orders, the bridge events if your settlement converts to another chain or token, and thePAYOUT_ORDER_*events if you use payouts.
A webhook receives only the events it lists. Webhooks created during dashboard onboarding list every event type. The full list and payloads are on events and payloads.
Endpoint requirements
- Accept
POSTwith a JSON body. - Verify the signature before acting on the payload.
- Return 2xx within 30 seconds.
- Process asynchronously.
Retry policy
A delivery is attempted up to 7 times. Each attempt waits 30 seconds for a response. A non-2xx status, a timeout or a connection error schedules the next attempt:
| After attempt | Next attempt in |
|---|---|
| 1 | 1 minute |
| 2 | 5 minutes |
| 3 | 30 minutes |
| 4 | 2 hours |
| 5 | 8 hours |
| 6 | 24 hours |
After the seventh failure the delivery is FAILED and not retried. Redirects count as failures,
so register the final URL. Every attempt carries the same X-Webhook-Id with a fresh timestamp
and signature.
Delivery statuses
| Status | Meaning |
|---|---|
PENDING | Awaiting delivery or retry |
DELIVERED | Delivered with a 2xx response |
FAILED | All 7 attempts failed, or delivery stopped because the webhook was inactive, its URL breaks a destination rule, or a test delivery's single attempt failed |
Automatic switch-off
When at least 30 finished deliveries in a row have FAILED, and the first and last of that run of
failures were created at least a day apart, Peer Pay switches the webhook off by setting active
to false. A DELIVERED delivery ends the run. PENDING deliveries are still retrying, and
test deliveries aren't real events, so neither counts nor ends the run. Only deliveries
created since the webhook was created or last updated count, so any update starts the count again.
You aren't notified: the webhook shows as inactive in the dashboard and in the list.
While the webhook is off, no new deliveries are created for it, and deliveries still waiting for a
retry are marked FAILED without being sent. A test sent to it reports Webhook is inactive.
Fix the endpoint, then switch the webhook back on in the dashboard or with
PATCH /api/v1/webhooks/{webhookId} and {"active": true}, and send a test delivery
to confirm it answers. Deliveries that failed are not replayed, so after switching it back on,
reconcile the orders you missed from the Orders API. The
delivery log returns the 50 most recent payloads.
Manage webhooks
Authenticate with X-API-Key, or with a dashboard session token in Authorization: Bearer, but
not both; sending both returns 400. With a dashboard session, creating, updating, deleting and
testing webhooks needs the Owner or Manager role.
List
curl https://api.pay.peer.xyz/api/v1/webhooks \
-H "X-API-Key: your_api_key"
Returns { webhooks }, without secrets.
Update
curl -X PATCH https://api.pay.peer.xyz/api/v1/webhooks/{webhookId} \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key" \
-d '{"active": true}'
PATCH accepts any of url, active, events and customHeaders.
Delete
curl -X DELETE https://api.pay.peer.xyz/api/v1/webhooks/{webhookId} \
-H "X-API-Key: your_api_key"
Test
curl -X POST https://api.pay.peer.xyz/api/v1/webhooks/{webhookId}/test \
-H "X-API-Key: your_api_key"
Sends one signed ORDER_CREATED delivery with data.test set to true and every snapshot
null, so you can exercise your handler before a real order exists. It is not retried.
responseObject carries success, deliveryId, responseCode and error. Limited to 5
calls per 10 minutes per merchant.
Deliveries
curl https://api.pay.peer.xyz/api/v1/webhooks/{webhookId}/deliveries \
-H "X-API-Key: your_api_key"
Returns the 50 most recent deliveries, newest first, as { deliveries, hasMore }. Each carries
eventType, payload, status, attempts, lastAttemptAt, nextRetryAt and responseCode.