Signed lead webhooks
Each AIPages page can send every new lead to one HTTPS endpoint you control. Requests are signed with a per-page secret, carry a stable event ID for de-duplication, and are retried when your endpoint fails. This page documents the exact request so you can build and test a receiver.
Pro and Agency plans · Workspace owners, admins and editors can configure · Updated
AIPages POSTs a JSON lead.created event to your page's webhook URL. Verify the X-AIPages-Signature header by computing HMAC-SHA256 of "timestamp.rawBody" with the page's whsec_ signing secret, reject stale timestamps, and de-duplicate on the event ID (also sent as Idempotency-Key). Any 2xx response within 8 seconds counts as delivered; otherwise AIPages retries, up to six attempts in total. Webhooks are available on the Pro and Agency plans.
Set up a page webhook
- 1
Open the page settings
Open the page in the builder, click Styles in the toolbar and choose the Hook tab in Page Settings. The panel is titled "Signed Lead Webhook".
- 2
Enter your endpoint
Paste an
https://URL into Webhook URL. AIPages rejects plain HTTP, URLs with a username or password, URLs with a#fragment, and hosts that are or resolve to private, loopback, link-local or reserved network addresses. - 3
Save and copy the signing secret
Click Save Webhook. Saving generates the page's signing secret. Click Reveal, then Copy, and store it in your receiver's secret store. The secret starts with
whsec_. - 4
Send a test event
Click Save & Test. AIPages sends one signed test event immediately and shows either "Test event sent (evt_test_…)" or the error your endpoint caused.
On the Free plan you can enter a URL, but you can't reveal the secret or send a test, and no leads are sent to it. If a workspace moves from a paid plan to Free, queued webhook deliveries stop and are marked failed rather than retried.
The request AIPages sends
Every delivery is an HTTP POST with a JSON body. These headers are always present:
| Header | Value |
|---|---|
Content-Type | application/json |
User-Agent | AIPages-Webhook/1.0 |
X-AIPages-Event | lead.created (the only event type today) |
X-AIPages-Event-Id | The event ID. The same value is in the body's id field. |
Idempotency-Key | Same value as the event ID. |
X-AIPages-Delivery-Attempt | 1 for the first attempt, then 2, 3 and so on. |
X-AIPages-Signature | t=<unix seconds>,v1=<hex HMAC-SHA256> |
An example body, formatted for reading. Your receiver gets it as one compact line:
{
"id": "5b0f3c1e-8f3a-4f0e-9a51-2a7c1d9e4b10",
"type": "lead.created",
"api_version": "2026-09-05",
"created_at": "2026-11-05T09:00:00.000Z",
"livemode": true,
"data": {
"lead": {
"id": "a1d2c3b4-0000-4000-8000-000000000001",
"pageId": "b2c3d4e5-0000-4000-8000-000000000002",
"pageName": "Spring workshop waitlist",
"email": "reader@example.com",
"name": "Sam Rivera",
"customFields": { "Team size": "6-20" },
"source": "https://aipages.app/p/spring-workshop",
"createdAt": "2026-11-05T09:00:00.000Z"
}
}
}| Field | Notes |
|---|---|
email | Always present. Trimmed and lower-cased. |
name, phone | Omitted when the form doesn't collect them or the visitor left them blank. |
customFields | Keyed by each custom field's label as written in the builder. Omitted when empty. Renaming a field's label changes the key on later leads. |
source | The page address the form was submitted from (the browser's Referer, up to 255 characters), or direct when the browser sent none. |
pageId, pageName | The page that captured the lead. Leads captured by an A/B variant carry the variant's ID and name. |
livemode is true for events from the live AIPages service and false for test events. api_version is 2026-09-05; check it if you want your receiver to reject payload versions it hasn't been written for.
Verify the signature
The signature is a lowercase hex HMAC-SHA256. The key is the whole signing secret string, including the whsec_ prefix, as UTF-8. The signed message is the t value, a full stop, and the raw request body exactly as received. Parse JSON only after verifying: re-serialising a parsed body can change spacing or key order and break the comparison.
- Read the raw body bytes before any JSON middleware touches them.
- Split the header on commas into
tandv1. - Reject the request if
tis more than five minutes from your clock. This window is a recommendation; every attempt is signed at send time, so retries arrive with a fresh timestamp. - Compute the HMAC and compare it with
v1using a constant-time comparison.
import crypto from "node:crypto";
import express from "express";
const TOLERANCE_SECONDS = 300;
export function verifyAipagesSignature(rawBody, header, secret, now = Math.floor(Date.now() / 1000)) {
if (typeof header !== "string" || !secret) return false;
const parts = Object.fromEntries(
header.split(",").map((part) => {
const index = part.indexOf("=");
return [part.slice(0, index).trim(), part.slice(index + 1).trim()];
}),
);
const timestamp = Number(parts.t);
if (!Number.isInteger(timestamp) || !/^[0-9a-f]{64}$/.test(parts.v1 ?? "")) return false;
if (Math.abs(now - timestamp) > TOLERANCE_SECONDS) return false;
const expected = crypto.createHmac("sha256", secret).update(`${timestamp}.`).update(rawBody).digest();
return crypto.timingSafeEqual(expected, Buffer.from(parts.v1, "hex"));
}
const app = express();
app.post("/webhooks/aipages", express.raw({ type: "application/json" }), async (req, res) => {
const ok = verifyAipagesSignature(req.body, req.get("X-AIPages-Signature"), process.env.AIPAGES_WEBHOOK_SECRET);
if (!ok) return res.status(400).send("invalid signature");
const event = JSON.parse(req.body.toString("utf8"));
// Record event.id and your side effect in one transaction; skip if event.id was already processed.
await handleLeadOnce(event.id, event.data.lead);
res.sendStatus(204);
});import hashlib
import hmac
import json
import os
import time
from flask import Flask, abort, request
TOLERANCE_SECONDS = 300
def verify_aipages_signature(raw_body: bytes, header: str | None, secret: str, now: int | None = None) -> bool:
if not header or not secret:
return False
parts = dict(part.strip().split("=", 1) for part in header.split(",") if "=" in part)
try:
timestamp = int(parts["t"])
except (KeyError, ValueError):
return False
current = int(time.time()) if now is None else now
if abs(current - timestamp) > TOLERANCE_SECONDS:
return False
expected = hmac.new(secret.encode("utf-8"), f"{timestamp}.".encode("utf-8") + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, parts.get("v1", ""))
app = Flask(__name__)
@app.post("/webhooks/aipages")
def aipages_webhook():
raw = request.get_data()
if not verify_aipages_signature(raw, request.headers.get("X-AIPages-Signature"), os.environ["AIPAGES_WEBHOOK_SECRET"]):
abort(400)
event = json.loads(raw)
# Record event["id"] and your side effect in one transaction; skip if it was already processed.
handle_lead_once(event["id"], event["data"]["lead"])
return "", 204handleLeadOnce and handle_lead_once stand for your own code. To check your implementation without a live endpoint, use this test vector. It uses a made-up secret, so pass the timestamp as now to skip the age check:
| Input | Value |
|---|---|
| Secret | whsec_example_secret_do_not_use |
Timestamp (t) | 1793865600 |
| Raw body | The compact one-line form of the example body above, with no spaces or line breaks |
Expected v1 | 794adf2271606553c622112d656ac95f60667f05ed6d49754daac8c49af3b5d1 |
{"id":"5b0f3c1e-8f3a-4f0e-9a51-2a7c1d9e4b10","type":"lead.created","api_version":"2026-09-05","created_at":"2026-11-05T09:00:00.000Z","livemode":true,"data":{"lead":{"id":"a1d2c3b4-0000-4000-8000-000000000001","pageId":"b2c3d4e5-0000-4000-8000-000000000002","pageName":"Spring workshop waitlist","email":"reader@example.com","name":"Sam Rivera","customFields":{"Team size":"6-20"},"source":"https://aipages.app/p/spring-workshop","createdAt":"2026-11-05T09:00:00.000Z"}}}Replay protection and duplicate deliveries
AIPages may deliver the same event more than once. This happens, for example, if your endpoint stores the lead but times out before answering, or if someone clicks Retry delivery in the dashboard. Every attempt for one lead carries the same event ID, in the body's id, X-AIPages-Event-Id and Idempotency-Key. Only the timestamp, signature and attempt number change.
- Store each processed event ID with a unique constraint, in the same transaction as the work it triggers.
- When an ID is already stored, return a 2xx without repeating the work. An error status would make AIPages retry a delivery you have already handled.
- The timestamp check limits how long a captured request can be replayed. The event-ID check stops replays inside that window.
- Test events use IDs that start with
evt_test_and carry a placeholder lead (test@example.com, sourcewebhook-test). Treat them as tests, not as leads.
How AIPages reads your response
| Your endpoint | Result |
|---|---|
| Returns any 2xx status within 8 seconds | Delivered. The response body is ignored. |
| Returns 3xx | Failed. Redirects are not followed, so point the URL at the final address. |
| Returns 4xx or 5xx | Failed with "Webhook returned HTTP <status>." |
| Takes longer than 8 seconds or the connection fails | Failed with "Webhook delivery failed or timed out." |
| Hostname resolves to a private or reserved address | Failed with "Webhook URL must resolve to a public address." |
Answer quickly. If your processing is slow, store the event, return 204, and do the work in your own background job.
Retry timing
A lead's webhook delivery gets up to six attempts in total. After a failed attempt, the next one becomes due after a delay that doubles each time:
| After attempt | Next attempt due no sooner than |
|---|---|
| 1 | 15 seconds |
| 2 | 30 seconds |
| 3 | 1 minute |
| 4 | 2 minutes |
| 5 | 4 minutes |
| 6 | No further automatic attempts. The delivery is marked failed. |
A due attempt is sent when AIPages next processes its delivery queue. That happens when any lead is submitted, when a workspace member loads the dashboard, and on a scheduled job every 10 minutes. On a quiet account each retry usually waits for the scheduled job, so all six attempts can take about 50 minutes rather than eight. Build your receiver to accept late deliveries.
- The URL and signing secret are read when each attempt is sent. If you fix the URL or rotate the secret, pending retries use the new values.
- If you remove the webhook URL before a retry runs, that delivery is marked failed and not retried.
- Save & Test test events are sent once, straight away. They are not queued, not retried and not shown in the dashboard. You can send five tests per page per minute.
Signing secret management
- Each page has its own secret. Use a different secret value in your receiver for each page that posts to it, or identify the page from
data.lead.pageIdbefore choosing the secret. - Reveal shows the current secret to workspace owners, admins and editors on paid plans. Viewers cannot reveal it.
- Rotate replaces the secret immediately, after a confirmation prompt. There is no overlap period, so update your receiver at the same moment. Until you do, deliveries fail verification on your side; return an error so AIPages keeps retrying.
- Never paste the secret into front-end code, a public repository or a form field on your landing page.
A/B variants and webhooks
A Variant B page uses its original page's webhook URL and signing secret, so one receiver gets leads from both versions. Use data.lead.pageId or pageName to tell them apart. See A/B testing for how variants work.
Limits to know about
- ·One webhook URL per page. To send a lead to several systems, receive it once and fan out in your own code or in an automation tool's catch hook.
- ·Only the lead.created event exists. There are no events for page edits, publishing or lead deletion.
- ·The payload is fixed. You cannot rename fields or add static values in AIPages.
- ·There is no attempt-by-attempt history or stored response body. In the Leads tab, Delivery details shows each destination's current status, attempt count and latest error.