Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Whatsapp Cloud Api?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ashish7802-whatsapp-cloud-api)
# 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