[{"data":1,"prerenderedAt":1553},["ShallowReactive",2],{"docs-navigation":3,"content-query-F1A8PeiUvF":291},[4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58,61,64,67,70,73,76,79,82,85,88,91,94,97,100,103,106,109,112,115,118,121,124,127,130,133,136,139,142,145,148,151,154,157,160,163,166,169,172,175,178,181,184,187,190,193,196,199,202,205,208,211,214,217,220,223,226,229,232,235,237,240,243,246,249,252,255,258,261,264,267,270,273,276,279,282,285,288],{"_path":5,"title":6},"/docs/account/account-management","Account management",{"_path":8,"title":9},"/docs/account/mfa","Multi-factor authentication (MFA)",{"_path":11,"title":12},"/docs/account/team","Teams and sub-accounts",{"_path":14,"title":15},"/docs/account/billing-and-subscriptions","Billing & subscriptions",{"_path":17,"title":18},"/docs/clawhub","Webhook Relay on ClawHub",{"_path":20,"title":21},"/docs/email","Receive emails as webhooks",{"_path":23,"title":24},"/docs/email/payload","Email webhook payload",{"_path":26,"title":27},"/docs/email/filtering-and-policy","Sender filtering & policy",{"_path":29,"title":30},"/docs/email/cli","Create & poll email addresses from the CLI",{"_path":32,"title":33},"/docs","Getting Started",{"_path":35,"title":36},"/docs/installation/cli","CLI",{"_path":38,"title":39},"/docs/installation/docker","Docker container",{"_path":41,"title":42},"/docs/installation/docker-compose","Docker Compose",{"_path":44,"title":45},"/docs/installation/kubernetes","Kubernetes",{"_path":47,"title":48},"/docs/installation/autostart-windows","Autostart (Windows)",{"_path":50,"title":51},"/docs/installation/autostart-linux","Autostart (Linux)",{"_path":53,"title":54},"/docs/installation/autostart-macos","Autostart (MacOS)",{"_path":56,"title":57},"/docs/installation/behind-proxy","HTTP proxy configuration",{"_path":59,"title":60},"/docs/mcp","MCP Server",{"_path":62,"title":63},"/docs/security","Security & Tech",{"_path":65,"title":66},"/docs/service-connections","Service Connections",{"_path":68,"title":69},"/docs/service-connections/aws_s3","AWS S3",{"_path":71,"title":72},"/docs/service-connections/aws_sns","AWS SNS",{"_path":74,"title":75},"/docs/service-connections/aws_sqs","AWS SQS",{"_path":77,"title":78},"/docs/service-connections/azure","Azure",{"_path":80,"title":81},"/docs/service-connections/gcp_gcs","GCP Cloud Storage",{"_path":83,"title":84},"/docs/service-connections/gcp_pubsub","GCP Pub/Sub",{"_path":86,"title":87},"/docs/service-connections/secrets","Secrets",{"_path":89,"title":90},"/docs/skills","Agent Skills",{"_path":92,"title":93},"/docs/skills-cli","skills.sh — the Agent Skills CLI",{"_path":95,"title":96},"/docs/tunnels/demoing-your-website","Demoing your website",{"_path":98,"title":99},"/docs/tunnels/regions","Regions",{"_path":101,"title":102},"/docs/tutorials/cicd/jenkins-bitbucket","Jenkins and Bitbucket",{"_path":104,"title":105},"/docs/tutorials/cicd/jenkins-github","Jenkins and GitHub",{"_path":107,"title":108},"/docs/tutorials/cicd/jenkins-plugin","Jenkins Plugin",{"_path":110,"title":111},"/docs/tutorials/cicd/jenkins-plugin-multibranch","Jenkins Multibranch Pipelines",{"_path":113,"title":114},"/docs/tutorials/cicd/kubernetes-operator","Kubernetes Operator",{"_path":116,"title":117},"/docs/tutorials/cicd/terraform-atlantis","Terraform Atlantis",{"_path":119,"title":120},"/docs/tutorials/cicd/webhook-exec","Execute scripts on webhook",{"_path":122,"title":123},"/docs/tutorials/edge/home-assistant","Home Assistant",{"_path":125,"title":126},"/docs/tutorials/edge/javascript-app","JavaScript app",{"_path":128,"title":129},"/docs/tutorials/edge/node-red","Node-RED",{"_path":131,"title":132},"/docs/tutorials/email/airtable","Email to Airtable",{"_path":134,"title":135},"/docs/tutorials/email/api","Email to API",{"_path":137,"title":138},"/docs/tutorials/email/database","Email to Database",{"_path":140,"title":141},"/docs/tutorials/email/discord","Email to Discord",{"_path":143,"title":144},"/docs/tutorials/email/google-sheets","Email to Google Sheets",{"_path":146,"title":147},"/docs/tutorials/email/microsoft-teams","Email to Microsoft Teams",{"_path":149,"title":150},"/docs/tutorials/email/notion","Email to Notion",{"_path":152,"title":153},"/docs/tutorials/email/slack","Email to Slack",{"_path":155,"title":156},"/docs/tutorials","Tutorials",{"_path":158,"title":159},"/docs/tutorials/n8n/email-trigger","n8n Email Trigger (Inbound Email)",{"_path":161,"title":162},"/docs/tutorials/n8n/webhook-trigger","n8n Webhook Trigger (No Public IP)",{"_path":164,"title":165},"/docs/tutorials/n8n/whatsapp-cloud-api-webhook","n8n WhatsApp Cloud API Webhook Setup",{"_path":167,"title":168},"/docs/tutorials/transform/docker-to-slack","DockerHub webhook to Slack notification",{"_path":170,"title":171},"/docs/tutorials/transform/enrich-webhooks","Enrich webhooks from APIs",{"_path":173,"title":174},"/docs/tutorials/warehouse/bigquery","GCP BigQuery",{"_path":176,"title":177},"/docs/webhooks/alerts","Alerts",{"_path":179,"title":180},"/docs/webhooks/auth/username-password","Username and password",{"_path":182,"title":183},"/docs/webhooks/auth/hmac","HMAC",{"_path":185,"title":186},"/docs/webhooks/auth/jwt","JWT authentication",{"_path":188,"title":189},"/docs/webhooks/auth/http-method","Auth using request method",{"_path":191,"title":192},"/docs/webhooks/cors","CORS for webhooks",{"_path":194,"title":195},"/docs/webhooks/cron/using-cron-webhooks","Schedule recurring webhooks",{"_path":197,"title":198},"/docs/webhooks/custom-domains","Custom webhook domains",{"_path":200,"title":201},"/docs/webhooks/custom-subdomains","Custom webhook subdomains",{"_path":203,"title":204},"/docs/webhooks/custom-webhook-response","Custom response to webhooks",{"_path":206,"title":207},"/docs/webhooks/durable-webhooks","Durable webhooks: reliable delivery with automatic retries",{"_path":209,"title":210},"/docs/webhooks/functions/manipulating-json","JSON encoding",{"_path":212,"title":213},"/docs/webhooks/functions/make-http-request","Make HTTP request",{"_path":215,"title":216},"/docs/webhooks/functions/modify-request","Modify webhook headers, body, method and path",{"_path":218,"title":219},"/docs/webhooks/functions/multipart-form-data","Multipart form to JSON",{"_path":221,"title":222},"/docs/webhooks/functions/url-encoded-data","URL Encoded Form",{"_path":224,"title":225},"/docs/webhooks/functions/working-with-time","Working with time",{"_path":227,"title":228},"/docs/webhooks/functions/send-emails","Sending emails",{"_path":230,"title":231},"/docs/webhooks/functions/crypto-functions","Base64, encryption",{"_path":233,"title":234},"/docs/webhooks/functions/integrate-into-cicd","Integrating into CI/CD",{"_path":236,"title":174},"/docs/webhooks/functions/big-query",{"_path":238,"title":239},"/docs/webhooks/functions/accessing-metadata","Accessing metadata",{"_path":241,"title":242},"/docs/webhooks/functions/response-functions","Response (post-delivery) functions",{"_path":244,"title":245},"/docs/webhooks/functions/alerting","Alerting from functions",{"_path":247,"title":248},"/docs/webhooks/functions/helper-libraries","Helper libraries",{"_path":250,"title":251},"/docs/webhooks/functions/transform-webhook-payload","Transform a webhook payload",{"_path":253,"title":254},"/docs/webhooks/functions/filter-webhooks","Filter or drop webhooks before forwarding",{"_path":256,"title":257},"/docs/webhooks/functions","Webhook transformations (functions): modify body, headers, method and path",{"_path":259,"title":260},"/docs/webhooks/internal/localhost","Receive webhooks on localhost with the relay CLI",{"_path":262,"title":263},"/docs/webhooks/large-webhooks","Large Webhooks",{"_path":265,"title":266},"/docs/webhooks/outbound-throttling","Outbound throttling: control webhook delivery speed",{"_path":268,"title":269},"/docs/webhooks/polling-webhooks","Polling webhooks with /v1/events",{"_path":271,"title":272},"/docs/webhooks/public/public-destination","Forward to public URL",{"_path":274,"title":275},"/docs/webhooks/public/multiple-destination-urls","Forward webhooks to multiple destinations",{"_path":277,"title":278},"/docs/webhooks/replay-on-agent-connect","Webhook replay on agent connect: recover missed webhooks",{"_path":280,"title":281},"/docs/webhooks/static-ip-address","Static IP Address",{"_path":283,"title":284},"/docs/webhooks/tls-ssl-errors","Fix TLS/SSL handshake errors: unsupported protocol, wrong version number, handshake failure",{"_path":286,"title":287},"/docs/webhooks/websocket-server","Connecting to websocket server",{"_path":289,"title":290},"/docs/webhooks/zero-retention-buckets","Zero Retention Buckets",{"_path":253,"_dir":292,"_draft":293,"_partial":293,"_locale":294,"title":254,"description":295,"intro":296,"type":297,"section":292,"level":298,"layout":299,"tags":300,"faq":303,"body":316,"_type":1546,"_id":1547,"_source":1548,"_file":1549,"_stem":1550,"_extension":1551,"sitemap":1552},"functions",false,"","Forward only the webhooks you want: drop events by type, branch, status or header, keep the rest out of your destination, and combine code filters with rule-based forwarding filters.","Stop unwanted webhooks in a function with r.stopForwarding(), or without code using forwarding rules.","example","beginner","doc",[301,302],"Functions","Filtering",[304,307,310,313],{"q":305,"a":306},"How do I forward only certain webhook events?","In a function, inspect the parsed body and call r.stopForwarding() for anything you do not want; the request is logged but not delivered. For simple conditions on a field, header, path or query you can use forwarding rules on the output instead, with no code.",{"q":308,"a":309},"What does the provider see when a webhook is dropped?","A normal success response from Webhook Relay, so it does not retry. The request is stored in the bucket's logs with no delivery, which keeps an audit trail of everything the provider sent.",{"q":311,"a":312},"Can I filter GitHub pushes to only the main branch?","Yes. Parse the payload, check that ref equals refs/heads/main (and the X-GitHub-Event header equals push), and stop forwarding otherwise. The same pattern works for pull request actions, Stripe event types or Shopify topics.",{"q":314,"a":315},"Can I route different events to different destinations?","Yes. Put one output per destination on the bucket and give each output its own filter (rule or function), so pushes go to CI, releases go to Slack, and everything else is ignored.",{"type":317,"children":318,"toc":1539},"root",[319,351,358,825,831,1000,1036,1042,1069,1464,1470,1490,1496,1514,1533],{"type":320,"tag":321,"props":322,"children":323},"element","p",{},[324,340,342,349],{"type":320,"tag":325,"props":326,"children":327},"strong",{},[328,331,338],{"type":329,"value":330},"text","To filter webhooks, attach a function that inspects each request and calls ",{"type":320,"tag":332,"props":333,"children":335},"code",{"className":334},[],[336],{"type":329,"value":337},"r.stopForwarding()",{"type":329,"value":339}," for anything the destination should not receive.",{"type":329,"value":341}," Dropped requests still appear in the bucket's logs, the provider still gets a success response, and only matching events are delivered. For simple field, header or path conditions, ",{"type":320,"tag":343,"props":344,"children":346},"a",{"href":345},"/features/forwarding-rules",[347],{"type":329,"value":348},"forwarding rules",{"type":329,"value":350}," do the same without code.",{"type":320,"tag":352,"props":353,"children":355},"h2",{"id":354},"keep-only-certain-event-types",[356],{"type":329,"value":357},"Keep only certain event types",{"type":320,"tag":359,"props":360,"children":361},"code-switcher",{},[362,554],{"type":320,"tag":363,"props":364,"children":365},"template",{"v-slot:javascript":294},[366],{"type":320,"tag":367,"props":368,"children":372},"pre",{"className":369,"code":370,"language":371,"meta":294,"style":294},"language-javascript shiki shiki-themes github-dark","const event = JSON.parse(r.body)\n\nconst allowed = [\"invoice.paid\", \"invoice.payment_failed\", \"customer.subscription.deleted\"]\nif (!allowed.includes(event.type)) {\n  r.stopForwarding()\n  return\n}\n","javascript",[373],{"type":320,"tag":332,"props":374,"children":375},{"__ignoreMap":294},[376,421,431,483,517,536,545],{"type":320,"tag":377,"props":378,"children":381},"span",{"class":379,"line":380},"line",1,[382,388,394,399,404,410,416],{"type":320,"tag":377,"props":383,"children":385},{"style":384},"--shiki-default:#F97583",[386],{"type":329,"value":387},"const",{"type":320,"tag":377,"props":389,"children":391},{"style":390},"--shiki-default:#79B8FF",[392],{"type":329,"value":393}," event",{"type":320,"tag":377,"props":395,"children":396},{"style":384},[397],{"type":329,"value":398}," =",{"type":320,"tag":377,"props":400,"children":401},{"style":390},[402],{"type":329,"value":403}," JSON",{"type":320,"tag":377,"props":405,"children":407},{"style":406},"--shiki-default:#E1E4E8",[408],{"type":329,"value":409},".",{"type":320,"tag":377,"props":411,"children":413},{"style":412},"--shiki-default:#B392F0",[414],{"type":329,"value":415},"parse",{"type":320,"tag":377,"props":417,"children":418},{"style":406},[419],{"type":329,"value":420},"(r.body)\n",{"type":320,"tag":377,"props":422,"children":424},{"class":379,"line":423},2,[425],{"type":320,"tag":377,"props":426,"children":428},{"emptyLinePlaceholder":427},true,[429],{"type":329,"value":430},"\n",{"type":320,"tag":377,"props":432,"children":434},{"class":379,"line":433},3,[435,439,444,448,453,459,464,469,473,478],{"type":320,"tag":377,"props":436,"children":437},{"style":384},[438],{"type":329,"value":387},{"type":320,"tag":377,"props":440,"children":441},{"style":390},[442],{"type":329,"value":443}," allowed",{"type":320,"tag":377,"props":445,"children":446},{"style":384},[447],{"type":329,"value":398},{"type":320,"tag":377,"props":449,"children":450},{"style":406},[451],{"type":329,"value":452}," [",{"type":320,"tag":377,"props":454,"children":456},{"style":455},"--shiki-default:#9ECBFF",[457],{"type":329,"value":458},"\"invoice.paid\"",{"type":320,"tag":377,"props":460,"children":461},{"style":406},[462],{"type":329,"value":463},", ",{"type":320,"tag":377,"props":465,"children":466},{"style":455},[467],{"type":329,"value":468},"\"invoice.payment_failed\"",{"type":320,"tag":377,"props":470,"children":471},{"style":406},[472],{"type":329,"value":463},{"type":320,"tag":377,"props":474,"children":475},{"style":455},[476],{"type":329,"value":477},"\"customer.subscription.deleted\"",{"type":320,"tag":377,"props":479,"children":480},{"style":406},[481],{"type":329,"value":482},"]\n",{"type":320,"tag":377,"props":484,"children":486},{"class":379,"line":485},4,[487,492,497,502,507,512],{"type":320,"tag":377,"props":488,"children":489},{"style":384},[490],{"type":329,"value":491},"if",{"type":320,"tag":377,"props":493,"children":494},{"style":406},[495],{"type":329,"value":496}," (",{"type":320,"tag":377,"props":498,"children":499},{"style":384},[500],{"type":329,"value":501},"!",{"type":320,"tag":377,"props":503,"children":504},{"style":406},[505],{"type":329,"value":506},"allowed.",{"type":320,"tag":377,"props":508,"children":509},{"style":412},[510],{"type":329,"value":511},"includes",{"type":320,"tag":377,"props":513,"children":514},{"style":406},[515],{"type":329,"value":516},"(event.type)) {\n",{"type":320,"tag":377,"props":518,"children":520},{"class":379,"line":519},5,[521,526,531],{"type":320,"tag":377,"props":522,"children":523},{"style":406},[524],{"type":329,"value":525},"  r.",{"type":320,"tag":377,"props":527,"children":528},{"style":412},[529],{"type":329,"value":530},"stopForwarding",{"type":320,"tag":377,"props":532,"children":533},{"style":406},[534],{"type":329,"value":535},"()\n",{"type":320,"tag":377,"props":537,"children":539},{"class":379,"line":538},6,[540],{"type":320,"tag":377,"props":541,"children":542},{"style":384},[543],{"type":329,"value":544},"  return\n",{"type":320,"tag":377,"props":546,"children":548},{"class":379,"line":547},7,[549],{"type":320,"tag":377,"props":550,"children":551},{"style":406},[552],{"type":329,"value":553},"}\n",{"type":320,"tag":363,"props":555,"children":556},{"v-slot:lua":294},[557],{"type":320,"tag":367,"props":558,"children":562},{"className":559,"code":560,"language":561,"meta":294,"style":294},"language-lua shiki shiki-themes github-dark","local json = require(\"json\")\n\nlocal event, err = json.decode(r.RequestBody)\nif err then error(err) end\n\nlocal allowed = { [\"invoice.paid\"] = true, [\"invoice.payment_failed\"] = true }\nif not allowed[event.type] then\n  r:StopForwarding()\n  return\nend\n","lua",[563],{"type":320,"tag":332,"props":564,"children":565},{"__ignoreMap":294},[566,604,611,651,683,690,755,786,809,817],{"type":320,"tag":377,"props":567,"children":568},{"class":379,"line":380},[569,574,579,584,589,594,599],{"type":320,"tag":377,"props":570,"children":571},{"style":384},[572],{"type":329,"value":573},"local",{"type":320,"tag":377,"props":575,"children":576},{"style":406},[577],{"type":329,"value":578}," json ",{"type":320,"tag":377,"props":580,"children":581},{"style":384},[582],{"type":329,"value":583},"=",{"type":320,"tag":377,"props":585,"children":586},{"style":390},[587],{"type":329,"value":588}," require",{"type":320,"tag":377,"props":590,"children":591},{"style":406},[592],{"type":329,"value":593},"(",{"type":320,"tag":377,"props":595,"children":596},{"style":455},[597],{"type":329,"value":598},"\"json\"",{"type":320,"tag":377,"props":600,"children":601},{"style":406},[602],{"type":329,"value":603},")\n",{"type":320,"tag":377,"props":605,"children":606},{"class":379,"line":423},[607],{"type":320,"tag":377,"props":608,"children":609},{"emptyLinePlaceholder":427},[610],{"type":329,"value":430},{"type":320,"tag":377,"props":612,"children":613},{"class":379,"line":433},[614,618,623,627,632,637,642,647],{"type":320,"tag":377,"props":615,"children":616},{"style":384},[617],{"type":329,"value":573},{"type":320,"tag":377,"props":619,"children":620},{"style":406},[621],{"type":329,"value":622}," event, err ",{"type":320,"tag":377,"props":624,"children":625},{"style":384},[626],{"type":329,"value":583},{"type":320,"tag":377,"props":628,"children":629},{"style":406},[630],{"type":329,"value":631}," json.",{"type":320,"tag":377,"props":633,"children":634},{"style":390},[635],{"type":329,"value":636},"decode",{"type":320,"tag":377,"props":638,"children":639},{"style":406},[640],{"type":329,"value":641},"(r.",{"type":320,"tag":377,"props":643,"children":644},{"style":412},[645],{"type":329,"value":646},"RequestBody",{"type":320,"tag":377,"props":648,"children":649},{"style":406},[650],{"type":329,"value":603},{"type":320,"tag":377,"props":652,"children":653},{"class":379,"line":485},[654,658,663,668,673,678],{"type":320,"tag":377,"props":655,"children":656},{"style":384},[657],{"type":329,"value":491},{"type":320,"tag":377,"props":659,"children":660},{"style":406},[661],{"type":329,"value":662}," err ",{"type":320,"tag":377,"props":664,"children":665},{"style":384},[666],{"type":329,"value":667},"then",{"type":320,"tag":377,"props":669,"children":670},{"style":390},[671],{"type":329,"value":672}," error",{"type":320,"tag":377,"props":674,"children":675},{"style":406},[676],{"type":329,"value":677},"(err) ",{"type":320,"tag":377,"props":679,"children":680},{"style":384},[681],{"type":329,"value":682},"end\n",{"type":320,"tag":377,"props":684,"children":685},{"class":379,"line":519},[686],{"type":320,"tag":377,"props":687,"children":688},{"emptyLinePlaceholder":427},[689],{"type":329,"value":430},{"type":320,"tag":377,"props":691,"children":692},{"class":379,"line":538},[693,697,702,706,711,715,720,724,729,734,738,742,746,750],{"type":320,"tag":377,"props":694,"children":695},{"style":384},[696],{"type":329,"value":573},{"type":320,"tag":377,"props":698,"children":699},{"style":406},[700],{"type":329,"value":701}," allowed ",{"type":320,"tag":377,"props":703,"children":704},{"style":384},[705],{"type":329,"value":583},{"type":320,"tag":377,"props":707,"children":708},{"style":406},[709],{"type":329,"value":710}," { [",{"type":320,"tag":377,"props":712,"children":713},{"style":455},[714],{"type":329,"value":458},{"type":320,"tag":377,"props":716,"children":717},{"style":406},[718],{"type":329,"value":719},"] ",{"type":320,"tag":377,"props":721,"children":722},{"style":384},[723],{"type":329,"value":583},{"type":320,"tag":377,"props":725,"children":726},{"style":390},[727],{"type":329,"value":728}," true",{"type":320,"tag":377,"props":730,"children":731},{"style":406},[732],{"type":329,"value":733},", [",{"type":320,"tag":377,"props":735,"children":736},{"style":455},[737],{"type":329,"value":468},{"type":320,"tag":377,"props":739,"children":740},{"style":406},[741],{"type":329,"value":719},{"type":320,"tag":377,"props":743,"children":744},{"style":384},[745],{"type":329,"value":583},{"type":320,"tag":377,"props":747,"children":748},{"style":390},[749],{"type":329,"value":728},{"type":320,"tag":377,"props":751,"children":752},{"style":406},[753],{"type":329,"value":754}," }\n",{"type":320,"tag":377,"props":756,"children":757},{"class":379,"line":547},[758,762,767,772,777,781],{"type":320,"tag":377,"props":759,"children":760},{"style":384},[761],{"type":329,"value":491},{"type":320,"tag":377,"props":763,"children":764},{"style":384},[765],{"type":329,"value":766}," not",{"type":320,"tag":377,"props":768,"children":769},{"style":406},[770],{"type":329,"value":771}," allowed[event.",{"type":320,"tag":377,"props":773,"children":774},{"style":412},[775],{"type":329,"value":776},"type",{"type":320,"tag":377,"props":778,"children":779},{"style":406},[780],{"type":329,"value":719},{"type":320,"tag":377,"props":782,"children":783},{"style":384},[784],{"type":329,"value":785},"then\n",{"type":320,"tag":377,"props":787,"children":789},{"class":379,"line":788},8,[790,795,800,805],{"type":320,"tag":377,"props":791,"children":792},{"style":412},[793],{"type":329,"value":794},"  r",{"type":320,"tag":377,"props":796,"children":797},{"style":406},[798],{"type":329,"value":799},":",{"type":320,"tag":377,"props":801,"children":802},{"style":390},[803],{"type":329,"value":804},"StopForwarding",{"type":320,"tag":377,"props":806,"children":807},{"style":406},[808],{"type":329,"value":535},{"type":320,"tag":377,"props":810,"children":812},{"class":379,"line":811},9,[813],{"type":320,"tag":377,"props":814,"children":815},{"style":384},[816],{"type":329,"value":544},{"type":320,"tag":377,"props":818,"children":820},{"class":379,"line":819},10,[821],{"type":320,"tag":377,"props":822,"children":823},{"style":384},[824],{"type":329,"value":682},{"type":320,"tag":352,"props":826,"children":828},{"id":827},"only-pushes-to-the-main-branch-github",[829],{"type":329,"value":830},"Only pushes to the main branch (GitHub)",{"type":320,"tag":367,"props":832,"children":834},{"className":369,"code":833,"language":371,"meta":294,"style":294},"const eventType = r.headers[\"X-Github-Event\"] || r.headers[\"x-github-event\"]\nconst payload = JSON.parse(r.body)\n\nif (eventType !== \"push\" || payload.ref !== \"refs/heads/main\") {\n  r.stopForwarding()\n  return\n}\n",[835],{"type":320,"tag":332,"props":836,"children":837},{"__ignoreMap":294},[838,886,918,925,971,986,993],{"type":320,"tag":377,"props":839,"children":840},{"class":379,"line":380},[841,845,850,854,859,864,868,873,877,882],{"type":320,"tag":377,"props":842,"children":843},{"style":384},[844],{"type":329,"value":387},{"type":320,"tag":377,"props":846,"children":847},{"style":390},[848],{"type":329,"value":849}," eventType",{"type":320,"tag":377,"props":851,"children":852},{"style":384},[853],{"type":329,"value":398},{"type":320,"tag":377,"props":855,"children":856},{"style":406},[857],{"type":329,"value":858}," r.headers[",{"type":320,"tag":377,"props":860,"children":861},{"style":455},[862],{"type":329,"value":863},"\"X-Github-Event\"",{"type":320,"tag":377,"props":865,"children":866},{"style":406},[867],{"type":329,"value":719},{"type":320,"tag":377,"props":869,"children":870},{"style":384},[871],{"type":329,"value":872},"||",{"type":320,"tag":377,"props":874,"children":875},{"style":406},[876],{"type":329,"value":858},{"type":320,"tag":377,"props":878,"children":879},{"style":455},[880],{"type":329,"value":881},"\"x-github-event\"",{"type":320,"tag":377,"props":883,"children":884},{"style":406},[885],{"type":329,"value":482},{"type":320,"tag":377,"props":887,"children":888},{"class":379,"line":423},[889,893,898,902,906,910,914],{"type":320,"tag":377,"props":890,"children":891},{"style":384},[892],{"type":329,"value":387},{"type":320,"tag":377,"props":894,"children":895},{"style":390},[896],{"type":329,"value":897}," payload",{"type":320,"tag":377,"props":899,"children":900},{"style":384},[901],{"type":329,"value":398},{"type":320,"tag":377,"props":903,"children":904},{"style":390},[905],{"type":329,"value":403},{"type":320,"tag":377,"props":907,"children":908},{"style":406},[909],{"type":329,"value":409},{"type":320,"tag":377,"props":911,"children":912},{"style":412},[913],{"type":329,"value":415},{"type":320,"tag":377,"props":915,"children":916},{"style":406},[917],{"type":329,"value":420},{"type":320,"tag":377,"props":919,"children":920},{"class":379,"line":433},[921],{"type":320,"tag":377,"props":922,"children":923},{"emptyLinePlaceholder":427},[924],{"type":329,"value":430},{"type":320,"tag":377,"props":926,"children":927},{"class":379,"line":485},[928,932,937,942,947,952,957,961,966],{"type":320,"tag":377,"props":929,"children":930},{"style":384},[931],{"type":329,"value":491},{"type":320,"tag":377,"props":933,"children":934},{"style":406},[935],{"type":329,"value":936}," (eventType ",{"type":320,"tag":377,"props":938,"children":939},{"style":384},[940],{"type":329,"value":941},"!==",{"type":320,"tag":377,"props":943,"children":944},{"style":455},[945],{"type":329,"value":946}," \"push\"",{"type":320,"tag":377,"props":948,"children":949},{"style":384},[950],{"type":329,"value":951}," ||",{"type":320,"tag":377,"props":953,"children":954},{"style":406},[955],{"type":329,"value":956}," payload.ref ",{"type":320,"tag":377,"props":958,"children":959},{"style":384},[960],{"type":329,"value":941},{"type":320,"tag":377,"props":962,"children":963},{"style":455},[964],{"type":329,"value":965}," \"refs/heads/main\"",{"type":320,"tag":377,"props":967,"children":968},{"style":406},[969],{"type":329,"value":970},") {\n",{"type":320,"tag":377,"props":972,"children":973},{"class":379,"line":519},[974,978,982],{"type":320,"tag":377,"props":975,"children":976},{"style":406},[977],{"type":329,"value":525},{"type":320,"tag":377,"props":979,"children":980},{"style":412},[981],{"type":329,"value":530},{"type":320,"tag":377,"props":983,"children":984},{"style":406},[985],{"type":329,"value":535},{"type":320,"tag":377,"props":987,"children":988},{"class":379,"line":538},[989],{"type":320,"tag":377,"props":990,"children":991},{"style":384},[992],{"type":329,"value":544},{"type":320,"tag":377,"props":994,"children":995},{"class":379,"line":547},[996],{"type":320,"tag":377,"props":997,"children":998},{"style":406},[999],{"type":329,"value":553},{"type":320,"tag":321,"props":1001,"children":1002},{},[1003,1005,1011,1013,1019,1020,1026,1028,1034],{"type":329,"value":1004},"Use the same shape for pull request ",{"type":320,"tag":332,"props":1006,"children":1008},{"className":1007},[],[1009],{"type":329,"value":1010},"action",{"type":329,"value":1012}," values (",{"type":320,"tag":332,"props":1014,"children":1016},{"className":1015},[],[1017],{"type":329,"value":1018},"opened",{"type":329,"value":463},{"type":320,"tag":332,"props":1021,"children":1023},{"className":1022},[],[1024],{"type":329,"value":1025},"closed",{"type":329,"value":1027},"), Shopify ",{"type":320,"tag":332,"props":1029,"children":1031},{"className":1030},[],[1032],{"type":329,"value":1033},"X-Shopify-Topic",{"type":329,"value":1035},", or Jira issue events.",{"type":320,"tag":352,"props":1037,"children":1039},{"id":1038},"drop-requests-that-fail-signature-verification",[1040],{"type":329,"value":1041},"Drop requests that fail signature verification",{"type":320,"tag":321,"props":1043,"children":1044},{},[1045,1047,1052,1054,1059,1061,1067],{"type":329,"value":1046},"Verify the HMAC before anything else and stop forwarding on mismatch, so forged requests never reach the destination. Store the secret as a ",{"type":320,"tag":343,"props":1048,"children":1049},{"href":86},[1050],{"type":329,"value":1051},"secret service connection",{"type":329,"value":1053},"; the ",{"type":320,"tag":343,"props":1055,"children":1056},{"href":230},[1057],{"type":329,"value":1058},"crypto functions",{"type":329,"value":1060}," page has the HMAC helpers and the ",{"type":320,"tag":343,"props":1062,"children":1064},{"href":1063},"/blog/verify-webhook-signature",[1065],{"type":329,"value":1066},"signature guide",{"type":329,"value":1068}," shows each provider's header format.",{"type":320,"tag":367,"props":1070,"children":1072},{"className":369,"code":1071,"language":371,"meta":294,"style":294},"const secret = require(\"secret:stripe-signing\")\n\nconst signature = r.headers[\"Stripe-Signature\"] || \"\"\nconst timestamp = (signature.match(/t=(\\d+)/) || [])[1]\nconst v1 = (signature.match(/v1=([a-f0-9]+)/) || [])[1]\nconst expected = crypto.hmac(\"sha256\", secret, `${timestamp}.${r.body}`)\n\nif (!v1 || expected !== v1) {\n  r.stopForwarding()\n  return\n}\n",[1073],{"type":320,"tag":332,"props":1074,"children":1075},{"__ignoreMap":294},[1076,1109,1116,1154,1237,1311,1389,1396,1434,1449,1456],{"type":320,"tag":377,"props":1077,"children":1078},{"class":379,"line":380},[1079,1083,1088,1092,1096,1100,1105],{"type":320,"tag":377,"props":1080,"children":1081},{"style":384},[1082],{"type":329,"value":387},{"type":320,"tag":377,"props":1084,"children":1085},{"style":390},[1086],{"type":329,"value":1087}," secret",{"type":320,"tag":377,"props":1089,"children":1090},{"style":384},[1091],{"type":329,"value":398},{"type":320,"tag":377,"props":1093,"children":1094},{"style":412},[1095],{"type":329,"value":588},{"type":320,"tag":377,"props":1097,"children":1098},{"style":406},[1099],{"type":329,"value":593},{"type":320,"tag":377,"props":1101,"children":1102},{"style":455},[1103],{"type":329,"value":1104},"\"secret:stripe-signing\"",{"type":320,"tag":377,"props":1106,"children":1107},{"style":406},[1108],{"type":329,"value":603},{"type":320,"tag":377,"props":1110,"children":1111},{"class":379,"line":423},[1112],{"type":320,"tag":377,"props":1113,"children":1114},{"emptyLinePlaceholder":427},[1115],{"type":329,"value":430},{"type":320,"tag":377,"props":1117,"children":1118},{"class":379,"line":433},[1119,1123,1128,1132,1136,1141,1145,1149],{"type":320,"tag":377,"props":1120,"children":1121},{"style":384},[1122],{"type":329,"value":387},{"type":320,"tag":377,"props":1124,"children":1125},{"style":390},[1126],{"type":329,"value":1127}," signature",{"type":320,"tag":377,"props":1129,"children":1130},{"style":384},[1131],{"type":329,"value":398},{"type":320,"tag":377,"props":1133,"children":1134},{"style":406},[1135],{"type":329,"value":858},{"type":320,"tag":377,"props":1137,"children":1138},{"style":455},[1139],{"type":329,"value":1140},"\"Stripe-Signature\"",{"type":320,"tag":377,"props":1142,"children":1143},{"style":406},[1144],{"type":329,"value":719},{"type":320,"tag":377,"props":1146,"children":1147},{"style":384},[1148],{"type":329,"value":872},{"type":320,"tag":377,"props":1150,"children":1151},{"style":455},[1152],{"type":329,"value":1153}," \"\"\n",{"type":320,"tag":377,"props":1155,"children":1156},{"class":379,"line":485},[1157,1161,1166,1170,1175,1180,1184,1189,1195,1200,1205,1210,1214,1219,1223,1228,1233],{"type":320,"tag":377,"props":1158,"children":1159},{"style":384},[1160],{"type":329,"value":387},{"type":320,"tag":377,"props":1162,"children":1163},{"style":390},[1164],{"type":329,"value":1165}," timestamp",{"type":320,"tag":377,"props":1167,"children":1168},{"style":384},[1169],{"type":329,"value":398},{"type":320,"tag":377,"props":1171,"children":1172},{"style":406},[1173],{"type":329,"value":1174}," (signature.",{"type":320,"tag":377,"props":1176,"children":1177},{"style":412},[1178],{"type":329,"value":1179},"match",{"type":320,"tag":377,"props":1181,"children":1182},{"style":406},[1183],{"type":329,"value":593},{"type":320,"tag":377,"props":1185,"children":1186},{"style":455},[1187],{"type":329,"value":1188},"/",{"type":320,"tag":377,"props":1190,"children":1192},{"style":1191},"--shiki-default:#DBEDFF",[1193],{"type":329,"value":1194},"t=(",{"type":320,"tag":377,"props":1196,"children":1197},{"style":390},[1198],{"type":329,"value":1199},"\\d",{"type":320,"tag":377,"props":1201,"children":1202},{"style":384},[1203],{"type":329,"value":1204},"+",{"type":320,"tag":377,"props":1206,"children":1207},{"style":1191},[1208],{"type":329,"value":1209},")",{"type":320,"tag":377,"props":1211,"children":1212},{"style":455},[1213],{"type":329,"value":1188},{"type":320,"tag":377,"props":1215,"children":1216},{"style":406},[1217],{"type":329,"value":1218},") ",{"type":320,"tag":377,"props":1220,"children":1221},{"style":384},[1222],{"type":329,"value":872},{"type":320,"tag":377,"props":1224,"children":1225},{"style":406},[1226],{"type":329,"value":1227}," [])[",{"type":320,"tag":377,"props":1229,"children":1230},{"style":390},[1231],{"type":329,"value":1232},"1",{"type":320,"tag":377,"props":1234,"children":1235},{"style":406},[1236],{"type":329,"value":482},{"type":320,"tag":377,"props":1238,"children":1239},{"class":379,"line":519},[1240,1244,1249,1253,1257,1261,1265,1269,1274,1279,1283,1287,1291,1295,1299,1303,1307],{"type":320,"tag":377,"props":1241,"children":1242},{"style":384},[1243],{"type":329,"value":387},{"type":320,"tag":377,"props":1245,"children":1246},{"style":390},[1247],{"type":329,"value":1248}," v1",{"type":320,"tag":377,"props":1250,"children":1251},{"style":384},[1252],{"type":329,"value":398},{"type":320,"tag":377,"props":1254,"children":1255},{"style":406},[1256],{"type":329,"value":1174},{"type":320,"tag":377,"props":1258,"children":1259},{"style":412},[1260],{"type":329,"value":1179},{"type":320,"tag":377,"props":1262,"children":1263},{"style":406},[1264],{"type":329,"value":593},{"type":320,"tag":377,"props":1266,"children":1267},{"style":455},[1268],{"type":329,"value":1188},{"type":320,"tag":377,"props":1270,"children":1271},{"style":1191},[1272],{"type":329,"value":1273},"v1=(",{"type":320,"tag":377,"props":1275,"children":1276},{"style":390},[1277],{"type":329,"value":1278},"[a-f0-9]",{"type":320,"tag":377,"props":1280,"children":1281},{"style":384},[1282],{"type":329,"value":1204},{"type":320,"tag":377,"props":1284,"children":1285},{"style":1191},[1286],{"type":329,"value":1209},{"type":320,"tag":377,"props":1288,"children":1289},{"style":455},[1290],{"type":329,"value":1188},{"type":320,"tag":377,"props":1292,"children":1293},{"style":406},[1294],{"type":329,"value":1218},{"type":320,"tag":377,"props":1296,"children":1297},{"style":384},[1298],{"type":329,"value":872},{"type":320,"tag":377,"props":1300,"children":1301},{"style":406},[1302],{"type":329,"value":1227},{"type":320,"tag":377,"props":1304,"children":1305},{"style":390},[1306],{"type":329,"value":1232},{"type":320,"tag":377,"props":1308,"children":1309},{"style":406},[1310],{"type":329,"value":482},{"type":320,"tag":377,"props":1312,"children":1313},{"class":379,"line":538},[1314,1318,1323,1327,1332,1337,1341,1346,1351,1356,1361,1366,1371,1375,1380,1385],{"type":320,"tag":377,"props":1315,"children":1316},{"style":384},[1317],{"type":329,"value":387},{"type":320,"tag":377,"props":1319,"children":1320},{"style":390},[1321],{"type":329,"value":1322}," expected",{"type":320,"tag":377,"props":1324,"children":1325},{"style":384},[1326],{"type":329,"value":398},{"type":320,"tag":377,"props":1328,"children":1329},{"style":406},[1330],{"type":329,"value":1331}," crypto.",{"type":320,"tag":377,"props":1333,"children":1334},{"style":412},[1335],{"type":329,"value":1336},"hmac",{"type":320,"tag":377,"props":1338,"children":1339},{"style":406},[1340],{"type":329,"value":593},{"type":320,"tag":377,"props":1342,"children":1343},{"style":455},[1344],{"type":329,"value":1345},"\"sha256\"",{"type":320,"tag":377,"props":1347,"children":1348},{"style":406},[1349],{"type":329,"value":1350},", secret, ",{"type":320,"tag":377,"props":1352,"children":1353},{"style":455},[1354],{"type":329,"value":1355},"`${",{"type":320,"tag":377,"props":1357,"children":1358},{"style":406},[1359],{"type":329,"value":1360},"timestamp",{"type":320,"tag":377,"props":1362,"children":1363},{"style":455},[1364],{"type":329,"value":1365},"}.${",{"type":320,"tag":377,"props":1367,"children":1368},{"style":406},[1369],{"type":329,"value":1370},"r",{"type":320,"tag":377,"props":1372,"children":1373},{"style":455},[1374],{"type":329,"value":409},{"type":320,"tag":377,"props":1376,"children":1377},{"style":406},[1378],{"type":329,"value":1379},"body",{"type":320,"tag":377,"props":1381,"children":1382},{"style":455},[1383],{"type":329,"value":1384},"}`",{"type":320,"tag":377,"props":1386,"children":1387},{"style":406},[1388],{"type":329,"value":603},{"type":320,"tag":377,"props":1390,"children":1391},{"class":379,"line":547},[1392],{"type":320,"tag":377,"props":1393,"children":1394},{"emptyLinePlaceholder":427},[1395],{"type":329,"value":430},{"type":320,"tag":377,"props":1397,"children":1398},{"class":379,"line":788},[1399,1403,1407,1411,1416,1420,1425,1429],{"type":320,"tag":377,"props":1400,"children":1401},{"style":384},[1402],{"type":329,"value":491},{"type":320,"tag":377,"props":1404,"children":1405},{"style":406},[1406],{"type":329,"value":496},{"type":320,"tag":377,"props":1408,"children":1409},{"style":384},[1410],{"type":329,"value":501},{"type":320,"tag":377,"props":1412,"children":1413},{"style":406},[1414],{"type":329,"value":1415},"v1 ",{"type":320,"tag":377,"props":1417,"children":1418},{"style":384},[1419],{"type":329,"value":872},{"type":320,"tag":377,"props":1421,"children":1422},{"style":406},[1423],{"type":329,"value":1424}," expected ",{"type":320,"tag":377,"props":1426,"children":1427},{"style":384},[1428],{"type":329,"value":941},{"type":320,"tag":377,"props":1430,"children":1431},{"style":406},[1432],{"type":329,"value":1433}," v1) {\n",{"type":320,"tag":377,"props":1435,"children":1436},{"class":379,"line":811},[1437,1441,1445],{"type":320,"tag":377,"props":1438,"children":1439},{"style":406},[1440],{"type":329,"value":525},{"type":320,"tag":377,"props":1442,"children":1443},{"style":412},[1444],{"type":329,"value":530},{"type":320,"tag":377,"props":1446,"children":1447},{"style":406},[1448],{"type":329,"value":535},{"type":320,"tag":377,"props":1450,"children":1451},{"class":379,"line":819},[1452],{"type":320,"tag":377,"props":1453,"children":1454},{"style":384},[1455],{"type":329,"value":544},{"type":320,"tag":377,"props":1457,"children":1459},{"class":379,"line":1458},11,[1460],{"type":320,"tag":377,"props":1461,"children":1462},{"style":406},[1463],{"type":329,"value":553},{"type":320,"tag":352,"props":1465,"children":1467},{"id":1466},"deduplicate-retries",[1468],{"type":329,"value":1469},"Deduplicate retries",{"type":320,"tag":321,"props":1471,"children":1472},{},[1473,1475,1481,1483,1489],{"type":329,"value":1474},"Providers retry on timeouts, so the same event can arrive twice. If your destination is not idempotent, key on the event id and skip repeats. Keep a short-lived record on the destination side, or rely on the provider's id and a ",{"type":320,"tag":343,"props":1476,"children":1478},{"href":1477},"/features/durable-retries",[1479],{"type":329,"value":1480},"durable retry",{"type":329,"value":1482}," schedule that avoids double delivery; see ",{"type":320,"tag":343,"props":1484,"children":1486},{"href":1485},"/blog/webhook-retries-and-idempotency",[1487],{"type":329,"value":1488},"webhook retries and idempotency",{"type":329,"value":409},{"type":320,"tag":352,"props":1491,"children":1493},{"id":1492},"rules-instead-of-code",[1494],{"type":329,"value":1495},"Rules instead of code",{"type":320,"tag":321,"props":1497,"children":1498},{},[1499,1501,1505,1507,1513],{"type":329,"value":1500},"For conditions like \"header equals\", \"JSON path equals\", \"path starts with\" or \"source IP in range\", set a rule on the output and skip the function entirely. Rules and functions can be combined: a rule does the coarse filter, a function does the payload work. Details: ",{"type":320,"tag":343,"props":1502,"children":1503},{"href":345},[1504],{"type":329,"value":348},{"type":329,"value":1506}," and the ",{"type":320,"tag":343,"props":1508,"children":1510},{"href":1509},"/blog/webhook-rule-based-filters",[1511],{"type":329,"value":1512},"filtering and routing guide",{"type":329,"value":409},{"type":320,"tag":321,"props":1515,"children":1516},{},[1517,1519,1524,1526,1531],{"type":329,"value":1518},"Next: ",{"type":320,"tag":343,"props":1520,"children":1521},{"href":250},[1522],{"type":329,"value":1523},"transform the payload",{"type":329,"value":1525}," of the events you keep, or ",{"type":320,"tag":343,"props":1527,"children":1528},{"href":244},[1529],{"type":329,"value":1530},"alert",{"type":329,"value":1532}," when something unexpected arrives.",{"type":320,"tag":1534,"props":1535,"children":1536},"style",{},[1537],{"type":329,"value":1538},"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":294,"searchDepth":433,"depth":433,"links":1540},[1541,1542,1543,1544,1545],{"id":354,"depth":423,"text":357},{"id":827,"depth":423,"text":830},{"id":1038,"depth":423,"text":1041},{"id":1466,"depth":423,"text":1469},{"id":1492,"depth":423,"text":1495},"markdown","content:docs:webhooks:functions:17.filter-webhooks.md","content","docs/webhooks/functions/17.filter-webhooks.md","docs/webhooks/functions/17.filter-webhooks","md",{"loc":253},1788848783809]