Skip to main content

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.

  1. Create a webhook and store the signing secret it returns once.
  2. Subscribe to the events your fulfillment logic needs.
  3. Verify the signature and timestamp on every delivery; see verification and handler checklist.
  4. Skip deliveries you've already processed, keyed on the body's id.
  5. For order events, reconcile your record from data.order.id and data.payment.id. Don't cancel an order because PAYMENT_EXPIRED arrived, 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.

FieldRequiredDescription
urlYesHTTPS endpoint on port 443 whose hostname resolves to a public address, at most 2048 characters
eventsYesOne or more event names from events and payloads
customHeadersNoUp to 10 { "key", "value" } pairs sent on every delivery, for example a shared bearer token
Destination rules

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.
  • localhost and any hostname ending in .internal, .local or .localhost are rejected whatever they resolve to.
  • Hosts on peer.xyz and zkp2p.xyz are 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 active to true on 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.
Active webhook limit

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.

Custom header rules
  • 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 with proxy- or x-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_FULFILLED is the release signal. Subscribe to it, plus PAYMENT_SETTLED, PAYMENT_FAILED, PAYMENT_EXPIRED, ORDER_CANCELLED and ORDER_RESIZED to learn why an order isn't progressing or that its amount moved.
  • Add PAYMENT_CHARGEBACKED, ORDER_PARTIALLY_CHARGEBACKED and ORDER_CHARGEBACKED if you accept Venmo or PayPal. Cash App payments can't be charged back.
  • Add DISPUTE_OPENED, DISPUTE_PAID and DISPUTE_ESCALATED to learn when a seller dispute asks you to pay a seller.
  • Add ORDER_AMOUNT_SET if you create open-amount orders, the bridge events if your settlement converts to another chain or token, and the PAYOUT_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​

  1. Accept POST with a JSON body.
  2. Verify the signature before acting on the payload.
  3. Return 2xx within 30 seconds.
  4. 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 attemptNext attempt in
11 minute
25 minutes
330 minutes
42 hours
58 hours
624 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​

StatusMeaning
PENDINGAwaiting delivery or retry
DELIVEREDDelivered with a 2xx response
FAILEDAll 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.