Webhook signature verify
FREE with proof-of-workor $0.001 in USDC
POST /api/webhook-verifyVerify a webhook's HMAC signature against the correct per-provider scheme: GitHub (X-Hub-Signature-256, sha256=hex), Stripe (Stripe-Signature t/v1 over "<t>.<body>" with replay tolerance), Shopify (X-Shopify-Hmac-Sha256, base64), Slack (X-Slack-Signature, v0:<ts>:<body> with replay tolerance).
Details
Constant-time comparison; the secret is never echoed. Pass the RAW request body string - signatures are over the raw bytes. Deterministic.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
provider | string | yes | github | stripe | shopify | slack The example sends github. |
payload | string | yes | the RAW request body string, byte-for-byte as received (never a re-serialized object) Also accepted as body, data, claims, message. The example sends {"hello":"world"}. |
secret | string | yes | the provider signing secret (never echoed back) Also accepted as key, password, passphrase. The example sends it's a secret. |
signature | string | yes | the signature header value, with or without its scheme prefix (sha256= / v0= / t=...,v1=...) |
timestamp | string | no | provider timestamp, required for stripe + slack (stripe may be parsed from a t= element in the signature) |
toleranceSeconds | number | no | max timestamp age for stripe/slack replay protection (default 300; 0 skips the age check) |
Free call, no wallet
Fetch a challenge, solve its sha256 puzzle (16 leading zero bits), resend with X-Pow-Solution.
import { createHash } from "node:crypto";
const lz = (b) => { let t = 0; for (const x of b) { if (!x) { t += 8; continue; } t += Math.clz32(x) - 24; break; } return t; };
const c = await (await fetch("https://agent402.tools/api/pow/challenge?slug=webhook-verify")).json();
let n = 0;
while (lz(createHash("sha256").update(c.challenge + ":" + n).digest()) < c.difficulty) n++;
await fetch("https://agent402.tools/api/webhook-verify", { method: "POST", headers: { "X-Pow-Solution": c.token + ":" + n, "Content-Type": "application/json" }, body: JSON.stringify({"provider":"github","payload":"{\"hello\":\"world\"}","secret":"it's a secret","signature":"sha256=8d4063f0a81aa1531d9891a028a68cf2bb537ecdf0e82557674d71e168d570f9"}) });Python:
import hashlib, json, urllib.request
def zero_bits(digest):
n = 0
for b in digest:
if b:
return n + 8 - b.bit_length()
n += 8
return n
c = json.load(urllib.request.urlopen("https://agent402.tools/api/pow/challenge?slug=webhook-verify"))
n = 0
while zero_bits(hashlib.sha256(f"{c['challenge']}:{n}".encode()).digest()) < c["difficulty"]:
n += 1
req = urllib.request.Request("https://agent402.tools/api/webhook-verify", method="POST", data="{\"provider\":\"github\",\"payload\":\"{\\\"hello\\\":\\\"world\\\"}\",\"secret\":\"it's a secret\",\"signature\":\"sha256=8d4063f0a81aa1531d9891a028a68cf2bb537ecdf0e82557674d71e168d570f9\"}".encode(), headers={"X-Pow-Solution": f"{c['token']}:{n}", "Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(req)))Example request
curl -i -X POST https://agent402.tools/api/webhook-verify \
-H "Content-Type: application/json" \
-d '{"provider":"github","payload":"{\"hello\":\"world\"}","secret":"it'\''s a secret","signature":"sha256=8d4063f0a81aa1531d9891a028a68cf2bb537ecdf0e82557674d71e168d570f9"}'Watch a call get paid
Request
POST /api/webhook-verify402
$0.001 USDCSign
PAYMENT-SIGNATURESettle
on 14 chainsAnswer
200 OKReceipt
Agent402-ReceiptEd25519Example response
{
"valid": true,
"provider": "github",
"scheme": "X-Hub-Signature-256: sha256=hex(HMAC-SHA256(secret, rawBody))",
"reason": "signature matches the recomputed HMAC for this payload and secret"
}| Field | Type | Always present | In the example |
|---|---|---|---|
valid | boolean | yes | true |
provider | string | yes | github |
scheme | string | yes | X-Hub-Signature-256: sha256=hex(HMAC-SHA256(secret, rawBody)) |
reason | string | yes | signature matches the recomputed HMAC for this payload and secret |
From an MCP client
catalog.call {
"slug": "webhook-verify",
"params": {
"provider": "github",
"payload": "{\"hello\":\"world\"}",
"secret": "it's a secret",
"signature": "sha256=8d4063f0a81aa1531d9891a028a68cf2bb537ecdf0e82557674d71e168d570f9"
}
}Hosted connector (https://agent402.tools/mcp): free, rate-limited. Stdio package: npx -y agent402-mcp@0.17.2.
Errors and behavior
- Pay $0.001 per call over x402 or MPP, or free with proof-of-work (16 leading zero bits of sha256): this tool makes no outbound network call.
- Required:
provider,payload,secretandsignature; a rejected input answers 4xx witherror,tool,expected,requiredandexample. - On this route, a call ending in any status of 400 or above is not charged over x402, MPP or a credits key. A Tempo push credential pays before the call; a failure is a refund owed.
- A bodyless
GETorHEADreturns the same 402 quote. - An
Idempotency-Keyreplays the first 200 uncharged (an answer larger than 1 MB is not replayed).
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.001" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.AGENT_KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://agent402.tools/api/webhook-verify", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"provider": "github",
"payload": "{\"hello\":\"world\"}",
"secret": "it's a secret",
"signature": "sha256=8d4063f0a81aa1531d9891a028a68cf2bb537ecdf0e82557674d71e168d570f9"
}),
});Get a wallet or run npx -y agent402-mcp@0.17.2 wallet new.