Webhooks
We POST a signed JSON event to your endpoint whenever an escrow changes state. Anyone can send JSON to a URL, so check the signature before you trust a delivery. That proves it came from us and was not altered.
Register an endpoint
Once per environment, either on the dashboard's Webhooks page or with an API key that has webhooks:write. Choose the events the endpoint receives — it gets only those. The URL must be public HTTPS: private and loopback addresses are refused, at registration and at every delivery.
curl -sS -X POST "$ESCROW_API_BASE/webhook-endpoints" \
-H "Authorization: Bearer $ESCROW_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"url": "https://shop.example/webhooks/escrow",
"enabledEvents": ["escrow.funded", "escrow.released", "escrow.refunded", "escrow.disputed",
"escrow.resolved", "escrow.cancelled", "escrow.expired",
"escrow.group.completed", "escrow.paid", "escrow.payment_refunded",
"transaction.failed"],
"description": "orders"
}'
# The response contains "secret": "whsec_…" exactly once. Store it now.Change the events, URL or enabled state later with PATCH /v1/webhook-endpoints/{id}. Send a signed test event with POST /v1/webhook-endpoints/{id}/test: the answer says whether your endpoint accepted it.
What a delivery looks like
POST /webhooks/escrow HTTP/1.1
Content-Type: application/json
Escrow-Signature: t=1788464991,v1=5f2b8c…(64 hex characters)
{
"id": "evt_01M1MD5Q0N6V7X2Y3Z4A5B6C7D",
"type": "escrow.funded",
"apiVersion": "2026-07-01",
"createdAt": "2026-09-03T12:29:51.000Z",
"organizationId": "org_01M1MCZ8H2K3J4N5P6Q7R8S9T0",
"data": {
"escrowId": "esc_01M1MD43G9ZRNVVHV25TQ85MCD",
"status": "FUNDED",
"amountAtomic": "1000000",
"transactionHash": "0x…",
"externalReference": "order-4417"
}
}type is one of the events you subscribed the endpoint to, such as escrow.funded or escrow.released. The Send test event button in the dashboard sends a webhook.test event, signed the same way, with data.test: true. Verify it and answer 2xx, but change nothing.
For every escrow.* event, data holds escrowId, organizationId, onChainId, status, chainId and amountAtomic, plus transactionHash when the change came from the chain, your externalReference and metadata when the escrow has them, and groupId for a milestone stage. Treat the event as a signal to look: re-read the escrow with GET /v1/escrows/{id} before acting. Anything you put in metadata is sent to every subscribed endpoint and kept in webhook history for 30 days — order ids, never personal data.
Event types
| type | When |
|---|---|
| escrow.created | An escrow was created (by API, a milestone group or a dashboard payment link). |
| escrow.funded | The payment is confirmed on chain. Mark the order paid here, after re-reading the escrow. |
| escrow.released | The buyer released; the seller has been paid. Create no payout of your own. |
| escrow.refunded | The buyer has their money back (seller refund, buyer refund after the lock, or a dispute). |
| escrow.disputed | A dispute was opened; release and refund are blocked until it is decided. |
| escrow.resolved | The dispute was decided. escrow.released or escrow.refunded follows. |
| escrow.cancelled | An unfunded escrow was cancelled. |
| escrow.expired | Nobody paid before the fundingDeadline. |
| escrow.paid | An instant payment is confirmed on chain: the seller and the platform fee are already paid, so deliver the order here. Sent instead of escrow.funded for an order created with settlementMode: "INSTANT"; nothing follows it. data adds settlementMode, platformFeeAtomic and sellerAmountAtomic. |
| escrow.payment_refunded | The seller refunded part or all of an instant payment from their own wallet. The order stays PAID; data adds refundId, refundAmountAtomic, totalRefundedAtomic and refundState (PARTIAL or FULL). |
| escrow.group.completed | Every stage of a milestone group reached a final status. Sent once. |
| transaction.failed | A transaction we were following failed or was dropped — for example a funding attempt that reverted. |
| seller_wallet.verified | A seller signed a verification link. Store data.sellerWalletId against data.sellerReference. |
Delivery order is not guaranteed: a late escrow.funded can arrive after escrow.released. Decide from the escrow's current status, not from the order events arrive in.
Verify the signature
The signing secret is the whsec_… value shown once when you registered the endpoint. Keep it server-side, for example in an environment variable such as ESCROW_WEBHOOK_SECRET. Each endpoint has its own secret.
- Read the request body as raw bytes, before any JSON parsing. Parsing and re-serialising changes whitespace and key order, and the signature will no longer match.
- Split the
Escrow-Signatureheader intot(Unix seconds) andv1(64 lowercase hex characters). Reject anything else. - Reject the delivery if
tis more than 5 minutes from your clock. That stops a captured request from being replayed later. Every attempt is signed afresh, so a retry is never stale. - Compute HMAC-SHA256 over
t + "." + rawBody, keyed with your signing secret — the whole string, including thewhsec_prefix, used as-is (do not hex-decode it). - Compare your hex digest with
v1using a constant-time comparison. Only then parse the body and act on it.
Code you can copy
No library is needed: each of these is the whole check. If you use our Node.js SDK, verifySignature does the same in one call.
import { createHmac, timingSafeEqual } from 'node:crypto';
import express from 'express';
function verifyEscrowSignature(rawBody, header, secret, windowSeconds = 300) {
const match = /^t=(\d+),v1=([0-9a-f]{64})$/.exec((header ?? '').trim());
if (!match) return false;
const [, timestamp, received] = match;
if (Math.abs(Date.now() / 1000 - Number(timestamp)) > windowSeconds) return false;
const expected = createHmac('sha256', secret)
.update(`${timestamp}.`)
.update(rawBody) // Buffer: the exact bytes received
.digest();
return timingSafeEqual(expected, Buffer.from(received, 'hex'));
}
const app = express();
// express.raw, not express.json — the signature covers the raw bytes.
app.post('/webhooks/escrow', express.raw({ type: 'application/json' }), (req, res) => {
if (!verifyEscrowSignature(req.body, req.get('Escrow-Signature'), process.env.ESCROW_WEBHOOK_SECRET)) {
return res.sendStatus(400);
}
const event = JSON.parse(req.body.toString('utf8'));
// …handle event.type, de-duplicating on event.id
res.sendStatus(204);
});import hashlib
import hmac
import json
import os
import re
import time
from flask import Flask, abort, request
HEADER = re.compile(r"^t=(\d+),v1=([0-9a-f]{64})$")
def verify_escrow_signature(raw_body: bytes, header: str, secret: str, window: int = 300) -> bool:
match = HEADER.match((header or "").strip())
if not match:
return False
timestamp, received = match.groups()
if abs(time.time() - int(timestamp)) > window:
return False
signed = timestamp.encode() + b"." + raw_body
expected = hmac.new(secret.encode(), signed, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, received)
app = Flask(__name__)
@app.post("/webhooks/escrow")
def escrow_webhook():
raw = request.get_data() # raw bytes — do not use request.json first
if not verify_escrow_signature(raw, request.headers.get("Escrow-Signature", ""),
os.environ["ESCROW_WEBHOOK_SECRET"]):
abort(400)
event = json.loads(raw)
# …handle event["type"], de-duplicating on event["id"]
return "", 204<?php
function verify_escrow_signature(string $rawBody, string $header, string $secret, int $window = 300): bool
{
if (!preg_match('/^t=(\d+),v1=([0-9a-f]{64})$/', trim($header), $m)) {
return false;
}
[, $timestamp, $received] = $m;
if (abs(time() - (int) $timestamp) > $window) {
return false;
}
$expected = hash_hmac('sha256', $timestamp . '.' . $rawBody, $secret);
return hash_equals($expected, $received);
}
$raw = file_get_contents('php://input'); // raw body, before json_decode
$header = $_SERVER['HTTP_ESCROW_SIGNATURE'] ?? '';
if (!verify_escrow_signature($raw, $header, getenv('ESCROW_WEBHOOK_SECRET'))) {
http_response_code(400);
exit;
}
$event = json_decode($raw, true);
// …handle $event['type'], de-duplicating on $event['id']
http_response_code(204);Test your implementation
Feed these exact values to your verifier with the 5-minute check turned off. The timestamp is fixed, so the time check would otherwise reject it. It must accept the signature, and reject it if you change a single byte of the body.
secret whsec_00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff
timestamp 1788464991
raw body {"id":"evt_01M1MD5Q0N6V7X2Y3Z4A5B6C7D","type":"webhook.test","apiVersion":"2026-07-01","createdAt":"2026-09-03T12:29:51.000Z","organizationId":"org_01M1MCZ8H2K3J4N5P6Q7R8S9T0","data":{"test":true}}
signed string = timestamp + "." + raw body
v1 = HMAC-SHA256(secret, signed string), lowercase hex
= 891644c0ebc776f83a05b9ec9f8e25e7c2f526a4e7a1103f7b4ea4f82105f74c
Escrow-Signature: t=1788464991,v1=891644c0ebc776f83a05b9ec9f8e25e7c2f526a4e7a1103f7b4ea4f82105f74cThen register your endpoint in the dashboard and press Send test event to check it end to end.
Respond, retry and de-duplicate
Answer 2xx quickly
Any 2xx status within 10 seconds counts as delivered. Anything else, including a timeout or a redirect loop, is a failure. Do slow work after you respond.
Failures are retried
After a failure we retry after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 24 hours: 7 attempts in all. If 10 deliveries in a row fail for good, we disable the endpoint. You can replay any event from the dashboard, or with POST /v1/webhook-events/{id}/replay; GET /v1/webhook-events lists what we sent.
De-duplicate on the event id
Delivery is at-least-once. A retry or a replay carries the same id, so record the ids you have processed and ignore repeats.
Lost the secret?
It is shown only once. Register a new endpoint, switch your server to its secret, then remove the old endpoint.