> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pesso.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Get told when a request is paid, and check the message really came from Pesso.

Pesso sends one event, `payment.succeeded`, to each of your endpoints — only after it has checked the payment on Base.

## The event

```json POST your-endpoint theme={null}
{
  "type": "payment.succeeded",
  "timestamp": "2026-09-21T14:13:05.000Z",
  "data": {
    "paymentId": "b7e0c1d4-5a92-4f3e-8d61-2c9a4e7f0b18",
    "requestId": "6a1f9d3c-27e4-4b8a-a0c5-93d81e2f4b76",
    "txHash": "0x9c4e1b7a2d5f8036c1e94a7b2d50f8e3c6a19b4d7e20f5a8c3b6d91e4f7a20c5b",
    "amount": "25",
    "amountAtomic": "25000000",
    "currency": "USDC",
    "chain": "base",
    "payerAddress": "0x4B2e9A7c1D5f3086E2a94c7B1d50F8e3C6a19b4D",
    "concept": "{\"Order\":\"#4418\",\"Items\":\"2 bags of coffee\"}",
    "duplicate": false,
    "paidAt": "2026-09-21T14:13:03.000Z"
  }
}
```

**data.paymentId** `string`

Unique per payment. Use it as your idempotency key.

**data.requestId** `string`

The `id` you got when you [created the request](https://docs.pesso.xyz/api-reference/create-payment-request.md).

**data.amount** `string`

USD, no trailing zeros: `"25"`, `"0.01"`, `"12.5"`. `amountAtomic` is the same in 6-decimal units.

**data.concept** `string | null`

A string concept comes back as you sent it. A JSON object comes back as its compact JSON **string** — `JSON.parse` it. `null` if there was none, or it was deleted before delivery.

**data.duplicate** `boolean`

`true` when a single-use link was paid a second time. See [Duplicates and idempotency](#duplicates-and-idempotency).

All fields, including `txHash`, `payerAddress` and `paidAt`, are on the [payment.succeeded](https://docs.pesso.xyz/api-reference/payment-succeeded.md) reference page. The top-level `timestamp` is when Pesso matched the payment to your request; the `webhook-timestamp` header is when this attempt was sent. Pesso never sends the payer’s name or email.

## Verify the signature

Pesso signs every delivery with [Standard Webhooks](https://www.standardwebhooks.com). Use their library with your signing secret, `whsec_…`, and the **raw** request body.

```js Node.js theme={null}
// npm install standardwebhooks
import { Webhook } from "standardwebhooks";

const wh = new Webhook(process.env.PESSO_WEBHOOK_SECRET);

// rawBody: the exact bytes Pesso sent, not re-serialised JSON
const event = wh.verify(rawBody, {
  "webhook-id": req.headers["webhook-id"],
  "webhook-timestamp": req.headers["webhook-timestamp"],
  "webhook-signature": req.headers["webhook-signature"],
});
```

```python Python theme={null}
# pip install standardwebhooks
import os
from standardwebhooks.webhooks import Webhook

wh = Webhook(os.environ["PESSO_WEBHOOK_SECRET"])

# body: the exact bytes Pesso sent, not re-serialised JSON
event = wh.verify(body, request.headers)
```

`verify` throws if the signature doesn’t match or `webhook-timestamp` is more than 5 minutes from now. Answer `400` and don’t act on the event.

### A complete handler

Most frameworks parse JSON before your code runs, and a re-serialised body no longer matches the signature. Read the raw bytes on this one route:

```js Express theme={null}
import express from "express";
import { Webhook } from "standardwebhooks";

const app = express();
const wh = new Webhook(process.env.PESSO_WEBHOOK_SECRET);

// express.raw keeps the exact bytes; don't put express.json() in front of this route.
app.post("/webhooks/pesso", express.raw({ type: "application/json" }), async (req, res) => {
  let event;
  try {
    event = wh.verify(req.body, req.headers);
  } catch {
    return res.sendStatus(400);
  }
  const { paymentId, requestId, duplicate } = event.data;
  if (await alreadyHandled(paymentId)) return res.sendStatus(200);
  await markOrderPaid(requestId, { paymentId, duplicate });
  res.sendStatus(200);
});
```

```python Flask theme={null}
import os
from flask import Flask, request
from standardwebhooks.webhooks import Webhook

app = Flask(__name__)
wh = Webhook(os.environ["PESSO_WEBHOOK_SECRET"])

@app.post("/webhooks/pesso")
def pesso_webhook():
    try:
        event = wh.verify(request.get_data(), request.headers)  # raw bytes
    except Exception:
        return "", 400
    data = event["data"]
    if already_handled(data["paymentId"]):
        return "", 200
    mark_order_paid(data["requestId"], payment_id=data["paymentId"], duplicate=data["duplicate"])
    return "", 200
```

`alreadyHandled` and `markOrderPaid` are yours. Answer quickly: do slow work, such as emails, after you reply.

> [!NOTE]
>
> **Test your verification** before a real payment: a sample body, headers and secret with the signature they must produce. [Jump to the sample](#test-your-verification).

## Test your verification

These values were signed by Pesso’s own signing code. **Sample only — never a real secret.**

| | Value |
| - | - |
| Signing secret | `whsec_cGVzc28gc2FtcGxlIHNlY3JldCBvbmx5` |
| `webhook-id` | `3f6c2a9e-8b1d-4e7a-9c55-0d2b7f41a6e3` |
| `webhook-timestamp` | `1790000000` |
| `webhook-signature` | `v1,u6FiqX3ySfm6VW794JA1ACn2ymfwXaTEu8/26sNhnQ4=` |

```json Body (exact bytes, no trailing newline) wrap theme={null}
{"type":"payment.succeeded","timestamp":"2026-09-21T14:13:05.000Z","data":{"paymentId":"b7e0c1d4-5a92-4f3e-8d61-2c9a4e7f0b18","requestId":"6a1f9d3c-27e4-4b8a-a0c5-93d81e2f4b76","txHash":"0x9c4e1b7a2d5f8036c1e94a7b2d50f8e3c6a19b4d7e20f5a8c3b6d91e4f7a20c5b","amount":"25","amountAtomic":"25000000","currency":"USDC","chain":"base","payerAddress":"0x4B2e9A7c1D5f3086E2a94c7B1d50F8e3C6a19b4D","concept":"{\"Order\":\"#4418\",\"Items\":\"2 bags of coffee\"}","duplicate":false,"paidAt":"2026-09-21T14:13:03.000Z"}}
```

The library above refuses this sample because its timestamp is old, so check your signing logic with plain HMAC instead. Each snippet prints `true`:

```js verify.mjs theme={null}
// Sample only — never a real secret. Prints true when the signature check is right.
import { createHmac, timingSafeEqual } from "node:crypto";

const secret = "whsec_cGVzc28gc2FtcGxlIHNlY3JldCBvbmx5";
const id = "3f6c2a9e-8b1d-4e7a-9c55-0d2b7f41a6e3";
const timestamp = "1790000000";
const signature = "v1,u6FiqX3ySfm6VW794JA1ACn2ymfwXaTEu8/26sNhnQ4=";
const body = String.raw`{"type":"payment.succeeded","timestamp":"2026-09-21T14:13:05.000Z","data":{"paymentId":"b7e0c1d4-5a92-4f3e-8d61-2c9a4e7f0b18","requestId":"6a1f9d3c-27e4-4b8a-a0c5-93d81e2f4b76","txHash":"0x9c4e1b7a2d5f8036c1e94a7b2d50f8e3c6a19b4d7e20f5a8c3b6d91e4f7a20c5b","amount":"25","amountAtomic":"25000000","currency":"USDC","chain":"base","payerAddress":"0x4B2e9A7c1D5f3086E2a94c7B1d50F8e3C6a19b4D","concept":"{\"Order\":\"#4418\",\"Items\":\"2 bags of coffee\"}","duplicate":false,"paidAt":"2026-09-21T14:13:03.000Z"}}`;

const key = Buffer.from(secret.slice("whsec_".length), "base64");
const expected = Buffer.from(createHmac("sha256", key).update(`${id}.${timestamp}.${body}`).digest("base64"));
const valid = signature.split(" ").some((entry) => {
  const [version, sig] = entry.split(",");
  return version === "v1" && sig.length === expected.length && timingSafeEqual(Buffer.from(sig), expected);
});
console.log(valid);
```

```python verify.py theme={null}
# Sample only — never a real secret. Prints true when the signature check is right.
import base64, hashlib, hmac

secret = "whsec_cGVzc28gc2FtcGxlIHNlY3JldCBvbmx5"
msg_id = "3f6c2a9e-8b1d-4e7a-9c55-0d2b7f41a6e3"
timestamp = "1790000000"
signature = "v1,u6FiqX3ySfm6VW794JA1ACn2ymfwXaTEu8/26sNhnQ4="
body = r'{"type":"payment.succeeded","timestamp":"2026-09-21T14:13:05.000Z","data":{"paymentId":"b7e0c1d4-5a92-4f3e-8d61-2c9a4e7f0b18","requestId":"6a1f9d3c-27e4-4b8a-a0c5-93d81e2f4b76","txHash":"0x9c4e1b7a2d5f8036c1e94a7b2d50f8e3c6a19b4d7e20f5a8c3b6d91e4f7a20c5b","amount":"25","amountAtomic":"25000000","currency":"USDC","chain":"base","payerAddress":"0x4B2e9A7c1D5f3086E2a94c7B1d50F8e3C6a19b4D","concept":"{\"Order\":\"#4418\",\"Items\":\"2 bags of coffee\"}","duplicate":false,"paidAt":"2026-09-21T14:13:03.000Z"}}'

key = base64.b64decode(secret.removeprefix("whsec_"))
expected = base64.b64encode(hmac.new(key, f"{msg_id}.{timestamp}.{body}".encode(), hashlib.sha256).digest()).decode()
valid = any(
    version == "v1" and hmac.compare_digest(sig, expected)
    for version, _, sig in (entry.partition(",") for entry in signature.split(" "))
)
print(str(valid).lower())
```

If yours prints `false`, check that you sign `webhook-id`, `.`, `webhook-timestamp`, `.` and the raw body, with the key base64-decoded from the part after `whsec_`, and compare in standard base64.

## Retries

Answer `2xx` within 10 seconds. Anything else — a redirect, a timeout, a `4xx` or `5xx` — is retried with the same `webhook-id`, up to seven attempts in all. Pesso doesn't follow redirects.

> [!WARNING]
>
> **Only the first attempt is immediate today.** Each retry goes out in Pesso’s daily run, between 00:00 and 00:59 UTC, so a missed first delivery can take a day or more to arrive, and the six retries span about six days. Keep your endpoint up.

Every attempt is signed afresh: `webhook-timestamp` is the time of that attempt, so the 5-minute check still passes on a retry. If your customer closes the page before Pesso has matched the payment, the first attempt also waits for the daily run. If the concept is deleted while a delivery is pending, later attempts carry `data.concept: null`. After the seventh failed attempt, Pesso stops trying.

## Duplicates and idempotency

Store `data.paymentId` and ignore any event you have already handled — a retry can arrive after you handled the first attempt. If `data.duplicate` is `true`, the customer paid a single-use link twice: handle it on your side — for example, send the money back from your own account.

## Your plan and your webhooks

Webhooks need the Business plan, like API keys. If your plan lapses, deliveries for new payments are held, not dropped: they go out once the plan is back on. Payments still reach your Pesso account either way. [See plans](https://pesso.xyz/plans).

## Where to see deliveries

In Pesso, **Your requests › Webhooks** shows each endpoint’s last delivery: delivered, retrying with the last reply, or stopped. **Your requests › Links** shows which links are paid. If a link shows paid and your server has no event, check the endpoint’s state first.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.