Skip to content
Back to skills

Whatsapp Cloud Api

ASecurity

> **Verification Tier:** `code_example_tested` | **Last Verified:** 2026-11-18 > **Official Docs:** https://developers.facebook.com/docs/whatsapp/cloud-api

  • 13 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentsrustnodeapisecurity

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add ashish7802/awesome-api-skills --skill whatsapp-cloud-api --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Whatsapp Cloud Api?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Whatsapp Cloud Api
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ashish7802-whatsapp-cloud-api/badge)](https://www.skillsdirectory.com/skills/ashish7802-whatsapp-cloud-api)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# WhatsApp Business Cloud API Skill

> **Verification Tier:** `code_example_tested` | **Last Verified:** 2026-11-18  
> **Official Docs:** https://developers.facebook.com/docs/whatsapp/cloud-api

## Overview
The WhatsApp Cloud API (hosted by Meta Graph API at `https://graph.facebook.com/v22.0/<PHONE_NUMBER_ID>/messages`) lets applications send template and interactive messages and receive real-time customer messages and delivery receipts via webhooks.

## Authentication
Use a permanent **System User Access Token** (`WHATSAPP_ACCESS_TOKEN`) from Meta Business Manager sent as `Authorization: Bearer <token>`. Never use temporary 24-hour developer tokens in production.

```ts
import crypto from 'node:crypto';

export function verifyWhatsAppSignature(rawBody: Buffer, sigHeader: string, appSecret: string): boolean {
  const expected = `sha256=${crypto.createHmac('sha256', appSecret).update(rawBody).digest('hex')}`;
  const a = Buffer.from(sigHeader, 'utf8');
  const b = Buffer.from(expected, 'utf8');
  return a.length === b.length && crypto.timingSafeEqual(a, b);
}
```

## Core Concepts
- **24-Hour Customer Service Window**: Free-form text/media messages can ONLY be sent within 24 hours of the user's last inbound message. Outside that window, you MUST send a pre-approved **Message Template**.
- **GET Webhook Handshake**: Meta validates your callback URL by sending `GET ?hub.mode=subscribe&hub.verify_token=<token>&hub.challenge=<challenge>`. Compare `hub.verify_token` with `WHATSAPP_VERIFY_TOKEN` and return the raw `hub.challenge` string with HTTP `200`.
- **POST Webhook Signature**: Every webhook POST includes `X-Hub-Signature-256: sha256=<hex>` signed with your **Meta App Secret** (`WHATSAPP_APP_SECRET`) over the exact raw request bytes. Always verify with `crypto.timingSafeEqual`.

## Error Handling & Rate Limits
- Return HTTP `200 OK` quickly to Meta webhooks (even for status updates like `delivered`/`read`) and process heavy work asynchronously via a queue.
- Deduplicate inbound messages using `message.id` (`wamid...`) because Meta may redeliver webhooks.
- Monitor messaging tier limits and Graph API error codes (`131047` re-engagement message required, `130429` rate limit hit).

## Security Best Practices
- Validate `X-Hub-Signature-256` on every POST webhook before trusting payload contents.
- Store `WHATSAPP_ACCESS_TOKEN`, `WHATSAPP_APP_SECRET`, and `WHATSAPP_VERIFY_TOKEN` in secret storage.

## AI Pitfalls
- Trying to send free-form text outside the 24-hour customer service window instead of an approved template (fails with error `131047`).
- Using the Verify Token instead of the Meta **App Secret** to compute `X-Hub-Signature-256`.
- Returning JSON instead of plain text `hub.challenge` during the GET webhook verification handshake.

## Production Checklist
- [ ] Permanent System User token configured (not 24h test token)
- [ ] GET handshake verifies `hub.mode === "subscribe"` and `hub.verify_token`
- [ ] POST webhook verifies `X-Hub-Signature-256` over raw body with `timingSafeEqual`
- [ ] Inbound messages deduplicated by `wamid` and processed asynchronously

## References
- [WhatsApp Cloud API Docs](https://developers.facebook.com/docs/whatsapp/cloud-api)
- [Webhooks Payload Verification](https://developers.facebook.com/docs/graph-api/webhooks/getting-started#verification-requests)

## Related skills
- [`twilio`](../twilio/SKILL.md) — alternative to
- [`resend`](../resend/SKILL.md) — works well with
- [`svix`](../svix/SKILL.md) — works well with

Files in this skill

  • SKILL.md3.4 KB
  • examples/quickstart.ts1.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.