[{"data":1,"prerenderedAt":2645},["ShallowReactive",2],{"content-query-EM0ZFZC4Gn":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"layout":10,"head":11,"author":14,"tags":15,"categories":20,"date":22,"faq":23,"body":42,"_type":2638,"_id":2639,"_source":2640,"_file":2641,"_stem":2642,"_extension":2643,"sitemap":2644,"readingTime":656},"/blog/stripe-webhook-signature-verification","blog",false,"","Stripe Webhook Signature Verification: Fix the Three Common Errors","Signature mismatch? Check the raw request body and the endpoint's whsec_ secret. Timestamp error? Check clock drift and delayed forwarding. Header error? Make sure Stripe-Signature reaches your handler intact.","post",{"title":12,"description":13},"Stripe Webhook Signature Verification Errors, Fixed","Why Stripe webhook signature verification fails: raw body parsing, the wrong whsec_ secret, and late retries or replays outside Stripe's 5-minute tolerance. Fixes for Express, Next.js and FastAPI.","Karolis Rusenas",[16,17,18,19],"stripe","webhooks","signature verification","security",[21],"guides","2026-11-28 12:00:00",[24,27,30,33,36,39],{"q":25,"a":26},"How does Stripe webhook signature verification work?","Stripe sends a Stripe-Signature header such as t=1732790000,v1=5257a8.... The v1 value is an HMAC-SHA256 of the timestamp, a dot and the raw request body, keyed with the endpoint's signing secret (whsec_...). Your server recomputes that HMAC with the same secret, compares it in constant time, and checks that the timestamp is no more than 5 minutes old. Stripe's SDKs do all of this in stripe.webhooks.constructEvent (Node) or stripe.Webhook.construct_event (Python).",{"q":28,"a":29},"Why do I get 'No signatures found matching the expected signature for payload'?","The HMAC your server computed doesn't match Stripe's. Almost always the body was parsed and re-serialized as JSON before verification (express.json(), a framework body parser, or req.json() in Next.js), or you used the wrong secret: the Stripe CLI's stripe listen secret instead of the Dashboard endpoint's, a test-mode secret in live mode, or the secret of a different endpoint. Pass the raw request bytes and the secret of the endpoint that sent the event.",{"q":31,"a":32},"Where do I find the Stripe webhook signing secret?","In the Stripe Dashboard, open Workbench, go to the Webhooks tab, select the endpoint and click 'Click to reveal' next to the signing secret, which starts with whsec_. Each endpoint, and test and live mode, has its own secret. When forwarding with the Stripe CLI, stripe listen prints a different secret: 'Ready! Your webhook signing secret is whsec_...'.",{"q":34,"a":35},"What does 'Timestamp outside the tolerance zone' mean?","The signature is valid but its timestamp is more than 5 minutes (300 seconds) away from your server's clock. Either your server's clock is wrong, or the request was delivered late by something between Stripe and your server, such as a proxy retry, a queue, a replay of a captured request, or an agent that was offline. Stripe's own retries are signed fresh each time, so they don't cause it.",{"q":37,"a":38},"Should I increase the Stripe webhook tolerance?","Avoid it. The tolerance argument to constructEvent can be raised, but it widens the window in which a captured webhook can be replayed against you. Fix clock drift with NTP, and if a gateway or queue delivers webhooks late, have it re-sign them with a fresh timestamp instead.",{"q":40,"a":41},"Can a webhook proxy re-sign Stripe webhooks?","Yes, if it knows the endpoint's signing secret. Webhook Relay verifies the Stripe-Signature when the webhook arrives and, with re-sign on delivery turned on, signs every delivery attempt again with the same secret and the current time. Your server keeps calling constructEvent with its existing secret and default tolerance, and retries, replays and late agent deliveries pass.",{"type":43,"children":44,"toc":2624},"root",[45,66,199,212,219,231,240,295,330,342,348,360,386,896,921,1370,1388,1752,1765,1778,1817,1822,1877,1897,1903,1929,1961,1984,2020,2032,2039,2049,2111,2139,2152,2158,2176,2189,2222,2285,2291,2296,2467,2473,2585,2598,2618],{"type":46,"tag":47,"props":48,"children":49},"element","p",{},[50],{"type":46,"tag":51,"props":52,"children":53},"strong",{},[54,57,64],{"type":55,"value":56},"text","Find the error ",{"type":46,"tag":58,"props":59,"children":61},"code",{"className":60},[],[62],{"type":55,"value":63},"constructEvent",{"type":55,"value":65}," threw in the table, then jump to its fix.",{"type":46,"tag":67,"props":68,"children":69},"table",{},[70,99],{"type":46,"tag":71,"props":72,"children":73},"thead",{},[74],{"type":46,"tag":75,"props":76,"children":77},"tr",{},[78,89,94],{"type":46,"tag":79,"props":80,"children":81},"th",{},[82,84],{"type":55,"value":83},"Error from ",{"type":46,"tag":58,"props":85,"children":87},{"className":86},[],[88],{"type":55,"value":63},{"type":46,"tag":79,"props":90,"children":91},{},[92],{"type":55,"value":93},"What it means",{"type":46,"tag":79,"props":95,"children":96},{},[97],{"type":55,"value":98},"Fix",{"type":46,"tag":100,"props":101,"children":102},"tbody",{},[103,139,165],{"type":46,"tag":75,"props":104,"children":105},{},[106,116,121],{"type":46,"tag":107,"props":108,"children":109},"td",{},[110],{"type":46,"tag":58,"props":111,"children":113},{"className":112},[],[114],{"type":55,"value":115},"No signatures found matching the expected signature for payload",{"type":46,"tag":107,"props":117,"children":118},{},[119],{"type":55,"value":120},"A parser changed the body, or the secret is wrong",{"type":46,"tag":107,"props":122,"children":123},{},[124,131,133],{"type":46,"tag":125,"props":126,"children":128},"a",{"href":127},"#fix-1-verify-the-raw-body",[129],{"type":55,"value":130},"Raw body",{"type":55,"value":132}," · ",{"type":46,"tag":125,"props":134,"children":136},{"href":135},"#fix-2-use-the-right-whsec_-secret",[137],{"type":55,"value":138},"Secret",{"type":46,"tag":75,"props":140,"children":141},{},[142,151,156],{"type":46,"tag":107,"props":143,"children":144},{},[145],{"type":46,"tag":58,"props":146,"children":148},{"className":147},[],[149],{"type":55,"value":150},"Timestamp outside the tolerance zone",{"type":46,"tag":107,"props":152,"children":153},{},[154],{"type":55,"value":155},"The signature matched, but its timestamp failed the 5-minute check: clock drift or delayed forwarding",{"type":46,"tag":107,"props":157,"children":158},{},[159],{"type":46,"tag":125,"props":160,"children":162},{"href":161},"#fix-3-timestamp-outside-the-tolerance-zone",[163],{"type":55,"value":164},"Timing",{"type":46,"tag":75,"props":166,"children":167},{},[168,177,190],{"type":46,"tag":107,"props":169,"children":170},{},[171],{"type":46,"tag":58,"props":172,"children":174},{"className":173},[],[175],{"type":55,"value":176},"Unable to extract timestamp and signatures from header",{"type":46,"tag":107,"props":178,"children":179},{},[180,182,188],{"type":55,"value":181},"The ",{"type":46,"tag":58,"props":183,"children":185},{"className":184},[],[186],{"type":55,"value":187},"Stripe-Signature",{"type":55,"value":189}," header is missing or mangled",{"type":46,"tag":107,"props":191,"children":192},{},[193],{"type":46,"tag":125,"props":194,"children":196},{"href":195},"#fix-4-pass-the-stripe-signature-header-through",[197],{"type":55,"value":198},"Header",{"type":46,"tag":47,"props":200,"children":201},{},[202,204,210],{"type":55,"value":203},"Stripe signs every delivery attempt fresh, including its own retries, so the timestamp error almost always points at something ",{"type":46,"tag":205,"props":206,"children":207},"em",{},[208],{"type":55,"value":209},"between",{"type":55,"value":211}," Stripe and your server. Python's version of that error also appends the timestamp.",{"type":46,"tag":213,"props":214,"children":216},"h2",{"id":215},"how-stripe-signs-a-webhook",[217],{"type":55,"value":218},"How Stripe signs a webhook",{"type":46,"tag":47,"props":220,"children":221},{},[222,224,229],{"type":55,"value":223},"Every Stripe webhook carries a ",{"type":46,"tag":58,"props":225,"children":227},{"className":226},[],[228],{"type":55,"value":187},{"type":55,"value":230}," header:",{"type":46,"tag":232,"props":233,"children":235},"pre",{"code":234},"Stripe-Signature: t=1732790000,v1=5257a869e7ecebeda32aff…\n",[236],{"type":46,"tag":58,"props":237,"children":238},{"__ignoreMap":7},[239],{"type":55,"value":234},{"type":46,"tag":241,"props":242,"children":243},"ul",{},[244,256,275],{"type":46,"tag":245,"props":246,"children":247},"li",{},[248,254],{"type":46,"tag":58,"props":249,"children":251},{"className":250},[],[252],{"type":55,"value":253},"t",{"type":55,"value":255}," is the Unix time when Stripe signed this delivery.",{"type":46,"tag":245,"props":257,"children":258},{},[259,265,267,273],{"type":46,"tag":58,"props":260,"children":262},{"className":261},[],[263],{"type":55,"value":264},"v1",{"type":55,"value":266}," is ",{"type":46,"tag":58,"props":268,"children":270},{"className":269},[],[271],{"type":55,"value":272},"HMAC-SHA256(secret, t + \".\" + rawBody)",{"type":55,"value":274},", in hex.",{"type":46,"tag":245,"props":276,"children":277},{},[278,280,285,287,293],{"type":55,"value":279},"The secret is the endpoint's ",{"type":46,"tag":51,"props":281,"children":282},{},[283],{"type":55,"value":284},"signing secret",{"type":55,"value":286},", which starts with ",{"type":46,"tag":58,"props":288,"children":290},{"className":289},[],[291],{"type":55,"value":292},"whsec_",{"type":55,"value":294},". The whole string, prefix included, is the key.",{"type":46,"tag":47,"props":296,"children":297},{},[298,300,305,307,312,314,320,322,328],{"type":55,"value":299},"To verify, your server recomputes the HMAC over the raw body, compares it in constant time, and rejects the request if ",{"type":46,"tag":58,"props":301,"children":303},{"className":302},[],[304],{"type":55,"value":253},{"type":55,"value":306}," is more than ",{"type":46,"tag":51,"props":308,"children":309},{},[310],{"type":55,"value":311},"300 seconds",{"type":55,"value":313}," from its own clock. That check is what stops an attacker who captured one real webhook from replaying it later. Stripe's SDKs do all of it in one call: ",{"type":46,"tag":58,"props":315,"children":317},{"className":316},[],[318],{"type":55,"value":319},"stripe.webhooks.constructEvent",{"type":55,"value":321}," in Node, ",{"type":46,"tag":58,"props":323,"children":325},{"className":324},[],[326],{"type":55,"value":327},"stripe.Webhook.construct_event",{"type":55,"value":329}," in Python.",{"type":46,"tag":47,"props":331,"children":332},{},[333,335,340],{"type":55,"value":334},"When you roll the secret, Stripe can keep the old one active for up to 7 days and sends one ",{"type":46,"tag":58,"props":336,"children":338},{"className":337},[],[339],{"type":55,"value":264},{"type":55,"value":341}," value per active secret. A match on any of them is valid.",{"type":46,"tag":213,"props":343,"children":345},{"id":344},"fix-1-verify-the-raw-body",[346],{"type":55,"value":347},"Fix 1: verify the raw body",{"type":46,"tag":47,"props":349,"children":350},{},[351,353,358],{"type":55,"value":352},"The HMAC is computed over the exact bytes Stripe sent. If a body parser turns them into an object and your code serializes it back, whitespace and key order change and the signature no longer matches. This is the most common cause of ",{"type":46,"tag":58,"props":354,"children":356},{"className":355},[],[357],{"type":55,"value":115},{"type":55,"value":359},".",{"type":46,"tag":47,"props":361,"children":362},{},[363,368,370,376,378,384],{"type":46,"tag":51,"props":364,"children":365},{},[366],{"type":55,"value":367},"Express.",{"type":55,"value":369}," Mount ",{"type":46,"tag":58,"props":371,"children":373},{"className":372},[],[374],{"type":55,"value":375},"express.raw()",{"type":55,"value":377}," on the webhook route, and register the route before any global ",{"type":46,"tag":58,"props":379,"children":381},{"className":380},[],[382],{"type":55,"value":383},"express.json()",{"type":55,"value":385},":",{"type":46,"tag":232,"props":387,"children":391},{"code":388,"language":389,"meta":7,"className":390,"style":7},"const express = require('express')\nconst stripe = require('stripe')(process.env.STRIPE_SECRET_KEY)\nconst app = express()\n\napp.post('/stripe/webhook', express.raw({ type: 'application/json' }), (req, res) => {\n  let event\n  try {\n    event = stripe.webhooks.constructEvent(\n      req.body, // a Buffer, not an object\n      req.headers['stripe-signature'],\n      process.env.STRIPE_WEBHOOK_SECRET\n    )\n  } catch (err) {\n    return res.status(400).send(`Webhook Error: ${err.message}`)\n  }\n  // handle event.type ...\n  res.json({ received: true })\n})\n\napp.use(express.json()) // everything else\n","js","language-js shiki shiki-themes github-dark",[392],{"type":46,"tag":58,"props":393,"children":394},{"__ignoreMap":7},[395,441,485,511,521,599,613,626,654,669,688,702,711,730,800,809,818,847,856,864],{"type":46,"tag":396,"props":397,"children":400},"span",{"class":398,"line":399},"line",1,[401,407,413,418,424,430,436],{"type":46,"tag":396,"props":402,"children":404},{"style":403},"--shiki-default:#F97583",[405],{"type":55,"value":406},"const",{"type":46,"tag":396,"props":408,"children":410},{"style":409},"--shiki-default:#79B8FF",[411],{"type":55,"value":412}," express",{"type":46,"tag":396,"props":414,"children":415},{"style":403},[416],{"type":55,"value":417}," =",{"type":46,"tag":396,"props":419,"children":421},{"style":420},"--shiki-default:#B392F0",[422],{"type":55,"value":423}," require",{"type":46,"tag":396,"props":425,"children":427},{"style":426},"--shiki-default:#E1E4E8",[428],{"type":55,"value":429},"(",{"type":46,"tag":396,"props":431,"children":433},{"style":432},"--shiki-default:#9ECBFF",[434],{"type":55,"value":435},"'express'",{"type":46,"tag":396,"props":437,"children":438},{"style":426},[439],{"type":55,"value":440},")\n",{"type":46,"tag":396,"props":442,"children":444},{"class":398,"line":443},2,[445,449,454,458,462,466,471,476,481],{"type":46,"tag":396,"props":446,"children":447},{"style":403},[448],{"type":55,"value":406},{"type":46,"tag":396,"props":450,"children":451},{"style":409},[452],{"type":55,"value":453}," stripe",{"type":46,"tag":396,"props":455,"children":456},{"style":403},[457],{"type":55,"value":417},{"type":46,"tag":396,"props":459,"children":460},{"style":420},[461],{"type":55,"value":423},{"type":46,"tag":396,"props":463,"children":464},{"style":426},[465],{"type":55,"value":429},{"type":46,"tag":396,"props":467,"children":468},{"style":432},[469],{"type":55,"value":470},"'stripe'",{"type":46,"tag":396,"props":472,"children":473},{"style":426},[474],{"type":55,"value":475},")(process.env.",{"type":46,"tag":396,"props":477,"children":478},{"style":409},[479],{"type":55,"value":480},"STRIPE_SECRET_KEY",{"type":46,"tag":396,"props":482,"children":483},{"style":426},[484],{"type":55,"value":440},{"type":46,"tag":396,"props":486,"children":488},{"class":398,"line":487},3,[489,493,498,502,506],{"type":46,"tag":396,"props":490,"children":491},{"style":403},[492],{"type":55,"value":406},{"type":46,"tag":396,"props":494,"children":495},{"style":409},[496],{"type":55,"value":497}," app",{"type":46,"tag":396,"props":499,"children":500},{"style":403},[501],{"type":55,"value":417},{"type":46,"tag":396,"props":503,"children":504},{"style":420},[505],{"type":55,"value":412},{"type":46,"tag":396,"props":507,"children":508},{"style":426},[509],{"type":55,"value":510},"()\n",{"type":46,"tag":396,"props":512,"children":514},{"class":398,"line":513},4,[515],{"type":46,"tag":396,"props":516,"children":518},{"emptyLinePlaceholder":517},true,[519],{"type":55,"value":520},"\n",{"type":46,"tag":396,"props":522,"children":524},{"class":398,"line":523},5,[525,530,534,538,543,548,553,558,563,568,574,579,584,589,594],{"type":46,"tag":396,"props":526,"children":527},{"style":426},[528],{"type":55,"value":529},"app.",{"type":46,"tag":396,"props":531,"children":532},{"style":420},[533],{"type":55,"value":10},{"type":46,"tag":396,"props":535,"children":536},{"style":426},[537],{"type":55,"value":429},{"type":46,"tag":396,"props":539,"children":540},{"style":432},[541],{"type":55,"value":542},"'/stripe/webhook'",{"type":46,"tag":396,"props":544,"children":545},{"style":426},[546],{"type":55,"value":547},", express.",{"type":46,"tag":396,"props":549,"children":550},{"style":420},[551],{"type":55,"value":552},"raw",{"type":46,"tag":396,"props":554,"children":555},{"style":426},[556],{"type":55,"value":557},"({ type: ",{"type":46,"tag":396,"props":559,"children":560},{"style":432},[561],{"type":55,"value":562},"'application/json'",{"type":46,"tag":396,"props":564,"children":565},{"style":426},[566],{"type":55,"value":567}," }), (",{"type":46,"tag":396,"props":569,"children":571},{"style":570},"--shiki-default:#FFAB70",[572],{"type":55,"value":573},"req",{"type":46,"tag":396,"props":575,"children":576},{"style":426},[577],{"type":55,"value":578},", ",{"type":46,"tag":396,"props":580,"children":581},{"style":570},[582],{"type":55,"value":583},"res",{"type":46,"tag":396,"props":585,"children":586},{"style":426},[587],{"type":55,"value":588},") ",{"type":46,"tag":396,"props":590,"children":591},{"style":403},[592],{"type":55,"value":593},"=>",{"type":46,"tag":396,"props":595,"children":596},{"style":426},[597],{"type":55,"value":598}," {\n",{"type":46,"tag":396,"props":600,"children":602},{"class":398,"line":601},6,[603,608],{"type":46,"tag":396,"props":604,"children":605},{"style":403},[606],{"type":55,"value":607},"  let",{"type":46,"tag":396,"props":609,"children":610},{"style":426},[611],{"type":55,"value":612}," event\n",{"type":46,"tag":396,"props":614,"children":616},{"class":398,"line":615},7,[617,622],{"type":46,"tag":396,"props":618,"children":619},{"style":403},[620],{"type":55,"value":621},"  try",{"type":46,"tag":396,"props":623,"children":624},{"style":426},[625],{"type":55,"value":598},{"type":46,"tag":396,"props":627,"children":629},{"class":398,"line":628},8,[630,635,640,645,649],{"type":46,"tag":396,"props":631,"children":632},{"style":426},[633],{"type":55,"value":634},"    event ",{"type":46,"tag":396,"props":636,"children":637},{"style":403},[638],{"type":55,"value":639},"=",{"type":46,"tag":396,"props":641,"children":642},{"style":426},[643],{"type":55,"value":644}," stripe.webhooks.",{"type":46,"tag":396,"props":646,"children":647},{"style":420},[648],{"type":55,"value":63},{"type":46,"tag":396,"props":650,"children":651},{"style":426},[652],{"type":55,"value":653},"(\n",{"type":46,"tag":396,"props":655,"children":657},{"class":398,"line":656},9,[658,663],{"type":46,"tag":396,"props":659,"children":660},{"style":426},[661],{"type":55,"value":662},"      req.body, ",{"type":46,"tag":396,"props":664,"children":666},{"style":665},"--shiki-default:#6A737D",[667],{"type":55,"value":668},"// a Buffer, not an object\n",{"type":46,"tag":396,"props":670,"children":672},{"class":398,"line":671},10,[673,678,683],{"type":46,"tag":396,"props":674,"children":675},{"style":426},[676],{"type":55,"value":677},"      req.headers[",{"type":46,"tag":396,"props":679,"children":680},{"style":432},[681],{"type":55,"value":682},"'stripe-signature'",{"type":46,"tag":396,"props":684,"children":685},{"style":426},[686],{"type":55,"value":687},"],\n",{"type":46,"tag":396,"props":689,"children":691},{"class":398,"line":690},11,[692,697],{"type":46,"tag":396,"props":693,"children":694},{"style":426},[695],{"type":55,"value":696},"      process.env.",{"type":46,"tag":396,"props":698,"children":699},{"style":409},[700],{"type":55,"value":701},"STRIPE_WEBHOOK_SECRET\n",{"type":46,"tag":396,"props":703,"children":705},{"class":398,"line":704},12,[706],{"type":46,"tag":396,"props":707,"children":708},{"style":426},[709],{"type":55,"value":710},"    )\n",{"type":46,"tag":396,"props":712,"children":714},{"class":398,"line":713},13,[715,720,725],{"type":46,"tag":396,"props":716,"children":717},{"style":426},[718],{"type":55,"value":719},"  } ",{"type":46,"tag":396,"props":721,"children":722},{"style":403},[723],{"type":55,"value":724},"catch",{"type":46,"tag":396,"props":726,"children":727},{"style":426},[728],{"type":55,"value":729}," (err) {\n",{"type":46,"tag":396,"props":731,"children":733},{"class":398,"line":732},14,[734,739,744,749,753,758,763,768,772,777,782,786,791,796],{"type":46,"tag":396,"props":735,"children":736},{"style":403},[737],{"type":55,"value":738},"    return",{"type":46,"tag":396,"props":740,"children":741},{"style":426},[742],{"type":55,"value":743}," res.",{"type":46,"tag":396,"props":745,"children":746},{"style":420},[747],{"type":55,"value":748},"status",{"type":46,"tag":396,"props":750,"children":751},{"style":426},[752],{"type":55,"value":429},{"type":46,"tag":396,"props":754,"children":755},{"style":409},[756],{"type":55,"value":757},"400",{"type":46,"tag":396,"props":759,"children":760},{"style":426},[761],{"type":55,"value":762},").",{"type":46,"tag":396,"props":764,"children":765},{"style":420},[766],{"type":55,"value":767},"send",{"type":46,"tag":396,"props":769,"children":770},{"style":426},[771],{"type":55,"value":429},{"type":46,"tag":396,"props":773,"children":774},{"style":432},[775],{"type":55,"value":776},"`Webhook Error: ${",{"type":46,"tag":396,"props":778,"children":779},{"style":426},[780],{"type":55,"value":781},"err",{"type":46,"tag":396,"props":783,"children":784},{"style":432},[785],{"type":55,"value":359},{"type":46,"tag":396,"props":787,"children":788},{"style":426},[789],{"type":55,"value":790},"message",{"type":46,"tag":396,"props":792,"children":793},{"style":432},[794],{"type":55,"value":795},"}`",{"type":46,"tag":396,"props":797,"children":798},{"style":426},[799],{"type":55,"value":440},{"type":46,"tag":396,"props":801,"children":803},{"class":398,"line":802},15,[804],{"type":46,"tag":396,"props":805,"children":806},{"style":426},[807],{"type":55,"value":808},"  }\n",{"type":46,"tag":396,"props":810,"children":812},{"class":398,"line":811},16,[813],{"type":46,"tag":396,"props":814,"children":815},{"style":665},[816],{"type":55,"value":817},"  // handle event.type ...\n",{"type":46,"tag":396,"props":819,"children":821},{"class":398,"line":820},17,[822,827,832,837,842],{"type":46,"tag":396,"props":823,"children":824},{"style":426},[825],{"type":55,"value":826},"  res.",{"type":46,"tag":396,"props":828,"children":829},{"style":420},[830],{"type":55,"value":831},"json",{"type":46,"tag":396,"props":833,"children":834},{"style":426},[835],{"type":55,"value":836},"({ received: ",{"type":46,"tag":396,"props":838,"children":839},{"style":409},[840],{"type":55,"value":841},"true",{"type":46,"tag":396,"props":843,"children":844},{"style":426},[845],{"type":55,"value":846}," })\n",{"type":46,"tag":396,"props":848,"children":850},{"class":398,"line":849},18,[851],{"type":46,"tag":396,"props":852,"children":853},{"style":426},[854],{"type":55,"value":855},"})\n",{"type":46,"tag":396,"props":857,"children":859},{"class":398,"line":858},19,[860],{"type":46,"tag":396,"props":861,"children":862},{"emptyLinePlaceholder":517},[863],{"type":55,"value":520},{"type":46,"tag":396,"props":865,"children":867},{"class":398,"line":866},20,[868,872,877,882,886,891],{"type":46,"tag":396,"props":869,"children":870},{"style":426},[871],{"type":55,"value":529},{"type":46,"tag":396,"props":873,"children":874},{"style":420},[875],{"type":55,"value":876},"use",{"type":46,"tag":396,"props":878,"children":879},{"style":426},[880],{"type":55,"value":881},"(express.",{"type":46,"tag":396,"props":883,"children":884},{"style":420},[885],{"type":55,"value":831},{"type":46,"tag":396,"props":887,"children":888},{"style":426},[889],{"type":55,"value":890},"()) ",{"type":46,"tag":396,"props":892,"children":893},{"style":665},[894],{"type":55,"value":895},"// everything else\n",{"type":46,"tag":47,"props":897,"children":898},{},[899,904,906,912,914,920],{"type":46,"tag":51,"props":900,"children":901},{},[902],{"type":55,"value":903},"Next.js (App Router).",{"type":55,"value":905}," Read the body with ",{"type":46,"tag":58,"props":907,"children":909},{"className":908},[],[910],{"type":55,"value":911},"req.text()",{"type":55,"value":913},", never ",{"type":46,"tag":58,"props":915,"children":917},{"className":916},[],[918],{"type":55,"value":919},"req.json()",{"type":55,"value":385},{"type":46,"tag":232,"props":922,"children":926},{"code":923,"language":924,"meta":7,"className":925,"style":7},"// app/api/stripe/webhook/route.ts\nimport Stripe from 'stripe'\nconst stripe = new Stripe(process.env.STRIPE_SECRET_KEY!)\n\nexport async function POST(req: Request) {\n  const body = await req.text()\n  const sig = req.headers.get('stripe-signature')!\n  let event: Stripe.Event\n  try {\n    event = stripe.webhooks.constructEvent(\n      body,\n      sig,\n      process.env.STRIPE_WEBHOOK_SECRET!\n    )\n  } catch (err) {\n    return new Response(`Webhook Error: ${(err as Error).message}`, { status: 400 })\n  }\n  // handle event.type ...\n  return Response.json({ received: true })\n}\n","ts","language-ts shiki shiki-themes github-dark",[927],{"type":46,"tag":58,"props":928,"children":929},{"__ignoreMap":7},[930,938,961,1004,1011,1056,1091,1135,1164,1175,1198,1206,1214,1230,1237,1252,1319,1326,1333,1362],{"type":46,"tag":396,"props":931,"children":932},{"class":398,"line":399},[933],{"type":46,"tag":396,"props":934,"children":935},{"style":665},[936],{"type":55,"value":937},"// app/api/stripe/webhook/route.ts\n",{"type":46,"tag":396,"props":939,"children":940},{"class":398,"line":443},[941,946,951,956],{"type":46,"tag":396,"props":942,"children":943},{"style":403},[944],{"type":55,"value":945},"import",{"type":46,"tag":396,"props":947,"children":948},{"style":426},[949],{"type":55,"value":950}," Stripe ",{"type":46,"tag":396,"props":952,"children":953},{"style":403},[954],{"type":55,"value":955},"from",{"type":46,"tag":396,"props":957,"children":958},{"style":432},[959],{"type":55,"value":960}," 'stripe'\n",{"type":46,"tag":396,"props":962,"children":963},{"class":398,"line":487},[964,968,972,976,981,986,991,995,1000],{"type":46,"tag":396,"props":965,"children":966},{"style":403},[967],{"type":55,"value":406},{"type":46,"tag":396,"props":969,"children":970},{"style":409},[971],{"type":55,"value":453},{"type":46,"tag":396,"props":973,"children":974},{"style":403},[975],{"type":55,"value":417},{"type":46,"tag":396,"props":977,"children":978},{"style":403},[979],{"type":55,"value":980}," new",{"type":46,"tag":396,"props":982,"children":983},{"style":420},[984],{"type":55,"value":985}," Stripe",{"type":46,"tag":396,"props":987,"children":988},{"style":426},[989],{"type":55,"value":990},"(process.env.",{"type":46,"tag":396,"props":992,"children":993},{"style":409},[994],{"type":55,"value":480},{"type":46,"tag":396,"props":996,"children":997},{"style":403},[998],{"type":55,"value":999},"!",{"type":46,"tag":396,"props":1001,"children":1002},{"style":426},[1003],{"type":55,"value":440},{"type":46,"tag":396,"props":1005,"children":1006},{"class":398,"line":513},[1007],{"type":46,"tag":396,"props":1008,"children":1009},{"emptyLinePlaceholder":517},[1010],{"type":55,"value":520},{"type":46,"tag":396,"props":1012,"children":1013},{"class":398,"line":523},[1014,1019,1024,1029,1034,1038,1042,1046,1051],{"type":46,"tag":396,"props":1015,"children":1016},{"style":403},[1017],{"type":55,"value":1018},"export",{"type":46,"tag":396,"props":1020,"children":1021},{"style":403},[1022],{"type":55,"value":1023}," async",{"type":46,"tag":396,"props":1025,"children":1026},{"style":403},[1027],{"type":55,"value":1028}," function",{"type":46,"tag":396,"props":1030,"children":1031},{"style":420},[1032],{"type":55,"value":1033}," POST",{"type":46,"tag":396,"props":1035,"children":1036},{"style":426},[1037],{"type":55,"value":429},{"type":46,"tag":396,"props":1039,"children":1040},{"style":570},[1041],{"type":55,"value":573},{"type":46,"tag":396,"props":1043,"children":1044},{"style":403},[1045],{"type":55,"value":385},{"type":46,"tag":396,"props":1047,"children":1048},{"style":420},[1049],{"type":55,"value":1050}," Request",{"type":46,"tag":396,"props":1052,"children":1053},{"style":426},[1054],{"type":55,"value":1055},") {\n",{"type":46,"tag":396,"props":1057,"children":1058},{"class":398,"line":601},[1059,1064,1069,1073,1078,1083,1087],{"type":46,"tag":396,"props":1060,"children":1061},{"style":403},[1062],{"type":55,"value":1063},"  const",{"type":46,"tag":396,"props":1065,"children":1066},{"style":409},[1067],{"type":55,"value":1068}," body",{"type":46,"tag":396,"props":1070,"children":1071},{"style":403},[1072],{"type":55,"value":417},{"type":46,"tag":396,"props":1074,"children":1075},{"style":403},[1076],{"type":55,"value":1077}," await",{"type":46,"tag":396,"props":1079,"children":1080},{"style":426},[1081],{"type":55,"value":1082}," req.",{"type":46,"tag":396,"props":1084,"children":1085},{"style":420},[1086],{"type":55,"value":55},{"type":46,"tag":396,"props":1088,"children":1089},{"style":426},[1090],{"type":55,"value":510},{"type":46,"tag":396,"props":1092,"children":1093},{"class":398,"line":615},[1094,1098,1103,1107,1112,1117,1121,1125,1130],{"type":46,"tag":396,"props":1095,"children":1096},{"style":403},[1097],{"type":55,"value":1063},{"type":46,"tag":396,"props":1099,"children":1100},{"style":409},[1101],{"type":55,"value":1102}," sig",{"type":46,"tag":396,"props":1104,"children":1105},{"style":403},[1106],{"type":55,"value":417},{"type":46,"tag":396,"props":1108,"children":1109},{"style":426},[1110],{"type":55,"value":1111}," req.headers.",{"type":46,"tag":396,"props":1113,"children":1114},{"style":420},[1115],{"type":55,"value":1116},"get",{"type":46,"tag":396,"props":1118,"children":1119},{"style":426},[1120],{"type":55,"value":429},{"type":46,"tag":396,"props":1122,"children":1123},{"style":432},[1124],{"type":55,"value":682},{"type":46,"tag":396,"props":1126,"children":1127},{"style":426},[1128],{"type":55,"value":1129},")",{"type":46,"tag":396,"props":1131,"children":1132},{"style":403},[1133],{"type":55,"value":1134},"!\n",{"type":46,"tag":396,"props":1136,"children":1137},{"class":398,"line":628},[1138,1142,1147,1151,1155,1159],{"type":46,"tag":396,"props":1139,"children":1140},{"style":403},[1141],{"type":55,"value":607},{"type":46,"tag":396,"props":1143,"children":1144},{"style":426},[1145],{"type":55,"value":1146}," event",{"type":46,"tag":396,"props":1148,"children":1149},{"style":403},[1150],{"type":55,"value":385},{"type":46,"tag":396,"props":1152,"children":1153},{"style":420},[1154],{"type":55,"value":985},{"type":46,"tag":396,"props":1156,"children":1157},{"style":426},[1158],{"type":55,"value":359},{"type":46,"tag":396,"props":1160,"children":1161},{"style":420},[1162],{"type":55,"value":1163},"Event\n",{"type":46,"tag":396,"props":1165,"children":1166},{"class":398,"line":656},[1167,1171],{"type":46,"tag":396,"props":1168,"children":1169},{"style":403},[1170],{"type":55,"value":621},{"type":46,"tag":396,"props":1172,"children":1173},{"style":426},[1174],{"type":55,"value":598},{"type":46,"tag":396,"props":1176,"children":1177},{"class":398,"line":671},[1178,1182,1186,1190,1194],{"type":46,"tag":396,"props":1179,"children":1180},{"style":426},[1181],{"type":55,"value":634},{"type":46,"tag":396,"props":1183,"children":1184},{"style":403},[1185],{"type":55,"value":639},{"type":46,"tag":396,"props":1187,"children":1188},{"style":426},[1189],{"type":55,"value":644},{"type":46,"tag":396,"props":1191,"children":1192},{"style":420},[1193],{"type":55,"value":63},{"type":46,"tag":396,"props":1195,"children":1196},{"style":426},[1197],{"type":55,"value":653},{"type":46,"tag":396,"props":1199,"children":1200},{"class":398,"line":690},[1201],{"type":46,"tag":396,"props":1202,"children":1203},{"style":426},[1204],{"type":55,"value":1205},"      body,\n",{"type":46,"tag":396,"props":1207,"children":1208},{"class":398,"line":704},[1209],{"type":46,"tag":396,"props":1210,"children":1211},{"style":426},[1212],{"type":55,"value":1213},"      sig,\n",{"type":46,"tag":396,"props":1215,"children":1216},{"class":398,"line":713},[1217,1221,1226],{"type":46,"tag":396,"props":1218,"children":1219},{"style":426},[1220],{"type":55,"value":696},{"type":46,"tag":396,"props":1222,"children":1223},{"style":409},[1224],{"type":55,"value":1225},"STRIPE_WEBHOOK_SECRET",{"type":46,"tag":396,"props":1227,"children":1228},{"style":403},[1229],{"type":55,"value":1134},{"type":46,"tag":396,"props":1231,"children":1232},{"class":398,"line":732},[1233],{"type":46,"tag":396,"props":1234,"children":1235},{"style":426},[1236],{"type":55,"value":710},{"type":46,"tag":396,"props":1238,"children":1239},{"class":398,"line":802},[1240,1244,1248],{"type":46,"tag":396,"props":1241,"children":1242},{"style":426},[1243],{"type":55,"value":719},{"type":46,"tag":396,"props":1245,"children":1246},{"style":403},[1247],{"type":55,"value":724},{"type":46,"tag":396,"props":1249,"children":1250},{"style":426},[1251],{"type":55,"value":729},{"type":46,"tag":396,"props":1253,"children":1254},{"class":398,"line":811},[1255,1259,1263,1268,1272,1276,1280,1284,1289,1294,1298,1302,1306,1311,1315],{"type":46,"tag":396,"props":1256,"children":1257},{"style":403},[1258],{"type":55,"value":738},{"type":46,"tag":396,"props":1260,"children":1261},{"style":403},[1262],{"type":55,"value":980},{"type":46,"tag":396,"props":1264,"children":1265},{"style":420},[1266],{"type":55,"value":1267}," Response",{"type":46,"tag":396,"props":1269,"children":1270},{"style":426},[1271],{"type":55,"value":429},{"type":46,"tag":396,"props":1273,"children":1274},{"style":432},[1275],{"type":55,"value":776},{"type":46,"tag":396,"props":1277,"children":1278},{"style":432},[1279],{"type":55,"value":429},{"type":46,"tag":396,"props":1281,"children":1282},{"style":426},[1283],{"type":55,"value":781},{"type":46,"tag":396,"props":1285,"children":1286},{"style":403},[1287],{"type":55,"value":1288}," as",{"type":46,"tag":396,"props":1290,"children":1291},{"style":420},[1292],{"type":55,"value":1293}," Error",{"type":46,"tag":396,"props":1295,"children":1296},{"style":432},[1297],{"type":55,"value":762},{"type":46,"tag":396,"props":1299,"children":1300},{"style":426},[1301],{"type":55,"value":790},{"type":46,"tag":396,"props":1303,"children":1304},{"style":432},[1305],{"type":55,"value":795},{"type":46,"tag":396,"props":1307,"children":1308},{"style":426},[1309],{"type":55,"value":1310},", { status: ",{"type":46,"tag":396,"props":1312,"children":1313},{"style":409},[1314],{"type":55,"value":757},{"type":46,"tag":396,"props":1316,"children":1317},{"style":426},[1318],{"type":55,"value":846},{"type":46,"tag":396,"props":1320,"children":1321},{"class":398,"line":820},[1322],{"type":46,"tag":396,"props":1323,"children":1324},{"style":426},[1325],{"type":55,"value":808},{"type":46,"tag":396,"props":1327,"children":1328},{"class":398,"line":849},[1329],{"type":46,"tag":396,"props":1330,"children":1331},{"style":665},[1332],{"type":55,"value":817},{"type":46,"tag":396,"props":1334,"children":1335},{"class":398,"line":858},[1336,1341,1346,1350,1354,1358],{"type":46,"tag":396,"props":1337,"children":1338},{"style":403},[1339],{"type":55,"value":1340},"  return",{"type":46,"tag":396,"props":1342,"children":1343},{"style":426},[1344],{"type":55,"value":1345}," Response.",{"type":46,"tag":396,"props":1347,"children":1348},{"style":420},[1349],{"type":55,"value":831},{"type":46,"tag":396,"props":1351,"children":1352},{"style":426},[1353],{"type":55,"value":836},{"type":46,"tag":396,"props":1355,"children":1356},{"style":409},[1357],{"type":55,"value":841},{"type":46,"tag":396,"props":1359,"children":1360},{"style":426},[1361],{"type":55,"value":846},{"type":46,"tag":396,"props":1363,"children":1364},{"class":398,"line":866},[1365],{"type":46,"tag":396,"props":1366,"children":1367},{"style":426},[1368],{"type":55,"value":1369},"}\n",{"type":46,"tag":47,"props":1371,"children":1372},{},[1373,1378,1380,1386],{"type":46,"tag":51,"props":1374,"children":1375},{},[1376],{"type":55,"value":1377},"FastAPI.",{"type":55,"value":1379}," Take the bytes from ",{"type":46,"tag":58,"props":1381,"children":1383},{"className":1382},[],[1384],{"type":55,"value":1385},"await request.body()",{"type":55,"value":1387},", not a Pydantic model:",{"type":46,"tag":232,"props":1389,"children":1393},{"code":1390,"language":1391,"meta":7,"className":1392,"style":7},"import os, stripe\nfrom fastapi import FastAPI, Request, HTTPException\n\napp = FastAPI()\n\n@app.post(\"/stripe/webhook\")\nasync def stripe_webhook(request: Request):\n    payload = await request.body()\n    sig = request.headers.get(\"stripe-signature\")\n    try:\n        event = stripe.Webhook.construct_event(\n            payload,\n            sig,\n            os.environ[\"STRIPE_WEBHOOK_SECRET\"],\n        )\n    except (ValueError, stripe.SignatureVerificationError) as e:\n        # older stripe-python versions: stripe.error.SignatureVerificationError\n        raise HTTPException(status_code=400, detail=str(e))\n    # handle event[\"type\"] ...\n    return {\"received\": True}\n","python","language-python shiki shiki-themes github-dark",[1394],{"type":46,"tag":58,"props":1395,"children":1396},{"__ignoreMap":7},[1397,1409,1430,1437,1454,1461,1482,1505,1526,1552,1565,1582,1590,1598,1615,1623,1656,1664,1713,1721],{"type":46,"tag":396,"props":1398,"children":1399},{"class":398,"line":399},[1400,1404],{"type":46,"tag":396,"props":1401,"children":1402},{"style":403},[1403],{"type":55,"value":945},{"type":46,"tag":396,"props":1405,"children":1406},{"style":426},[1407],{"type":55,"value":1408}," os, stripe\n",{"type":46,"tag":396,"props":1410,"children":1411},{"class":398,"line":443},[1412,1416,1421,1425],{"type":46,"tag":396,"props":1413,"children":1414},{"style":403},[1415],{"type":55,"value":955},{"type":46,"tag":396,"props":1417,"children":1418},{"style":426},[1419],{"type":55,"value":1420}," fastapi ",{"type":46,"tag":396,"props":1422,"children":1423},{"style":403},[1424],{"type":55,"value":945},{"type":46,"tag":396,"props":1426,"children":1427},{"style":426},[1428],{"type":55,"value":1429}," FastAPI, Request, HTTPException\n",{"type":46,"tag":396,"props":1431,"children":1432},{"class":398,"line":487},[1433],{"type":46,"tag":396,"props":1434,"children":1435},{"emptyLinePlaceholder":517},[1436],{"type":55,"value":520},{"type":46,"tag":396,"props":1438,"children":1439},{"class":398,"line":513},[1440,1445,1449],{"type":46,"tag":396,"props":1441,"children":1442},{"style":426},[1443],{"type":55,"value":1444},"app ",{"type":46,"tag":396,"props":1446,"children":1447},{"style":403},[1448],{"type":55,"value":639},{"type":46,"tag":396,"props":1450,"children":1451},{"style":426},[1452],{"type":55,"value":1453}," FastAPI()\n",{"type":46,"tag":396,"props":1455,"children":1456},{"class":398,"line":523},[1457],{"type":46,"tag":396,"props":1458,"children":1459},{"emptyLinePlaceholder":517},[1460],{"type":55,"value":520},{"type":46,"tag":396,"props":1462,"children":1463},{"class":398,"line":601},[1464,1469,1473,1478],{"type":46,"tag":396,"props":1465,"children":1466},{"style":420},[1467],{"type":55,"value":1468},"@app.post",{"type":46,"tag":396,"props":1470,"children":1471},{"style":426},[1472],{"type":55,"value":429},{"type":46,"tag":396,"props":1474,"children":1475},{"style":432},[1476],{"type":55,"value":1477},"\"/stripe/webhook\"",{"type":46,"tag":396,"props":1479,"children":1480},{"style":426},[1481],{"type":55,"value":440},{"type":46,"tag":396,"props":1483,"children":1484},{"class":398,"line":615},[1485,1490,1495,1500],{"type":46,"tag":396,"props":1486,"children":1487},{"style":403},[1488],{"type":55,"value":1489},"async",{"type":46,"tag":396,"props":1491,"children":1492},{"style":403},[1493],{"type":55,"value":1494}," def",{"type":46,"tag":396,"props":1496,"children":1497},{"style":420},[1498],{"type":55,"value":1499}," stripe_webhook",{"type":46,"tag":396,"props":1501,"children":1502},{"style":426},[1503],{"type":55,"value":1504},"(request: Request):\n",{"type":46,"tag":396,"props":1506,"children":1507},{"class":398,"line":628},[1508,1513,1517,1521],{"type":46,"tag":396,"props":1509,"children":1510},{"style":426},[1511],{"type":55,"value":1512},"    payload ",{"type":46,"tag":396,"props":1514,"children":1515},{"style":403},[1516],{"type":55,"value":639},{"type":46,"tag":396,"props":1518,"children":1519},{"style":403},[1520],{"type":55,"value":1077},{"type":46,"tag":396,"props":1522,"children":1523},{"style":426},[1524],{"type":55,"value":1525}," request.body()\n",{"type":46,"tag":396,"props":1527,"children":1528},{"class":398,"line":656},[1529,1534,1538,1543,1548],{"type":46,"tag":396,"props":1530,"children":1531},{"style":426},[1532],{"type":55,"value":1533},"    sig ",{"type":46,"tag":396,"props":1535,"children":1536},{"style":403},[1537],{"type":55,"value":639},{"type":46,"tag":396,"props":1539,"children":1540},{"style":426},[1541],{"type":55,"value":1542}," request.headers.get(",{"type":46,"tag":396,"props":1544,"children":1545},{"style":432},[1546],{"type":55,"value":1547},"\"stripe-signature\"",{"type":46,"tag":396,"props":1549,"children":1550},{"style":426},[1551],{"type":55,"value":440},{"type":46,"tag":396,"props":1553,"children":1554},{"class":398,"line":671},[1555,1560],{"type":46,"tag":396,"props":1556,"children":1557},{"style":403},[1558],{"type":55,"value":1559},"    try",{"type":46,"tag":396,"props":1561,"children":1562},{"style":426},[1563],{"type":55,"value":1564},":\n",{"type":46,"tag":396,"props":1566,"children":1567},{"class":398,"line":690},[1568,1573,1577],{"type":46,"tag":396,"props":1569,"children":1570},{"style":426},[1571],{"type":55,"value":1572},"        event ",{"type":46,"tag":396,"props":1574,"children":1575},{"style":403},[1576],{"type":55,"value":639},{"type":46,"tag":396,"props":1578,"children":1579},{"style":426},[1580],{"type":55,"value":1581}," stripe.Webhook.construct_event(\n",{"type":46,"tag":396,"props":1583,"children":1584},{"class":398,"line":704},[1585],{"type":46,"tag":396,"props":1586,"children":1587},{"style":426},[1588],{"type":55,"value":1589},"            payload,\n",{"type":46,"tag":396,"props":1591,"children":1592},{"class":398,"line":713},[1593],{"type":46,"tag":396,"props":1594,"children":1595},{"style":426},[1596],{"type":55,"value":1597},"            sig,\n",{"type":46,"tag":396,"props":1599,"children":1600},{"class":398,"line":732},[1601,1606,1611],{"type":46,"tag":396,"props":1602,"children":1603},{"style":426},[1604],{"type":55,"value":1605},"            os.environ[",{"type":46,"tag":396,"props":1607,"children":1608},{"style":432},[1609],{"type":55,"value":1610},"\"STRIPE_WEBHOOK_SECRET\"",{"type":46,"tag":396,"props":1612,"children":1613},{"style":426},[1614],{"type":55,"value":687},{"type":46,"tag":396,"props":1616,"children":1617},{"class":398,"line":802},[1618],{"type":46,"tag":396,"props":1619,"children":1620},{"style":426},[1621],{"type":55,"value":1622},"        )\n",{"type":46,"tag":396,"props":1624,"children":1625},{"class":398,"line":811},[1626,1631,1636,1641,1646,1651],{"type":46,"tag":396,"props":1627,"children":1628},{"style":403},[1629],{"type":55,"value":1630},"    except",{"type":46,"tag":396,"props":1632,"children":1633},{"style":426},[1634],{"type":55,"value":1635}," (",{"type":46,"tag":396,"props":1637,"children":1638},{"style":409},[1639],{"type":55,"value":1640},"ValueError",{"type":46,"tag":396,"props":1642,"children":1643},{"style":426},[1644],{"type":55,"value":1645},", stripe.SignatureVerificationError) ",{"type":46,"tag":396,"props":1647,"children":1648},{"style":403},[1649],{"type":55,"value":1650},"as",{"type":46,"tag":396,"props":1652,"children":1653},{"style":426},[1654],{"type":55,"value":1655}," e:\n",{"type":46,"tag":396,"props":1657,"children":1658},{"class":398,"line":820},[1659],{"type":46,"tag":396,"props":1660,"children":1661},{"style":665},[1662],{"type":55,"value":1663},"        # older stripe-python versions: stripe.error.SignatureVerificationError\n",{"type":46,"tag":396,"props":1665,"children":1666},{"class":398,"line":849},[1667,1672,1677,1682,1686,1690,1694,1699,1703,1708],{"type":46,"tag":396,"props":1668,"children":1669},{"style":403},[1670],{"type":55,"value":1671},"        raise",{"type":46,"tag":396,"props":1673,"children":1674},{"style":426},[1675],{"type":55,"value":1676}," HTTPException(",{"type":46,"tag":396,"props":1678,"children":1679},{"style":570},[1680],{"type":55,"value":1681},"status_code",{"type":46,"tag":396,"props":1683,"children":1684},{"style":403},[1685],{"type":55,"value":639},{"type":46,"tag":396,"props":1687,"children":1688},{"style":409},[1689],{"type":55,"value":757},{"type":46,"tag":396,"props":1691,"children":1692},{"style":426},[1693],{"type":55,"value":578},{"type":46,"tag":396,"props":1695,"children":1696},{"style":570},[1697],{"type":55,"value":1698},"detail",{"type":46,"tag":396,"props":1700,"children":1701},{"style":403},[1702],{"type":55,"value":639},{"type":46,"tag":396,"props":1704,"children":1705},{"style":409},[1706],{"type":55,"value":1707},"str",{"type":46,"tag":396,"props":1709,"children":1710},{"style":426},[1711],{"type":55,"value":1712},"(e))\n",{"type":46,"tag":396,"props":1714,"children":1715},{"class":398,"line":858},[1716],{"type":46,"tag":396,"props":1717,"children":1718},{"style":665},[1719],{"type":55,"value":1720},"    # handle event[\"type\"] ...\n",{"type":46,"tag":396,"props":1722,"children":1723},{"class":398,"line":866},[1724,1728,1733,1738,1743,1748],{"type":46,"tag":396,"props":1725,"children":1726},{"style":403},[1727],{"type":55,"value":738},{"type":46,"tag":396,"props":1729,"children":1730},{"style":426},[1731],{"type":55,"value":1732}," {",{"type":46,"tag":396,"props":1734,"children":1735},{"style":432},[1736],{"type":55,"value":1737},"\"received\"",{"type":46,"tag":396,"props":1739,"children":1740},{"style":426},[1741],{"type":55,"value":1742},": ",{"type":46,"tag":396,"props":1744,"children":1745},{"style":409},[1746],{"type":55,"value":1747},"True",{"type":46,"tag":396,"props":1749,"children":1750},{"style":426},[1751],{"type":55,"value":1369},{"type":46,"tag":47,"props":1753,"children":1754},{},[1755,1757,1763],{"type":55,"value":1756},"Flask is the same idea with ",{"type":46,"tag":58,"props":1758,"children":1760},{"className":1759},[],[1761],{"type":55,"value":1762},"request.get_data()",{"type":55,"value":1764},". Anything that sits in front of your app, such as an API gateway mapping template, a serverless body transform or a middleware that decompresses and re-encodes, can also change the bytes. Log the raw body's length and a hash on both sides if you're unsure.",{"type":46,"tag":213,"props":1766,"children":1768},{"id":1767},"fix-2-use-the-right-whsec_-secret",[1769,1771,1776],{"type":55,"value":1770},"Fix 2: use the right ",{"type":46,"tag":58,"props":1772,"children":1774},{"className":1773},[],[1775],{"type":55,"value":292},{"type":55,"value":1777}," secret",{"type":46,"tag":47,"props":1779,"children":1780},{},[1781,1786,1788,1793,1795,1800,1802,1808,1810,1816],{"type":46,"tag":51,"props":1782,"children":1783},{},[1784],{"type":55,"value":1785},"Where to find it:",{"type":55,"value":1787}," in the Stripe Dashboard, open ",{"type":46,"tag":51,"props":1789,"children":1790},{},[1791],{"type":55,"value":1792},"Workbench → Webhooks",{"type":55,"value":1794},", select the endpoint and click ",{"type":46,"tag":51,"props":1796,"children":1797},{},[1798],{"type":55,"value":1799},"Click to reveal",{"type":55,"value":1801}," next to the signing secret. When you forward events with the Stripe CLI, ",{"type":46,"tag":58,"props":1803,"children":1805},{"className":1804},[],[1806],{"type":55,"value":1807},"stripe listen",{"type":55,"value":1809}," prints its own secret instead: ",{"type":46,"tag":58,"props":1811,"children":1813},{"className":1812},[],[1814],{"type":55,"value":1815},"Ready! Your webhook signing secret is whsec_…",{"type":55,"value":359},{"type":46,"tag":47,"props":1818,"children":1819},{},[1820],{"type":55,"value":1821},"Every endpoint has its own signing secret, and the wrong one produces exactly the same error as a parsed body:",{"type":46,"tag":241,"props":1823,"children":1824},{},[1825,1847,1857,1867],{"type":46,"tag":245,"props":1826,"children":1827},{},[1828,1838,1840,1845],{"type":46,"tag":51,"props":1829,"children":1830},{},[1831,1836],{"type":46,"tag":58,"props":1832,"children":1834},{"className":1833},[],[1835],{"type":55,"value":1807},{"type":55,"value":1837}," vs the Dashboard.",{"type":55,"value":1839}," The Stripe CLI prints its own ",{"type":46,"tag":58,"props":1841,"children":1843},{"className":1842},[],[1844],{"type":55,"value":292},{"type":55,"value":1846}," when it starts forwarding. It's not the secret of the endpoint you created in the Dashboard.",{"type":46,"tag":245,"props":1848,"children":1849},{},[1850,1855],{"type":46,"tag":51,"props":1851,"children":1852},{},[1853],{"type":55,"value":1854},"Test mode vs live mode.",{"type":55,"value":1856}," The same URL registered in both modes has two different secrets.",{"type":46,"tag":245,"props":1858,"children":1859},{},[1860,1865],{"type":46,"tag":51,"props":1861,"children":1862},{},[1863],{"type":55,"value":1864},"Several endpoints.",{"type":55,"value":1866}," If two endpoints point to the same URL, each event is signed with the secret of the endpoint that sent it.",{"type":46,"tag":245,"props":1868,"children":1869},{},[1870,1875],{"type":46,"tag":51,"props":1871,"children":1872},{},[1873],{"type":55,"value":1874},"Copy-paste damage.",{"type":55,"value":1876}," A trailing newline in an environment variable is enough to break the match.",{"type":46,"tag":47,"props":1878,"children":1879},{},[1880,1882,1887,1889,1895],{"type":55,"value":1881},"You can check a secret without touching your code. Paste the payload, the ",{"type":46,"tag":58,"props":1883,"children":1885},{"className":1884},[],[1886],{"type":55,"value":187},{"type":55,"value":1888}," header and the secret into the free ",{"type":46,"tag":125,"props":1890,"children":1892},{"href":1891},"/verify-stripe-webhook-signature/",[1893],{"type":55,"value":1894},"Stripe webhook signature verifier",{"type":55,"value":1896},", which runs in your browser.",{"type":46,"tag":213,"props":1898,"children":1900},{"id":1899},"fix-3-timestamp-outside-the-tolerance-zone",[1901],{"type":55,"value":1902},"Fix 3: \"Timestamp outside the tolerance zone\"",{"type":46,"tag":47,"props":1904,"children":1905},{},[1906,1908,1913,1915,1920,1922,1927],{"type":55,"value":1907},"The signature ",{"type":46,"tag":205,"props":1909,"children":1910},{},[1911],{"type":55,"value":1912},"matched",{"type":55,"value":1914},", but its timestamp failed the freshness check: ",{"type":46,"tag":58,"props":1916,"children":1918},{"className":1917},[],[1919],{"type":55,"value":253},{"type":55,"value":1921}," is more than 300 seconds from your server's clock. ",{"type":46,"tag":51,"props":1923,"children":1924},{},[1925],{"type":55,"value":1926},"Check your server clock first, then whether something held or replayed the original request.",{"type":55,"value":1928}," Clock drift: run NTP. Late delivery: re-sign, don't raise the tolerance.",{"type":46,"tag":47,"props":1930,"children":1931},{},[1932,1937,1939,1945,1946,1952,1954,1960],{"type":46,"tag":51,"props":1933,"children":1934},{},[1935],{"type":55,"value":1936},"Clock drift.",{"type":55,"value":1938}," If your server's clock is minutes off, every webhook fails. Run NTP (",{"type":46,"tag":58,"props":1940,"children":1942},{"className":1941},[],[1943],{"type":55,"value":1944},"chronyd",{"type":55,"value":578},{"type":46,"tag":58,"props":1947,"children":1949},{"className":1948},[],[1950],{"type":55,"value":1951},"systemd-timesyncd",{"type":55,"value":1953},") and check with ",{"type":46,"tag":58,"props":1955,"children":1957},{"className":1956},[],[1958],{"type":55,"value":1959},"date -u",{"type":55,"value":359},{"type":46,"tag":47,"props":1962,"children":1963},{},[1964,1969,1971,1976,1978,1982],{"type":46,"tag":51,"props":1965,"children":1966},{},[1967],{"type":55,"value":1968},"Late delivery.",{"type":55,"value":1970}," Stripe signs each delivery attempt when it sends it. In Stripe's words, it generates \"a new signature and timestamp for the new delivery attempt\". Its automatic retries (up to three days in live mode) and the ",{"type":46,"tag":51,"props":1972,"children":1973},{},[1974],{"type":55,"value":1975},"Resend",{"type":55,"value":1977}," button in the Dashboard therefore carry a fresh timestamp. The problem starts when something ",{"type":46,"tag":205,"props":1979,"children":1980},{},[1981],{"type":55,"value":209},{"type":55,"value":1983}," Stripe and your server stores the request and delivers the original later:",{"type":46,"tag":241,"props":1985,"children":1986},{},[1987,1992,1997,2002,2015],{"type":46,"tag":245,"props":1988,"children":1989},{},[1990],{"type":55,"value":1991},"a webhook proxy or gateway that retries a failed delivery after your server comes back",{"type":46,"tag":245,"props":1993,"children":1994},{},[1995],{"type":55,"value":1996},"replaying captured webhooks from logs after fixing a bug",{"type":46,"tag":245,"props":1998,"children":1999},{},[2000],{"type":55,"value":2001},"a queue or rate limiter that holds requests during a burst",{"type":46,"tag":245,"props":2003,"children":2004},{},[2005,2007,2013],{"type":55,"value":2006},"a tunnel or agent to ",{"type":46,"tag":58,"props":2008,"children":2010},{"className":2009},[],[2011],{"type":55,"value":2012},"localhost",{"type":55,"value":2014}," that was disconnected while your laptop slept, then delivers the backlog",{"type":46,"tag":245,"props":2016,"children":2017},{},[2018],{"type":55,"value":2019},"CI or test fixtures that reuse recorded webhooks",{"type":46,"tag":47,"props":2021,"children":2022},{},[2023,2025,2030],{"type":55,"value":2024},"Each of those delivers an authentic webhook whose signature is now 10 minutes, an hour or a day old, and ",{"type":46,"tag":58,"props":2026,"children":2028},{"className":2027},[],[2029],{"type":55,"value":63},{"type":55,"value":2031}," correctly refuses it.",{"type":46,"tag":2033,"props":2034,"children":2036},"h3",{"id":2035},"the-fix-re-sign-the-delivery",[2037],{"type":55,"value":2038},"The fix: re-sign the delivery",{"type":46,"tag":47,"props":2040,"children":2041},{},[2042,2044],{"type":55,"value":2043},"The fix is to give each late delivery a fresh signature. That's only safe in the system that can verify the original first, and that holds the same secret. ",{"type":46,"tag":51,"props":2045,"children":2046},{},[2047],{"type":55,"value":2048},"Webhook Relay does this on the input:",{"type":46,"tag":2050,"props":2051,"children":2052},"ol",{},[2053,2079,2092],{"type":46,"tag":245,"props":2054,"children":2055},{},[2056,2058,2063,2065,2070,2072,2077],{"type":55,"value":2057},"You pick ",{"type":46,"tag":51,"props":2059,"children":2060},{},[2061],{"type":55,"value":2062},"Stripe",{"type":55,"value":2064}," in the input's ",{"type":46,"tag":125,"props":2066,"children":2068},{"href":2067},"/docs/webhooks/auth/signature-verification/",[2069],{"type":55,"value":18},{"type":55,"value":2071}," settings and paste the endpoint's ",{"type":46,"tag":58,"props":2073,"children":2075},{"className":2074},[],[2076],{"type":55,"value":292},{"type":55,"value":2078}," secret.",{"type":46,"tag":245,"props":2080,"children":2081},{},[2082,2084,2090],{"type":55,"value":2083},"Every incoming webhook is verified, including the 5-minute check, when it arrives. A forged or stale request gets a ",{"type":46,"tag":58,"props":2085,"children":2087},{"className":2086},[],[2088],{"type":55,"value":2089},"401",{"type":55,"value":2091}," and is never stored or forwarded.",{"type":46,"tag":245,"props":2093,"children":2094},{},[2095,2097,2102,2104,2109],{"type":55,"value":2096},"With ",{"type":46,"tag":51,"props":2098,"children":2099},{},[2100],{"type":55,"value":2101},"re-sign on delivery",{"type":55,"value":2103}," on, every delivery attempt gets a new ",{"type":46,"tag":58,"props":2105,"children":2107},{"className":2106},[],[2108],{"type":55,"value":187},{"type":55,"value":2110}," with the current time, made with the same secret over the body actually sent.",{"type":46,"tag":47,"props":2112,"children":2113},{},[2114,2116,2121,2123,2129,2131,2137],{"type":55,"value":2115},"Your server's code doesn't change. It calls ",{"type":46,"tag":58,"props":2117,"children":2119},{"className":2118},[],[2120],{"type":55,"value":63},{"type":55,"value":2122}," with the same secret and the default tolerance. A delivery that was ",{"type":46,"tag":125,"props":2124,"children":2126},{"href":2125},"/features/durable-retries/",[2127],{"type":55,"value":2128},"retried",{"type":55,"value":2130}," after an outage, replayed from the logs, or queued for an ",{"type":46,"tag":125,"props":2132,"children":2134},{"href":2133},"/blog/receiving-stripe-webhooks-localhost/",[2135],{"type":55,"value":2136},"agent on localhost",{"type":55,"value":2138}," passes like a webhook sent a second ago. Only webhooks that passed verification on arrival are re-signed, so re-signing can't launder a forged request.",{"type":46,"tag":47,"props":2140,"children":2141},{},[2142,2144,2150],{"type":55,"value":2143},"The same applies to the other providers that sign a timestamp: Svix-based senders such as Clerk and Resend, and Slack. ",{"type":46,"tag":125,"props":2145,"children":2147},{"href":2146},"/blog/webhook-signature-fails-after-retry/",[2148],{"type":55,"value":2149},"Why webhook signatures fail after retries and replays",{"type":55,"value":2151}," covers those.",{"type":46,"tag":2033,"props":2153,"children":2155},{"id":2154},"dont-raise-the-tolerance-instead",[2156],{"type":55,"value":2157},"Don't raise the tolerance instead",{"type":46,"tag":47,"props":2159,"children":2160},{},[2161,2166,2168,2174],{"type":46,"tag":58,"props":2162,"children":2164},{"className":2163},[],[2165],{"type":55,"value":63},{"type":55,"value":2167}," takes a fourth argument, the tolerance in seconds, and Python has ",{"type":46,"tag":58,"props":2169,"children":2171},{"className":2170},[],[2172],{"type":55,"value":2173},"tolerance=",{"type":55,"value":2175},". It's tempting to set it to a day. That makes every webhook you ever received replayable against your endpoint for a day, which is the attack the timestamp exists to stop. Turning verification off for \"internal\" traffic has the same problem.",{"type":46,"tag":213,"props":2177,"children":2179},{"id":2178},"fix-4-pass-the-stripe-signature-header-through",[2180,2182,2187],{"type":55,"value":2181},"Fix 4: pass the ",{"type":46,"tag":58,"props":2183,"children":2185},{"className":2184},[],[2186],{"type":55,"value":187},{"type":55,"value":2188}," header through",{"type":46,"tag":47,"props":2190,"children":2191},{},[2192,2197,2199,2204,2206,2212,2214,2220],{"type":46,"tag":58,"props":2193,"children":2195},{"className":2194},[],[2196],{"type":55,"value":176},{"type":55,"value":2198}," means the SDK got no ",{"type":46,"tag":58,"props":2200,"children":2202},{"className":2201},[],[2203],{"type":55,"value":187},{"type":55,"value":2205}," value, or one without ",{"type":46,"tag":58,"props":2207,"children":2209},{"className":2208},[],[2210],{"type":55,"value":2211},"t=",{"type":55,"value":2213}," and ",{"type":46,"tag":58,"props":2215,"children":2217},{"className":2216},[],[2218],{"type":55,"value":2219},"v1=",{"type":55,"value":2221},". Check three things:",{"type":46,"tag":241,"props":2223,"children":2224},{},[2225,2250,2267],{"type":46,"tag":245,"props":2226,"children":2227},{},[2228,2233,2235,2241,2243,2249],{"type":46,"tag":51,"props":2229,"children":2230},{},[2231],{"type":55,"value":2232},"You read the right header.",{"type":55,"value":2234}," In Node it's ",{"type":46,"tag":58,"props":2236,"children":2238},{"className":2237},[],[2239],{"type":55,"value":2240},"req.headers['stripe-signature']",{"type":55,"value":2242},", lowercase. In Next.js and FastAPI, ",{"type":46,"tag":58,"props":2244,"children":2246},{"className":2245},[],[2247],{"type":55,"value":2248},"headers.get('stripe-signature')",{"type":55,"value":359},{"type":46,"tag":245,"props":2251,"children":2252},{},[2253,2258,2260,2265],{"type":46,"tag":51,"props":2254,"children":2255},{},[2256],{"type":55,"value":2257},"Nothing in front of your app drops it.",{"type":55,"value":2259}," Some API gateways, load balancers and serverless proxies forward only an allowlist of headers. Add ",{"type":46,"tag":58,"props":2261,"children":2263},{"className":2262},[],[2264],{"type":55,"value":187},{"type":55,"value":2266}," to it.",{"type":46,"tag":245,"props":2268,"children":2269},{},[2270,2275,2277,2283],{"type":46,"tag":51,"props":2271,"children":2272},{},[2273],{"type":55,"value":2274},"Nothing rewrites it.",{"type":55,"value":2276}," A proxy that folds or truncates long header values breaks the ",{"type":46,"tag":58,"props":2278,"children":2280},{"className":2279},[],[2281],{"type":55,"value":2282},"t=…,v1=…",{"type":55,"value":2284}," format.",{"type":46,"tag":213,"props":2286,"children":2288},{"id":2287},"test-it-with-the-stripe-cli",[2289],{"type":55,"value":2290},"Test it with the Stripe CLI",{"type":46,"tag":47,"props":2292,"children":2293},{},[2294],{"type":55,"value":2295},"Verify a fresh event first, then reproduce a mismatch and a timestamp failure.",{"type":46,"tag":2050,"props":2297,"children":2298},{},[2299,2372,2408,2427],{"type":46,"tag":245,"props":2300,"children":2301},{},[2302,2304,2347,2351,2356,2358,2363,2365,2370],{"type":55,"value":2303},"Start forwarding and copy the secret it prints:",{"type":46,"tag":232,"props":2305,"children":2309},{"code":2306,"language":2307,"meta":7,"className":2308,"style":7},"stripe login\nstripe listen --forward-to localhost:3000/stripe/webhook\n","bash","language-bash shiki shiki-themes github-dark",[2310],{"type":46,"tag":58,"props":2311,"children":2312},{"__ignoreMap":7},[2313,2325],{"type":46,"tag":396,"props":2314,"children":2315},{"class":398,"line":399},[2316,2320],{"type":46,"tag":396,"props":2317,"children":2318},{"style":420},[2319],{"type":55,"value":16},{"type":46,"tag":396,"props":2321,"children":2322},{"style":432},[2323],{"type":55,"value":2324}," login\n",{"type":46,"tag":396,"props":2326,"children":2327},{"class":398,"line":443},[2328,2332,2337,2342],{"type":46,"tag":396,"props":2329,"children":2330},{"style":420},[2331],{"type":55,"value":16},{"type":46,"tag":396,"props":2333,"children":2334},{"style":432},[2335],{"type":55,"value":2336}," listen",{"type":46,"tag":396,"props":2338,"children":2339},{"style":409},[2340],{"type":55,"value":2341}," --forward-to",{"type":46,"tag":396,"props":2343,"children":2344},{"style":432},[2345],{"type":55,"value":2346}," localhost:3000/stripe/webhook\n",{"type":46,"tag":2348,"props":2349,"children":2350},"br",{},[],{"type":46,"tag":58,"props":2352,"children":2354},{"className":2353},[],[2355],{"type":55,"value":1807},{"type":55,"value":2357}," prints ",{"type":46,"tag":58,"props":2359,"children":2361},{"className":2360},[],[2362],{"type":55,"value":1815},{"type":55,"value":2364},". Put that value in ",{"type":46,"tag":58,"props":2366,"children":2368},{"className":2367},[],[2369],{"type":55,"value":1225},{"type":55,"value":2371}," and restart your handler.",{"type":46,"tag":245,"props":2373,"children":2374},{},[2375,2377,2383,2384],{"type":55,"value":2376},"In a second terminal, send an event. The handler should return ",{"type":46,"tag":58,"props":2378,"children":2380},{"className":2379},[],[2381],{"type":55,"value":2382},"200",{"type":55,"value":385},{"type":46,"tag":232,"props":2385,"children":2387},{"code":2386,"language":2307,"meta":7,"className":2308,"style":7},"stripe trigger payment_intent.succeeded\n",[2388],{"type":46,"tag":58,"props":2389,"children":2390},{"__ignoreMap":7},[2391],{"type":46,"tag":396,"props":2392,"children":2393},{"class":398,"line":399},[2394,2398,2403],{"type":46,"tag":396,"props":2395,"children":2396},{"style":420},[2397],{"type":55,"value":16},{"type":46,"tag":396,"props":2399,"children":2400},{"style":432},[2401],{"type":55,"value":2402}," trigger",{"type":46,"tag":396,"props":2404,"children":2405},{"style":432},[2406],{"type":55,"value":2407}," payment_intent.succeeded\n",{"type":46,"tag":245,"props":2409,"children":2410},{},[2411,2413,2418,2420,2425],{"type":55,"value":2412},"Change one character of ",{"type":46,"tag":58,"props":2414,"children":2416},{"className":2415},[],[2417],{"type":55,"value":1225},{"type":55,"value":2419},", restart the handler and trigger again. You should get ",{"type":46,"tag":58,"props":2421,"children":2423},{"className":2422},[],[2424],{"type":55,"value":115},{"type":55,"value":2426},". Restore the secret and restart.",{"type":46,"tag":245,"props":2428,"children":2429},{},[2430,2432,2437,2439,2444,2446,2452,2454,2459,2461,2466],{"type":55,"value":2431},"To see the timestamp error, capture one request from the same ",{"type":46,"tag":58,"props":2433,"children":2435},{"className":2434},[],[2436],{"type":55,"value":1807},{"type":55,"value":2438}," session with its exact body and ",{"type":46,"tag":58,"props":2440,"children":2442},{"className":2441},[],[2443],{"type":55,"value":187},{"type":55,"value":2445}," header, for example in a free ",{"type":46,"tag":125,"props":2447,"children":2449},{"href":2448},"/webhook-bin/",[2450],{"type":55,"value":2451},"Webhook Bin",{"type":55,"value":2453},". Check that it verifies while fresh. More than five minutes later, send the same body and header to your handler with the same ",{"type":46,"tag":58,"props":2455,"children":2457},{"className":2456},[],[2458],{"type":55,"value":1225},{"type":55,"value":2460},". Expect ",{"type":46,"tag":58,"props":2462,"children":2464},{"className":2463},[],[2465],{"type":55,"value":150},{"type":55,"value":359},{"type":46,"tag":213,"props":2468,"children":2470},{"id":2469},"checklist",[2471],{"type":55,"value":2472},"Checklist",{"type":46,"tag":241,"props":2474,"children":2477},{"className":2475},[2476],"contains-task-list",[2478,2503,2526,2535,2550,2559,2568],{"type":46,"tag":245,"props":2479,"children":2482},{"className":2480},[2481],"task-list-item",[2483,2488,2490,2495,2497,2502],{"type":46,"tag":2484,"props":2485,"children":2487},"input",{"disabled":517,"type":2486},"checkbox",[],{"type":55,"value":2489}," The handler verifies the ",{"type":46,"tag":51,"props":2491,"children":2492},{},[2493],{"type":55,"value":2494},"raw bytes",{"type":55,"value":2496},", with no JSON parser before ",{"type":46,"tag":58,"props":2498,"children":2500},{"className":2499},[],[2501],{"type":55,"value":63},{"type":55,"value":359},{"type":46,"tag":245,"props":2504,"children":2506},{"className":2505},[2481],[2507,2510,2512,2517,2519,2524],{"type":46,"tag":2484,"props":2508,"children":2509},{"disabled":517,"type":2486},[],{"type":55,"value":2511}," ",{"type":46,"tag":58,"props":2513,"children":2515},{"className":2514},[],[2516],{"type":55,"value":1225},{"type":55,"value":2518}," is the secret of ",{"type":46,"tag":51,"props":2520,"children":2521},{},[2522],{"type":55,"value":2523},"this endpoint, in this mode",{"type":55,"value":2525},", with no whitespace.",{"type":46,"tag":245,"props":2527,"children":2529},{"className":2528},[2481],[2530,2533],{"type":46,"tag":2484,"props":2531,"children":2532},{"disabled":517,"type":2486},[],{"type":55,"value":2534}," The server clock is synced by NTP.",{"type":46,"tag":245,"props":2536,"children":2538},{"className":2537},[2481],[2539,2542,2544,2549],{"type":46,"tag":2484,"props":2540,"children":2541},{"disabled":517,"type":2486},[],{"type":55,"value":2543}," Nothing between Stripe and the server strips or rewrites ",{"type":46,"tag":58,"props":2545,"children":2547},{"className":2546},[],[2548],{"type":55,"value":187},{"type":55,"value":359},{"type":46,"tag":245,"props":2551,"children":2553},{"className":2552},[2481],[2554,2557],{"type":46,"tag":2484,"props":2555,"children":2556},{"disabled":517,"type":2486},[],{"type":55,"value":2558}," Anything that can deliver late (a gateway, a queue, replays, a tunnel) re-signs, or is the thing that verifies.",{"type":46,"tag":245,"props":2560,"children":2562},{"className":2561},[2481],[2563,2566],{"type":46,"tag":2484,"props":2564,"children":2565},{"disabled":517,"type":2486},[],{"type":55,"value":2567}," The tolerance is the default 300 seconds.",{"type":46,"tag":245,"props":2569,"children":2571},{"className":2570},[2481],[2572,2575,2577,2583],{"type":46,"tag":2484,"props":2573,"children":2574},{"disabled":517,"type":2486},[],{"type":55,"value":2576}," Handlers are idempotent on ",{"type":46,"tag":58,"props":2578,"children":2580},{"className":2579},[],[2581],{"type":55,"value":2582},"event.id",{"type":55,"value":2584},", because retries and replays deliver the same event again.",{"type":46,"tag":2586,"props":2587,"children":2592},"inline-cta",{"label":2588,"secondary-label":2589,"secondary-to":2067,"title":2590,"to":2591},"Create a free bucket","Read the signature verification docs","Verify Stripe signatures before they reach your server","https://my.webhookrelay.com/register",[2593],{"type":46,"tag":47,"props":2594,"children":2595},{},[2596],{"type":55,"value":2597},"Verification, the 5-minute check and re-signing happen on the Webhook Relay input, so your handler keeps its current code and secret.",{"type":46,"tag":47,"props":2599,"children":2600},{},[2601,2603,2609,2611,2617],{"type":55,"value":2602},"For HMAC in general, see ",{"type":46,"tag":125,"props":2604,"children":2606},{"href":2605},"/blog/verify-webhook-signature/",[2607],{"type":55,"value":2608},"how to verify a webhook signature",{"type":55,"value":2610},". For the delivery side, see ",{"type":46,"tag":125,"props":2612,"children":2614},{"href":2613},"/blog/reliable-webhook-delivery/",[2615],{"type":55,"value":2616},"reliable webhook delivery",{"type":55,"value":359},{"type":46,"tag":2619,"props":2620,"children":2621},"style",{},[2622],{"type":55,"value":2623},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":487,"depth":487,"links":2625},[2626,2627,2628,2630,2634,2636,2637],{"id":215,"depth":443,"text":218},{"id":344,"depth":443,"text":347},{"id":1767,"depth":443,"text":2629},"Fix 2: use the right whsec_ secret",{"id":1899,"depth":443,"text":1902,"children":2631},[2632,2633],{"id":2035,"depth":487,"text":2038},{"id":2154,"depth":487,"text":2157},{"id":2178,"depth":443,"text":2635},"Fix 4: pass the Stripe-Signature header through",{"id":2287,"depth":443,"text":2290},{"id":2469,"depth":443,"text":2472},"markdown","content:blog:stripe-webhook-signature-verification.md","content","blog/stripe-webhook-signature-verification.md","blog/stripe-webhook-signature-verification","md",{"loc":4},1795866821382]