{"id":1699,"date":"2026-11-10T19:20:55","date_gmt":"2026-11-10T19:20:55","guid":{"rendered":"https:\/\/vectalk.com.br\/blog\/whatsapp-api-nextjs\/"},"modified":"2026-11-10T19:21:00","modified_gmt":"2026-11-10T19:21:00","slug":"whatsapp-api-nextjs","status":"publish","type":"post","link":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/","title":{"rendered":"WhatsApp API with Next.js (App Router): sending and webhooks"},"content":{"rendered":"\n<p><em>Updated on November 10, 2026<\/em><\/p>\n\n\n\n<p>In Next.js with the App Router, an integration with the official WhatsApp Business API fits in two route handlers: a <code>route.ts<\/code> with <code>GET<\/code> and <code>POST<\/code> for the webhook (the <code>GET<\/code> returns the <code>hub.challenge<\/code>, the <code>POST<\/code> validates <code>x-hub-signature-256<\/code> over the raw body) and a server-only function that sends messages with <code>fetch<\/code>. The token lives in an environment variable without the <code>NEXT_PUBLIC_<\/code> prefix, and event processing runs after the response with <code>after()<\/code>.<\/p>\n\n\n\n<p>Below is the full TypeScript code, with the details that break most often in production: reading the body as bytes before validating, keeping your auth middleware from blocking Meta, and not losing work on serverless platforms.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Project structure<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-bash\">app\/\n  api\/\n    whatsapp\/\n      webhook\/route.ts   # GET (verification) + POST (events)\n      send\/route.ts      # internal endpoint for sending messages\nlib\/\n  whatsapp.ts            # send client (server only)\n  process-event.ts       # webhook business logic<\/code><\/pre>\n\n\n\n<p>Environment variables (<code>.env.local<\/code> in development, your hosting dashboard in production):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-bash\">WA_SEND_URL=\"https:\/\/graph.facebook.com\/v27.0\/YOUR_PHONE_NUMBER_ID\/messages\"\nWA_TOKEN=\"your_token\"\nWA_VERIFY_TOKEN=\"a-string-you-made-up\"\nMETA_APP_SECRET=\"app_secret_from_the_meta_dashboard\"\nINTERNAL_API_KEY=\"key-for-calling-the-send-endpoint\"<\/code><\/pre>\n\n\n\n<p>None of them has <code>NEXT_PUBLIC_<\/code>. According to the <a href=\"https:\/\/nextjs.org\/docs\/app\/guides\/environment-variables\" target=\"_blank\" rel=\"noreferrer noopener\">Next.js environment variables guide<\/a>, variables with that prefix are inlined into the browser bundle, and a WhatsApp token in the browser is a leaked token.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The send client<\/h2>\n\n\n\n<p>Sending is a <code>POST<\/code> to <code>https:\/\/graph.facebook.com\/v27.0\/&lt;PHONE_NUMBER_ID&gt;\/messages<\/code> with <code>Authorization: Bearer<\/code> and JSON, according to <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/messages\/send-messages\" target=\"_blank\" rel=\"noreferrer noopener\">Meta&#8217;s send messages documentation<\/a>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-ts\">\/\/ lib\/whatsapp.ts\nimport \"server-only\";\n\ntype SendResult = { wamid: string };\n\nasync function send(payload: Record&lt;string, unknown&gt;): Promise&lt;SendResult&gt; {\n  const res = await fetch(process.env.WA_SEND_URL!, {\n    method: \"POST\",\n    headers: {\n      Authorization: `Bearer ${process.env.WA_TOKEN}`,\n      \"Content-Type\": \"application\/json\",\n    },\n    body: JSON.stringify({ messaging_product: \"whatsapp\", ...payload }),\n    cache: \"no-store\",\n    signal: AbortSignal.timeout(15_000),\n  });\n\n  const data = await res.json();\n  if (!res.ok) {\n    throw new Error(`WhatsApp ${res.status}: ${data?.error?.message ?? \"error\"}`);\n  }\n  return { wamid: data.messages[0].id };\n}\n\nexport function sendText(to: string, body: string) {\n  return send({ to, type: \"text\", text: { body } });\n}\n\nexport function sendTemplate(to: string, name: string, params: string[], lang = \"en_US\") {\n  return send({\n    to,\n    type: \"template\",\n    template: {\n      name,\n      language: { code: lang },\n      components: [\n        { type: \"body\", parameters: params.map((text) =&gt; ({ type: \"text\", text })) },\n      ],\n    },\n  });\n}<\/code><\/pre>\n\n\n\n<p><code>import \"server-only\"<\/code> makes the build fail if a Client Component imports this file by mistake, as described in the <a href=\"https:\/\/nextjs.org\/docs\/app\/getting-started\/server-and-client-components\" target=\"_blank\" rel=\"noreferrer noopener\">Server and Client Components docs<\/a>. It&#8217;s a cheap safety net for the token.<\/p>\n\n\n\n<p>Outside the 24-hour window, only approved templates are accepted. Header fields with media and buttons are covered in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/send-whatsapp-template-message-api\/\">how to send a template through the API<\/a>, and send examples in other languages in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/send-whatsapp-message-api-examples\/\">send a WhatsApp message through the API<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Internal send endpoint<\/h2>\n\n\n\n<p>If your dashboard needs to send messages, expose a protected route handler. Never accept free-form <code>to<\/code> and <code>body<\/code> from any visitor: that turns your number into a spam channel and tanks its quality.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-ts\">\/\/ app\/api\/whatsapp\/send\/route.ts\nimport { NextRequest } from \"next\/server\";\nimport { sendTemplate } from \"@\/lib\/whatsapp\";\n\nexport async function POST(req: NextRequest) {\n  if (req.headers.get(\"x-internal-key\") !== process.env.INTERNAL_API_KEY) {\n    return new Response(\"unauthorized\", { status: 401 });\n  }\n\n  const { to, orderId } = await req.json();\n  const { wamid } = await sendTemplate(to, \"order_confirmed\", [orderId]);\n  return Response.json({ wamid });\n}<\/code><\/pre>\n\n\n\n<p>In an app with login, replace the fixed key with a check of the user session and limit which templates each role can send.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The webhook: GET verification<\/h2>\n\n\n\n<p><a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/webhooks\/create-webhook-endpoint\" target=\"_blank\" rel=\"noreferrer noopener\">Meta&#8217;s webhook endpoint documentation<\/a> says verification arrives as a <code>GET<\/code> with <code>hub.mode=subscribe<\/code>, <code>hub.verify_token<\/code> and <code>hub.challenge<\/code>. If the token matches, respond <code>200<\/code> with the bare challenge in the body. Any other response leaves the endpoint unverified.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-ts\">\/\/ app\/api\/whatsapp\/webhook\/route.ts (part 1)\nimport { NextRequest, after } from \"next\/server\";\nimport crypto from \"node:crypto\";\nimport { processEvent } from \"@\/lib\/process-event\";\n\nexport const runtime = \"nodejs\";\n\nexport async function GET(req: NextRequest) {\n  const p = req.nextUrl.searchParams;\n\n  if (p.get(\"hub.mode\") === \"subscribe\" &amp;&amp; p.get(\"hub.verify_token\") === process.env.WA_VERIFY_TOKEN) {\n    return new Response(p.get(\"hub.challenge\") ?? \"\", {\n      status: 200,\n      headers: { \"Content-Type\": \"text\/plain\" },\n    });\n  }\n  return new Response(\"forbidden\", { status: 403 });\n}<\/code><\/pre>\n\n\n\n<p>Since Next.js 15, <code>GET<\/code> handlers are no longer static by default, according to the version history in the <a href=\"https:\/\/nextjs.org\/docs\/app\/api-reference\/file-conventions\/route\" target=\"_blank\" rel=\"noreferrer noopener\">route.js reference<\/a>. Since this <code>GET<\/code> reads <code>searchParams<\/code>, it&#8217;s dynamic anyway. If you&#8217;re on an older version, make sure the response wasn&#8217;t cached at build time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The webhook: POST with x-hub-signature-256<\/h2>\n\n\n\n<p>Every event comes with the <code>X-Hub-Signature-256: sha256=&lt;hash&gt;<\/code> header, an HMAC-SHA256 of the body using the app secret. The golden rule: compute the hash over the bytes you received, before any <code>JSON.parse<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-ts\">\/\/ app\/api\/whatsapp\/webhook\/route.ts (part 2)\nfunction isValidSignature(raw: Buffer, header: string | null): boolean {\n  if (!header) return false;\n  const expected =\n    \"sha256=\" + crypto.createHmac(\"sha256\", process.env.META_APP_SECRET!).update(raw).digest(\"hex\");\n  const a = Buffer.from(expected);\n  const b = Buffer.from(header);\n  return a.length === b.length &amp;&amp; crypto.timingSafeEqual(a, b);\n}\n\nexport async function POST(req: NextRequest) {\n  const raw = Buffer.from(await req.arrayBuffer());\n\n  if (!isValidSignature(raw, req.headers.get(\"x-hub-signature-256\"))) {\n    return new Response(\"invalid signature\", { status: 401 });\n  }\n\n  const payload = JSON.parse(raw.toString(\"utf8\"));\n\n  after(async () =&gt; {\n    try {\n      await processEvent(payload);\n    } catch (err) {\n      console.error(\"webhook processing failed\", err);\n    }\n  });\n\n  return new Response(\"ok\", { status: 200 });\n}<\/code><\/pre>\n\n\n\n<p>Points worth noting:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>No body parser.<\/strong> Unlike Pages Router API Routes, route handlers don&#8217;t need any <code>bodyParser<\/code> configuration for webhooks; the reference itself shows an example with <code>request.text()<\/code>. Here we use <code>arrayBuffer()<\/code> to get the exact bytes.<\/li>\n\n\n<li><strong><code>timingSafeEqual<\/code> with equal lengths.<\/strong> The function throws if the buffers have different lengths, which is why the <code>length<\/code> check comes first.<\/li>\n\n\n<li><strong><code>runtime = \"nodejs\"<\/code>.<\/strong> The code uses <code>node:crypto<\/code>. On the Edge runtime you&#8217;d have to rewrite the HMAC with the Web Crypto API.<\/li>\n\n<\/ul>\n\n\n\n<p>The signature walkthrough in plain Node.js, Python and PHP is in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-signature-validation\/\">how to validate the WhatsApp webhook signature<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Processing after the response with after()<\/h2>\n\n\n\n<p>According to the <a href=\"https:\/\/nextjs.org\/docs\/app\/api-reference\/functions\/after\" target=\"_blank\" rel=\"noreferrer noopener\"><code>after<\/code> reference<\/a>, the function schedules work to run after the response is finished, works in route handlers and became stable in Next.js 15.1. It respects the route&#8217;s configured maximum duration (<code>maxDuration<\/code>, if the platform supports it). It&#8217;s supported on a Node.js server and in Docker; on serverless platforms it depends on a <code>waitUntil<\/code> mechanism, which Vercel provides.<\/p>\n\n\n\n<p>That solves the common case: return <code>200<\/code> to Meta quickly and only then call AI, a CRM or the database. But it isn&#8217;t a queue. If the function dies midway, the event is lost, because Meta already got <code>200<\/code> and won&#8217;t redeliver. For work that can&#8217;t be lost, write the raw payload to a table before responding and process it from there.<\/p>\n\n\n\n<p>And make <code>processEvent<\/code> ready for duplicates. The <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/webhooks\/overview\" target=\"_blank\" rel=\"noreferrer noopener\">webhooks overview<\/a> warns that deliveries without a <code>200<\/code> are retried for up to 7 days and may arrive duplicated:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-ts\">\/\/ lib\/process-event.ts\nimport \"server-only\";\nimport { sendText } from \".\/whatsapp\";\nimport { db } from \".\/db\"; \/\/ your database client\n\nexport async function processEvent(payload: any) {\n  for (const entry of payload.entry ?? []) {\n    for (const change of entry.changes ?? []) {\n      const value = change.value ?? {};\n\n      for (const msg of value.messages ?? []) {\n        const inserted = await db.inboundInsertIgnore({ wamid: msg.id, from: msg.from, type: msg.type });\n        if (!inserted) continue; \/\/ already processed\n\n        if (msg.type === \"text\") {\n          await sendText(msg.from, \"We got your message. We'll reply shortly.\");\n        }\n      }\n\n      for (const st of value.statuses ?? []) {\n        await db.updateOutboundStatus(st.id, st.status, st.timestamp);\n      }\n    }\n  }\n}<\/code><\/pre>\n\n\n\n<p><code>inboundInsertIgnore<\/code> stands for an <code>INSERT ... ON CONFLICT DO NOTHING<\/code> (or your ORM&#8217;s equivalent) with a unique index on <code>wamid<\/code>. The format of each message type is in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-payload-examples\/\">webhook payload examples<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Auth middleware and other blockers<\/h2>\n\n\n\n<p>If your app uses middleware (<code>proxy<\/code> in newer versions) to require login, the webhook route will answer with a redirect to the login page and Meta will never see a <code>200<\/code>. Remove <code>\/api\/whatsapp\/webhook<\/code> from the <code>matcher<\/code>. The same goes for password protection on previews and firewalls that block bots.<\/p>\n\n\n\n<p>Other frequent causes of a silent webhook are in the <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-not-working\/\">webhook not working checklist<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Where to host<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Hosting<\/th><th><code>after()<\/code><\/th><th>Note<\/th><\/tr><\/thead><tbody><tr><td>Node.js server (<code>next start<\/code>)<\/td><td>Supported<\/td><td>Long-running process; the simplest option for webhooks<\/td><\/tr><tr><td>Docker<\/td><td>Supported<\/td><td>Same as Node.js<\/td><\/tr><tr><td>Serverless adapters (e.g. Vercel)<\/td><td>Platform-specific<\/td><td>Requires a <code>waitUntil<\/code> primitive, which Vercel provides; respect <code>maxDuration<\/code><\/td><\/tr><tr><td>Static export<\/td><td>Not supported<\/td><td>No server, no webhook<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Source: support table in the <a href=\"https:\/\/nextjs.org\/docs\/app\/api-reference\/functions\/after\" target=\"_blank\" rel=\"noreferrer noopener\"><code>after<\/code> reference<\/a>. Lambda and Cloudflare Workers comparisons are in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-aws-lambda-serverless\/\">serverless WhatsApp webhook<\/a>. Meta requires HTTPS with a valid certificate, and preview domains with protection enabled won&#8217;t work as a callback.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to do this with Vectalk<\/h2>\n\n\n\n<p>Vectalk is a proxy for the official Cloud API: the code above stays the same, only the variables change. For sending, use <code>WA_SEND_URL=\"https:\/\/apis.vectalk.com.br\/api\/messages\"<\/code> with <code>Authorization: Bearer<\/code> and the same JSON body, as in the <a href=\"https:\/\/docs.vectalk.com.br\/quickstart\">Vectalk quickstart<\/a>. With an instance token, the <code>phone_number_id<\/code> is resolved from the token; with an organization token (the global token from <strong>Settings (Configura\u00e7\u00f5es) \u2192 API Tokens<\/strong>), include <code>phone_number_id<\/code> in the body, according to the <a href=\"https:\/\/docs.vectalk.com.br\/authentication\">authentication page<\/a>.<\/p>\n\n\n\n<p>For the webhook, register the route handler URL with <code>POST https:\/\/apis.vectalk.com.br\/api\/webhooks<\/code> (<code>instance_id<\/code>, <code>url<\/code>, <code>name<\/code>). The <a href=\"https:\/\/docs.vectalk.com.br\/concepts\/webhooks\">webhooks documentation<\/a> says the Hub forwards the same payload Meta sends and expects <code>200<\/code> within 20 seconds, so <code>processEvent<\/code> doesn&#8217;t change. Since the documentation doesn&#8217;t describe a signature header on the forwarded request, replace the <code>x-hub-signature-256<\/code> check with a secret in the registered URL (for example, <code>?key=...<\/code>) and confirm through the <a href=\"https:\/\/vectalk.com.br\/contato.html\">contact page<\/a>. To get started, <a href=\"https:\/\/apps.vectalk.com.br\/register\">create your account<\/a>.<\/p>\n\n\n\n<p>Running a separate backend in Rails or Python? See <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-ruby-on-rails\/\">WhatsApp API with Ruby on Rails<\/a> and <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/\">webhook with FastAPI<\/a>. The same flow in Express is in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-bot-nodejs-express\/\">WhatsApp bot with Node.js<\/a>. For the platform overview, start with the <a href=\"https:\/\/vectalk.com.br\/blog\/en\/official-whatsapp-api\/\">official WhatsApp API<\/a> guide.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Can I call the WhatsApp API directly from a Client Component?<\/h3>\n\n\n\n<p>No. The token would have to go to the browser, and anyone could send messages on behalf of your number. Make the call in a route handler, a Server Action or other server-only code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why does the signature fail if I use <code>await req.json()<\/code>?<\/h3>\n\n\n\n<p>Because you lose the original bytes. Read with <code>arrayBuffer()<\/code> (or <code>text()<\/code>), validate, and only then <code>JSON.parse<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Server Action or route handler for sending messages?<\/h3>\n\n\n\n<p>For buttons in your own dashboard, a Server Action works well. For calls from other systems (ERP, n8n, cron), an authenticated route handler is simpler to integrate. Both run on the server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does the webhook work on the Edge runtime?<\/h3>\n\n\n\n<p>It does, but the example uses <code>node:crypto<\/code>. On Edge, rewrite the HMAC with <code>crypto.subtle<\/code> and compare the hashes carefully. In most cases, the Node.js runtime is the shortest path.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What happens if <code>processEvent<\/code> throws inside <code>after()<\/code>?<\/h3>\n\n\n\n<p>Meta already received <code>200<\/code> and won&#8217;t redeliver. Log the error and, for critical events, store the payload before responding so you can reprocess it.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>Official sources consulted on November 10, 2026:<\/strong> <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/messages\/send-messages\" target=\"_blank\" rel=\"noreferrer noopener\">Meta: send messages<\/a>, <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/webhooks\/create-webhook-endpoint\" target=\"_blank\" rel=\"noreferrer noopener\">Meta: create a webhook endpoint<\/a>, <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/webhooks\/overview\" target=\"_blank\" rel=\"noreferrer noopener\">Meta: webhooks overview<\/a>, <a href=\"https:\/\/nextjs.org\/docs\/app\/api-reference\/file-conventions\/route\" target=\"_blank\" rel=\"noreferrer noopener\">Next.js: route.js<\/a>, <a href=\"https:\/\/nextjs.org\/docs\/app\/api-reference\/functions\/after\" target=\"_blank\" rel=\"noreferrer noopener\">Next.js: after<\/a>, <a href=\"https:\/\/nextjs.org\/docs\/app\/guides\/environment-variables\" target=\"_blank\" rel=\"noreferrer noopener\">Next.js: environment variables<\/a>, <a href=\"https:\/\/nextjs.org\/docs\/app\/getting-started\/server-and-client-components\" target=\"_blank\" rel=\"noreferrer noopener\">Next.js: Server and Client Components (server-only)<\/a>, <a href=\"https:\/\/docs.vectalk.com.br\/quickstart\">Vectalk: quickstart<\/a>, <a href=\"https:\/\/docs.vectalk.com.br\/authentication\">Vectalk: authentication<\/a>, <a href=\"https:\/\/docs.vectalk.com.br\/concepts\/webhooks\">Vectalk: webhooks<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>App Router route handlers to send messages through the official WhatsApp Business API and receive the webhook with verification and signature validation.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-1699","post","type-post","status-publish","format-standard","hentry","category-blog"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WhatsApp API with Next.js (App Router) | Vectalk<\/title>\n<meta name=\"description\" content=\"WhatsApp API in Next.js: route handlers for sending and webhooks, hub.challenge verification, x-hub-signature-256 checks and processing with after().\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WhatsApp API with Next.js (App Router) | Vectalk\" \/>\n<meta property=\"og:description\" content=\"WhatsApp API in Next.js: route handlers for sending and webhooks, hub.challenge verification, x-hub-signature-256 checks and processing with after().\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Vectalk\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-10T19:20:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-10T19:21:00+00:00\" \/>\n<meta name=\"author\" content=\"wanderleyfcunha\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"wanderleyfcunha\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-api-nextjs\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-api-nextjs\\\/\"},\"author\":{\"name\":\"wanderleyfcunha\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#\\\/schema\\\/person\\\/ff36ecd9d8257856f227f8e5d639db2b\"},\"headline\":\"WhatsApp API with Next.js (App Router): sending and webhooks\",\"datePublished\":\"2026-11-10T19:20:55+00:00\",\"dateModified\":\"2026-11-10T19:21:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-api-nextjs\\\/\"},\"wordCount\":1216,\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-api-nextjs\\\/\",\"url\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-api-nextjs\\\/\",\"name\":\"WhatsApp API with Next.js (App Router) | Vectalk\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#website\"},\"datePublished\":\"2026-11-10T19:20:55+00:00\",\"dateModified\":\"2026-11-10T19:21:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#\\\/schema\\\/person\\\/ff36ecd9d8257856f227f8e5d639db2b\"},\"description\":\"WhatsApp API in Next.js: route handlers for sending and webhooks, hub.challenge verification, x-hub-signature-256 checks and processing with after().\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-api-nextjs\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-api-nextjs\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-api-nextjs\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WhatsApp API with Next.js (App Router): sending and webhooks\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/\",\"name\":\"Blog Vectalk\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#\\\/schema\\\/person\\\/ff36ecd9d8257856f227f8e5d639db2b\",\"name\":\"wanderleyfcunha\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g\",\"caption\":\"wanderleyfcunha\"},\"sameAs\":[\"https:\\\/\\\/vectalk.com.br\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WhatsApp API with Next.js (App Router) | Vectalk","description":"WhatsApp API in Next.js: route handlers for sending and webhooks, hub.challenge verification, x-hub-signature-256 checks and processing with after().","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/","og_locale":"en_US","og_type":"article","og_title":"WhatsApp API with Next.js (App Router) | Vectalk","og_description":"WhatsApp API in Next.js: route handlers for sending and webhooks, hub.challenge verification, x-hub-signature-256 checks and processing with after().","og_url":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/","og_site_name":"Blog Vectalk","article_published_time":"2026-11-10T19:20:55+00:00","article_modified_time":"2026-11-10T19:21:00+00:00","author":"wanderleyfcunha","twitter_card":"summary_large_image","twitter_misc":{"Written by":"wanderleyfcunha","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/#article","isPartOf":{"@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/"},"author":{"name":"wanderleyfcunha","@id":"https:\/\/vectalk.com.br\/blog\/#\/schema\/person\/ff36ecd9d8257856f227f8e5d639db2b"},"headline":"WhatsApp API with Next.js (App Router): sending and webhooks","datePublished":"2026-11-10T19:20:55+00:00","dateModified":"2026-11-10T19:21:00+00:00","mainEntityOfPage":{"@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/"},"wordCount":1216,"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/","url":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/","name":"WhatsApp API with Next.js (App Router) | Vectalk","isPartOf":{"@id":"https:\/\/vectalk.com.br\/blog\/#website"},"datePublished":"2026-11-10T19:20:55+00:00","dateModified":"2026-11-10T19:21:00+00:00","author":{"@id":"https:\/\/vectalk.com.br\/blog\/#\/schema\/person\/ff36ecd9d8257856f227f8e5d639db2b"},"description":"WhatsApp API in Next.js: route handlers for sending and webhooks, hub.challenge verification, x-hub-signature-256 checks and processing with after().","breadcrumb":{"@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-nextjs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vectalk.com.br\/blog\/"},{"@type":"ListItem","position":2,"name":"WhatsApp API with Next.js (App Router): sending and webhooks"}]},{"@type":"WebSite","@id":"https:\/\/vectalk.com.br\/blog\/#website","url":"https:\/\/vectalk.com.br\/blog\/","name":"Blog Vectalk","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/vectalk.com.br\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/vectalk.com.br\/blog\/#\/schema\/person\/ff36ecd9d8257856f227f8e5d639db2b","name":"wanderleyfcunha","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/21c37077f1731eb558973f27a7b647d55f72fde5200a843ac5f5345b247ea725?s=96&d=mm&r=g","caption":"wanderleyfcunha"},"sameAs":["https:\/\/vectalk.com.br\/blog"]}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/posts\/1699","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/comments?post=1699"}],"version-history":[{"count":1,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/posts\/1699\/revisions"}],"predecessor-version":[{"id":1702,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/posts\/1699\/revisions\/1702"}],"wp:attachment":[{"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/media?parent=1699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/categories?post=1699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/tags?post=1699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}