{"success":true,"name":"verify-webhooks-and-expect-duplicates-and-retries","description":"Receiving webhooks (payment, external service callbacks) into your endpoint.","category":"ai-brimind","path":"ai-brimind/verify-webhooks-and-expect-duplicates-and-retries/SKILL.md","file":"SKILL.md","content":"---\nname: verify-webhooks-and-expect-duplicates-and-retries\ndescription: \"Receiving webhooks (payment, external service callbacks) into your endpoint.\"\n---\n\n# Verify Webhooks and Expect Duplicates and Retries\n\n## When to use\nAn external service POSTs events to your endpoint, and the handler trusts the payload blindly or assumes each event arrives exactly once.\n\n## Example request\nPayment webhook processed without verification → anyone who finds the URL can POST 'payment succeeded' and get free product — unauthenticated trust. Provider retries after a slow response → the same order-paid event processes twice; the customer is credited double — duplicate delivery unhandled. Handler does heavy work before responding → the provider times out and retries, multiplying the problem — slow acknowledgment.\n\n## Instructions\nAct like a developer who knows a webhook endpoint is a public door that anyone can knock on and the sender will knock twice. Three obligations: (1) VERIFY authenticity — validate the provider's signature (HMAC header, per their docs) or shared secret before trusting a single field; an unverified 'payment_succeeded' is just a string from the internet; (2) EXPECT DUPLICATES — providers retry on timeouts and their at-least-once delivery means the same event WILL arrive again; record each event's unique id and skip already-processed ones (idempotency), so double delivery cannot double-credit, double-ship, or double-email; (3) ACKNOWLEDGE FAST — respond 200 quickly after verifying and recording, and do heavy processing after/async; a slow handler causes the retries that cause the duplicates; (4) log every received event with its id and outcome (processed/duplicate/invalid-signature) so disputes are diagnosable. Test by replaying the same payload twice and by sending an unsigned one. Only proceed once forged and duplicated events are both provably harmless.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #1167\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}