Webhook reference
Peppy sends JSON events to each configured webhook. Verify every request before using its body.
On this page#
Headers#
Scroll sideways
| Header | Value |
|---|---|
webhook-id |
Delivery ID. Retries for one message reuse this value. |
webhook-timestamp |
Unix time in whole seconds. |
webhook-signature |
v1,<base64> HMAC-SHA256 signature. |
Peppy signs the UTF-8 bytes of webhook-id.webhook-timestamp.raw-body with the base64-decoded value after the whsec_ prefix of the signing secret. Keep the raw request body unchanged until verification succeeds.
Verify a signature#
Node.js#
import crypto from "node:crypto";
export function verifyWebhook({ id, timestamp, signatureHeader, rawBody, secret }) {
try {
const timestampSeconds = Number(timestamp);
if (!secret.startsWith("whsec_") || !Number.isInteger(timestampSeconds) || Math.abs(Math.floor(Date.now() / 1000) - timestampSeconds) > 300) return false;
const key = Buffer.from(secret.slice("whsec_".length), "base64");
const payload = Buffer.concat([Buffer.from(`${id}.${timestamp}.`, "utf8"), rawBody]);
const expected = crypto.createHmac("sha256", key).update(payload).digest();
return signatureHeader.split(" ").some((candidate) => {
const [version, received] = candidate.split(",", 2);
if (version !== "v1" || !received) return false;
const actual = Buffer.from(received, "base64");
return actual.length === expected.length && crypto.timingSafeEqual(actual, expected);
});
} catch {
return false;
}
}
Python 3.9+#
import base64
import hashlib
import hmac
import time
def verify_webhook(*, webhook_id, timestamp, signature_header, raw_body, secret):
try:
if not secret.startswith("whsec_") or abs(time.time() - int(timestamp)) > 300:
return False
key = base64.b64decode(secret.removeprefix("whsec_"), validate=True)
payload = f"{webhook_id}.{timestamp}.".encode() + raw_body
expected = base64.b64encode(hmac.new(key, payload, hashlib.sha256).digest())
for candidate in signature_header.split():
version, received = candidate.split(",", 1)
if version == "v1" and hmac.compare_digest(received.encode(), expected):
return True
except (ValueError, TypeError):
return False
return False
Events and payload#
Scroll sideways
| Event | When it arrives | Data |
|---|---|---|
message.received |
An incoming SMS, MMS, or RCS message matches the webhook filter. | webhook_id, message and conversation IDs, sender, recipients, transport, subject, body, sent time, and attachment metadata. |
webhook.test |
You select Send test. | webhook_id and message: This is a test event from Peppy. |
Example message.received payload:
{
"type": "message.received",
"timestamp": "2026-11-12T09:41:00Z",
"source": "https://example.com",
"data": {
"webhook_id": "00000000-0000-0000-0000-000000000000",
"message_id": "11111111-1111-1111-1111-111111111111",
"conversation_id": "22222222-2222-2222-2222-222222222222",
"from": { "address": "+15550100", "contact_name": null },
"to": ["+15550200"],
"transport": "sms",
"subject": null,
"body": "Hello",
"sent_at": "2026-11-12T09:40:00Z",
"attachments": [{ "id": "attachment-id", "content_type": "image/jpeg", "size": 12345 }]
}
}
Scroll sideways
| Field | Type | Notes |
|---|---|---|
type |
string | message.received or webhook.test. |
timestamp |
RFC 3339 timestamp | Time Peppy built the event. |
source |
string | The server's public origin. |
data.webhook_id |
UUID string | Webhook that received the event. |
data.message_id, data.conversation_id |
UUID strings | Present for message.received. |
data.from |
object | Sender address and contact_name, which can be null. |
data.to |
string array | Recipients. |
data.transport |
string | sms, mms, or rcs. |
data.subject, data.sent_at |
string or null |
Message subject and sent time. |
data.body |
string | Message text. |
data.attachments |
array | Each item has id, content_type, and size; the latter two can be null. |
Payloads, including body, from, and to, are plain text sent to your endpoint outside Peppy's encryption.
Delivery#
Scroll sideways
| Rule | Behavior |
|---|---|
| Delivery | At least once. Deduplicate with webhook-id. |
| Success | Return a 2xx response within 10 seconds. The whole attempt, including DNS, stops at 15 seconds. |
| Redirects | Peppy refuses them. |
| Retries | Peppy retries up to 5 times, waiting 5 seconds, then 1 minute, 10 minutes, 1 hour, and 6 hours after each failed attempt. After the 6th failure it drops the delivery and marks it failed. |
| Retryable failures | Network failures, 408, 425, 429, and 5xx responses. Other 4xx responses and 3xx responses fail permanently. |
| Paused webhook | Peppy holds queued deliveries until you resume it. Messages that arrive while it is paused are skipped, not sent later. |
| Changed URL or filter | Peppy discards queued deliveries for that webhook. Changing its name keeps them. |
| Backfill | None. Peppy skips imported history, messages more than 24 hours old, and messages sent more than five minutes before the webhook was created. |
Endpoint policy#
Your URL must use HTTPS, be at most 2,048 bytes, have no username or password, and resolve only to public addresses. Peppy blocks localhost, names ending in .localhost, and the Peppy server's own host.
Scroll sideways
| Address family | Blocked addresses |
|---|---|
| IPv4 | 0.0.0.0/8, 10.0.0.0/8, 100.64.0.0/10, 127.0.0.0/8, 169.254.0.0/16, 172.16.0.0/12, 192.0.0.0/24, 192.0.2.0/24, 192.168.0.0/16, 198.18.0.0/15, 198.51.100.0/24, 203.0.113.0/24, multicast 224.0.0.0/4, and 240.0.0.0/4 including 255.255.255.255. |
| IPv6 | Loopback, unspecified, multicast, fc00::/7, fe80::/10, fec0::/10, 2001:db8::/32, 2001::/32, and 64:ff9b:1::/48. Peppy also checks IPv4-compatible, IPv4-mapped, NAT64, and 6to4 addresses against the IPv4 list. |
Lifecycle#
Removing or re-enabling Peppy MCP deletes the vault's webhooks.