{"id":1705,"date":"2026-11-10T19:21:19","date_gmt":"2026-11-10T19:21:19","guid":{"rendered":"https:\/\/vectalk.com.br\/blog\/whatsapp-webhook-fastapi\/"},"modified":"2026-11-10T19:21:23","modified_gmt":"2026-11-10T19:21:23","slug":"whatsapp-webhook-fastapi","status":"publish","type":"post","link":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/","title":{"rendered":"WhatsApp webhook with FastAPI: async and secure"},"content":{"rendered":"\n<p><em>Updated on November 10, 2026<\/em><\/p>\n\n\n\n<p>A WhatsApp webhook in FastAPI needs to do three things in the right order: read the raw body with <code>await request.body()<\/code>, validate the <code>X-Hub-Signature-256<\/code> header with HMAC-SHA256 and the app secret, and return <code>200<\/code> immediately, leaving processing for later with <code>BackgroundTasks<\/code> or a queue. Anything slow (AI, CRM, a remote database) stays out of the response path.<\/p>\n\n\n\n<p>This article picks up where the <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-bot-python-fastapi\/\">WhatsApp bot with Python and FastAPI<\/a> leaves off: there you build the bot from scratch; here the focus is making the webhook asynchronous, secure and resilient to redeliveries, duplicates and process crashes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why responding fast matters<\/h2>\n\n\n\n<p>According to <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/webhooks\/overview\" target=\"_blank\" rel=\"noreferrer noopener\">Meta&#8217;s webhooks overview<\/a>, when delivery fails (a response other than <code>200<\/code>, or a connection error), Meta retries with decreasing frequency for up to 7 days, and those retries can produce duplicate notifications. The <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/webhooks\/create-webhook-endpoint\" target=\"_blank\" rel=\"noreferrer noopener\">webhook endpoint page<\/a> adds that a single <code>POST<\/code> can carry up to 1,000 batched updates, with no guarantee of batching, and asks you to handle each request individually and deduplicate on your side.<\/p>\n\n\n\n<p>In practice, a handler that calls an AI model before responding becomes a duplicate factory: the response is delayed, the delivery is considered failed, the event comes back and the bot replies twice. If you use Vectalk, the Hub also requires <code>200<\/code> within 20 seconds, according to the <a href=\"https:\/\/docs.vectalk.com.br\/concepts\/webhooks\">Vectalk webhooks documentation<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Webhook structure<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-python\"># main.py\nimport hashlib\nimport hmac\nimport json\nimport os\nfrom contextlib import asynccontextmanager\n\nimport httpx\nfrom fastapi import BackgroundTasks, FastAPI, HTTPException, Query, Request\nfrom fastapi.responses import PlainTextResponse\n\nVERIFY_TOKEN = os.environ[\"WA_VERIFY_TOKEN\"]\nAPP_SECRET = os.environ[\"META_APP_SECRET\"].encode()\nSEND_URL = os.environ[\"WA_SEND_URL\"]  # Meta or Vectalk\nTOKEN = os.environ[\"WA_TOKEN\"]\n\n\n@asynccontextmanager\nasync def lifespan(app: FastAPI):\n    app.state.http = httpx.AsyncClient(\n        timeout=15,\n        headers={\"Authorization\": f\"Bearer {TOKEN}\"},\n    )\n    yield\n    await app.state.http.aclose()\n\n\napp = FastAPI(lifespan=lifespan)<\/code><\/pre>\n\n\n\n<p>A single <code>httpx.AsyncClient<\/code> created in the <code>lifespan<\/code> reuses connections across requests. Creating a new client for every message works, but opens a TLS connection per send.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">GET: endpoint verification<\/h2>\n\n\n\n<p>Meta verifies the endpoint with a <code>GET<\/code> carrying <code>hub.mode<\/code>, <code>hub.verify_token<\/code> and <code>hub.challenge<\/code>. If the token matches, respond <code>200<\/code> with the bare challenge. Since the names contain dots, use <code>alias<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-python\">@app.get(\"\/webhook\", response_class=PlainTextResponse)\nasync def verify(\n    mode: str | None = Query(None, alias=\"hub.mode\"),\n    token: str | None = Query(None, alias=\"hub.verify_token\"),\n    challenge: str | None = Query(None, alias=\"hub.challenge\"),\n):\n    if mode == \"subscribe\" and token and hmac.compare_digest(token, VERIFY_TOKEN):\n        return challenge or \"\"\n    raise HTTPException(status_code=403)<\/code><\/pre>\n\n\n\n<p><code>PlainTextResponse<\/code> matters: if FastAPI returns the challenge as JSON (<code>\"123\"<\/code> with quotes), verification fails.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">POST: signature over the raw body<\/h2>\n\n\n\n<p>Meta signs every event with <code>X-Hub-Signature-256: sha256=&lt;hash&gt;<\/code>, an HMAC-SHA256 of the body using the app secret, according to the <a href=\"https:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/webhooks\/create-webhook-endpoint\" target=\"_blank\" rel=\"noreferrer noopener\">webhook endpoint page<\/a>. In FastAPI, that means not declaring a Pydantic model as the endpoint parameter: the framework would consume and parse the body before you could get the original bytes. Take the <code>Request<\/code> and read <code>await request.body()<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-python\">def valid_signature(raw: bytes, header: str | None) -&gt; bool:\n    if not header:\n        return False\n    expected = \"sha256=\" + hmac.new(APP_SECRET, raw, hashlib.sha256).hexdigest()\n    return hmac.compare_digest(expected, header)\n\n\n@app.post(\"\/webhook\")\nasync def receive(request: Request, background: BackgroundTasks):\n    raw = await request.body()\n\n    if not valid_signature(raw, request.headers.get(\"x-hub-signature-256\")):\n        raise HTTPException(status_code=401)\n\n    payload = json.loads(raw)\n    await save_raw_event(payload)          # fast: just stores it\n    background.add_task(process_event, payload, request.app.state.http)\n    return {\"ok\": True}<\/code><\/pre>\n\n\n\n<p><code>hmac.compare_digest<\/code> compares in constant time. If you want Pydantic validation, do it after the signature check: <code>WebhookPayload.model_validate_json(raw)<\/code>. The signature walkthrough in other languages is in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-signature-validation\/\">how to validate the webhook signature<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">BackgroundTasks: what it does and what it doesn&#8217;t<\/h2>\n\n\n\n<p>According to the <a href=\"https:\/\/fastapi.tiangolo.com\/tutorial\/background-tasks\/\" target=\"_blank\" rel=\"noreferrer noopener\">FastAPI Background Tasks documentation<\/a>, tasks registered with <code>add_task(func, *args, **kwargs)<\/code> run after the response is sent, in the same process as the application. The function can be <code>async def<\/code> or a regular <code>def<\/code>. The documentation itself recommends bigger tools, such as Celery, for heavy computation that needs to run across multiple processes or servers.<\/p>\n\n\n\n<p>That sets the limits clearly:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Situation<\/th><th>Is BackgroundTasks enough?<\/th><th>Alternative<\/th><\/tr><\/thead><tbody><tr><td>Reply with fixed text, mark as read<\/td><td>Yes<\/td><td>\u2014<\/td><\/tr><tr><td>Call AI or a CRM with a few seconds of latency<\/td><td>Yes, at low volume<\/td><td>A queue when volume grows<\/td><\/tr><tr><td>Long processing (transcription, OCR, reports)<\/td><td>No<\/td><td>Celery, RQ, ARQ or a managed queue<\/td><\/tr><tr><td>Event that can&#8217;t be lost during a deploy or crash<\/td><td>Only if the event is stored first<\/td><td>Store it and reprocess from the database<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The point that bites most: after the <code>200<\/code>, Meta considers the event delivered. If the process restarts mid-task (deploy, out of memory, autoscaling), the work is gone and there will be no redelivery. That&#8217;s why the example calls <code>save_raw_event<\/code> before responding. A simple write to a local database takes milliseconds and lets you reprocess whatever was left pending.<\/p>\n\n\n\n<p>Also watch out for blocking code inside <code>async def<\/code>: a synchronous database call or a <code>requests.post<\/code> inside an async function blocks the event loop and delays every other webhook. Use async libraries (<code>httpx<\/code>, <code>asyncpg<\/code>) inside <code>async def<\/code> functions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Idempotent processing<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-python\">async def process_event(payload: dict, http: httpx.AsyncClient) -&gt; None:\n    for entry in payload.get(\"entry\", []):\n        for change in entry.get(\"changes\", []):\n            value = change.get(\"value\", {})\n\n            for msg in value.get(\"messages\", []):\n                if not await mark_as_seen(msg[\"id\"]):\n                    continue  # duplicate: already processed\n                if msg.get(\"type\") == \"text\":\n                    await reply(http, msg[\"from\"], \"We got your message. We'll reply shortly.\")\n\n            for st in value.get(\"statuses\", []):\n                await update_status(st[\"id\"], st[\"status\"], st[\"timestamp\"])\n\n\nasync def reply(http: httpx.AsyncClient, to: str, body: str) -&gt; None:\n    r = await http.post(SEND_URL, json={\n        \"messaging_product\": \"whatsapp\",\n        \"to\": to,\n        \"type\": \"text\",\n        \"text\": {\"body\": body},\n    })\n    r.raise_for_status()<\/code><\/pre>\n\n\n\n<p><code>mark_as_seen<\/code> needs storage shared across processes. An in-memory <code>set()<\/code> won&#8217;t do if you run more than one Uvicorn worker or more than one replica. Two common options:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-python\"># Option 1: Redis (SET NX with expiry)\nasync def mark_as_seen(wamid: str) -&gt; bool:\n    return bool(await redis.set(f\"wa:{wamid}\", 1, nx=True, ex=7 * 24 * 3600))\n\n# Option 2: Postgres with a unique index\n# INSERT INTO wa_inbound (wamid, ...) VALUES ($1, ...) ON CONFLICT (wamid) DO NOTHING\n# and check whether a row was inserted<\/code><\/pre>\n\n\n\n<p>The 7-day expiry matches the maximum redelivery window Meta describes. The fields for each message type are in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-payload-examples\/\">webhook payload examples<\/a>, and the <code>sent<\/code>, <code>delivered<\/code>, <code>read<\/code>, <code>failed<\/code> cycle in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-message-status-webhook\/\">message status via webhook<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">When to swap BackgroundTasks for a queue<\/h2>\n\n\n\n<p>With a queue, the webhook only validates and publishes; separate workers consume:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-python\">@app.post(\"\/webhook\")\nasync def receive(request: Request):\n    raw = await request.body()\n    if not valid_signature(raw, request.headers.get(\"x-hub-signature-256\")):\n        raise HTTPException(status_code=401)\n    await queue.enqueue(\"process_event\", raw.decode())  # ARQ, RQ, Celery, SQS...\n    return {\"ok\": True}<\/code><\/pre>\n\n\n\n<p>The switch pays off when processing takes more than a few seconds, when you need retries with controlled backoff, or when a message spike (a campaign, for example) could saturate the web process. If the bottleneck is sending replies, respect the per-number pace described in <a href=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-api-rate-limit-throughput\/\">WhatsApp API throughput and rate limits<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the signature locally<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"language-bash\">body='{\"object\":\"whatsapp_business_account\",\"entry\":[]}'\nsignature=$(printf '%s' \"$body\" | openssl dgst -sha256 -hmac \"$META_APP_SECRET\" | sed 's\/^.* \/\/')\n\ncurl -i -X POST http:\/\/localhost:8000\/webhook \\\n  -H \"Content-Type: application\/json\" \\\n  -H \"X-Hub-Signature-256: sha256=$signature\" \\\n  -d \"$body\"<\/code><\/pre>\n\n\n\n<p>You should get <code>200<\/code>; with one character changed in the body, <code>401<\/code>. To expose your local server to Meta (which requires HTTPS with a valid certificate), see <a href=\"https:\/\/vectalk.com.br\/blog\/en\/test-whatsapp-webhook-locally\/\">how to test the webhook locally with ngrok<\/a>.<\/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, so only the variables change. To send, use <code>WA_SEND_URL=https:\/\/apis.vectalk.com.br\/api\/messages<\/code> with <code>Authorization: Bearer<\/code> and the same JSON, 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 automatically; 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>To receive, register your FastAPI URL with <code>POST https:\/\/apis.vectalk.com.br\/api\/webhooks<\/code> (<code>instance_id<\/code>, <code>url<\/code>, <code>name<\/code>). The Hub forwards the same payload Meta sends and expects <code>200<\/code> within 20 seconds, so <code>process_event<\/code> doesn&#8217;t change. The Vectalk documentation doesn&#8217;t describe a signature header on the forwarded request: protect the route with your own secret in the registered URL (for example, <code>?key=...<\/code> checked with <code>hmac.compare_digest<\/code>) and confirm with the team 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>Other stacks: <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-api-nextjs\/\">WhatsApp API with Next.js<\/a>. For the big picture, see 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 declare a Pydantic model as the endpoint parameter?<\/h3>\n\n\n\n<p>You can, but then you lose the original bytes and the signature can no longer be verified. Take <code>Request<\/code>, validate the signature over <code>await request.body()<\/code> and only then convert with <code>model_validate_json<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does BackgroundTasks run in a separate process?<\/h3>\n\n\n\n<p>No. The FastAPI documentation makes it clear that tasks run in the same process as the application, whether <code>async def<\/code> or regular <code>def<\/code>, so a process crash takes the task with it. And, according to the <a href=\"https:\/\/starlette.dev\/background\/\" target=\"_blank\" rel=\"noreferrer noopener\">Starlette documentation<\/a>, tasks run in order and, if one raises an exception, the following ones are not executed. That&#8217;s why <code>process_event<\/code> should handle its own errors.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How many Uvicorn workers should I use?<\/h3>\n\n\n\n<p>It depends on the load, but with more than one worker, deduplication must live in Redis or the database, never in memory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What should I return when the signature doesn&#8217;t match?<\/h3>\n\n\n\n<p>A code other than <code>200<\/code>, such as <code>401<\/code>. Monitor that number: a wave of 401s usually means the app secret was changed without updating the server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Do I need to return anything in the POST body?<\/h3>\n\n\n\n<p>No. Meta only looks at the <code>200<\/code> status. A short JSON like <code>{\"ok\": true}<\/code> helps with your own logs.<\/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\/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:\/\/developers.facebook.com\/documentation\/business-messaging\/whatsapp\/messages\/send-messages\" target=\"_blank\" rel=\"noreferrer noopener\">Meta: send messages<\/a>, <a href=\"https:\/\/fastapi.tiangolo.com\/tutorial\/background-tasks\/\" target=\"_blank\" rel=\"noreferrer noopener\">FastAPI: Background Tasks<\/a>, <a href=\"https:\/\/starlette.dev\/background\/\" target=\"_blank\" rel=\"noreferrer noopener\">Starlette: Background Tasks<\/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>How to build a WhatsApp webhook in FastAPI that returns 200 immediately, validates the signature and processes in the background without duplicating or losing events.<\/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-1705","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 Webhook with FastAPI | Vectalk<\/title>\n<meta name=\"description\" content=\"WhatsApp webhook with FastAPI: return 200 fast, validate the X-Hub-Signature-256 signature, process in the background and handle duplicates.\" \/>\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-webhook-fastapi\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WhatsApp Webhook with FastAPI | Vectalk\" \/>\n<meta property=\"og:description\" content=\"WhatsApp webhook with FastAPI: return 200 fast, validate the X-Hub-Signature-256 signature, process in the background and handle duplicates.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog Vectalk\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-10T19:21:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-10T19:21:23+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=\"8 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-webhook-fastapi\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-webhook-fastapi\\\/\"},\"author\":{\"name\":\"wanderleyfcunha\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#\\\/schema\\\/person\\\/ff36ecd9d8257856f227f8e5d639db2b\"},\"headline\":\"WhatsApp webhook with FastAPI: async and secure\",\"datePublished\":\"2026-11-10T19:21:19+00:00\",\"dateModified\":\"2026-11-10T19:21:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-webhook-fastapi\\\/\"},\"wordCount\":1133,\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-webhook-fastapi\\\/\",\"url\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-webhook-fastapi\\\/\",\"name\":\"WhatsApp Webhook with FastAPI | Vectalk\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#website\"},\"datePublished\":\"2026-11-10T19:21:19+00:00\",\"dateModified\":\"2026-11-10T19:21:23+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/#\\\/schema\\\/person\\\/ff36ecd9d8257856f227f8e5d639db2b\"},\"description\":\"WhatsApp webhook with FastAPI: return 200 fast, validate the X-Hub-Signature-256 signature, process in the background and handle duplicates.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-webhook-fastapi\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-webhook-fastapi\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/en\\\/whatsapp-webhook-fastapi\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/vectalk.com.br\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WhatsApp webhook with FastAPI: async and secure\"}]},{\"@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 Webhook with FastAPI | Vectalk","description":"WhatsApp webhook with FastAPI: return 200 fast, validate the X-Hub-Signature-256 signature, process in the background and handle duplicates.","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-webhook-fastapi\/","og_locale":"en_US","og_type":"article","og_title":"WhatsApp Webhook with FastAPI | Vectalk","og_description":"WhatsApp webhook with FastAPI: return 200 fast, validate the X-Hub-Signature-256 signature, process in the background and handle duplicates.","og_url":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/","og_site_name":"Blog Vectalk","article_published_time":"2026-11-10T19:21:19+00:00","article_modified_time":"2026-11-10T19:21:23+00:00","author":"wanderleyfcunha","twitter_card":"summary_large_image","twitter_misc":{"Written by":"wanderleyfcunha","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/#article","isPartOf":{"@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/"},"author":{"name":"wanderleyfcunha","@id":"https:\/\/vectalk.com.br\/blog\/#\/schema\/person\/ff36ecd9d8257856f227f8e5d639db2b"},"headline":"WhatsApp webhook with FastAPI: async and secure","datePublished":"2026-11-10T19:21:19+00:00","dateModified":"2026-11-10T19:21:23+00:00","mainEntityOfPage":{"@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/"},"wordCount":1133,"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/","url":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/","name":"WhatsApp Webhook with FastAPI | Vectalk","isPartOf":{"@id":"https:\/\/vectalk.com.br\/blog\/#website"},"datePublished":"2026-11-10T19:21:19+00:00","dateModified":"2026-11-10T19:21:23+00:00","author":{"@id":"https:\/\/vectalk.com.br\/blog\/#\/schema\/person\/ff36ecd9d8257856f227f8e5d639db2b"},"description":"WhatsApp webhook with FastAPI: return 200 fast, validate the X-Hub-Signature-256 signature, process in the background and handle duplicates.","breadcrumb":{"@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/vectalk.com.br\/blog\/en\/whatsapp-webhook-fastapi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/vectalk.com.br\/blog\/"},{"@type":"ListItem","position":2,"name":"WhatsApp webhook with FastAPI: async and secure"}]},{"@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\/1705","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=1705"}],"version-history":[{"count":1,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/posts\/1705\/revisions"}],"predecessor-version":[{"id":1708,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/posts\/1705\/revisions\/1708"}],"wp:attachment":[{"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/media?parent=1705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/categories?post=1705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vectalk.com.br\/blog\/wp-json\/wp\/v2\/tags?post=1705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}