Meta for Developers Integration Guide
What is Meta for Developers?
Graph v23.0 + system-user tokens + HMAC webhooks; WhatsApp Cloud API is the payload.
Pin a version (unversioned = oldest, a silent footgun). Run server automation on a non-expiring *system user token*, not a user token. Every webhook is HMAC-SHA256 of the raw body keyed with the App Secret — validate constant-time, ACK 200, process async; payloads are arrays, so walk every entry/changes/messages or you drop messages. For codeAmani the money surface is WhatsApp: per-message pricing (utility is free inside the 24h window), portfolio-wide limits starting at 250 users/24h, and Flows that turn a chat into a booking/ordering app — paired with M-Pesa STK Push, that's a complete Kenyan-SME product.
Six Meta platform primitives
The Graph underneath; apps + tokens to authorize; WhatsApp, Flows, and webhooks to ship.
███╗ ███╗███████╗████████╗ █████╗ ██████╗ ███████╗██╗ ██╗
████╗ ████║██╔════╝╚══██╔══╝██╔══██╗ ██╔══██╗██╔════╝██║ ██║
██╔████╔██║█████╗ ██║ ███████║ ██║ ██║█████╗ ██║ ██║
██║╚██╔╝██║██╔══╝ ██║ ██╔══██║ ██║ ██║██╔══╝ ╚██╗ ██╔╝
██║ ╚═╝ ██║███████╗ ██║ ██║ ██║ ██████╔╝███████╗ ╚████╔╝
╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═══╝Meta for Developers Integration Guide
Focus — the whole Meta developer surface as one platform: Graph API fundamentals, app creation, the token/permission model, webhooks, and the consumer-facing products (WhatsApp, Messenger, Instagram, Login, Marketing API), capped with a catalog of business build ideas for the Kenyan community. For the deep messaging-only reference (send/template/Twilio-vs-Meta) see the focused
whatsapp-business-apiguide — this guide is the platform-wide course around it.
Overview
Meta for Developers is a single platform
exposed through one base URL — https://graph.facebook.com/{version}/{node-or-edge}.
WhatsApp Cloud API, Messenger, Instagram, Marketing API, and Pages are all
specialized layers over the Graph. Five things are worth internalizing before you
write a line of code:
- Everything is the Graph API. Master nodes/edges/fields, versioning, and error codes once; every product reuses them.
- App type is a permanent decision. A Business app (WhatsApp, Pages, Marketing) uses access levels (Standard → Advanced via App Review). A Consumer app uses app modes (Dev/Live). You cannot convert one to the other — recreate the app if you chose wrong.
- Tokens are a taxonomy, not a single thing. User tokens expire fast; system user tokens are the production credential for server automation.
- Webhook HMAC is the security perimeter. Every event is signed with
X-Hub-Signature-256(HMAC-SHA256 of the raw body keyed with your App Secret). Validate with a constant-time compare before parsing. - WhatsApp pricing is per-message (since July 2025) and messaging limits are portfolio-wide (since Oct 2025), starting at 250 unique users / 24h and scaling algorithmically: 250 → 2,000 → 10,000 → 100,000 → unlimited.
Official Documentation
| Topic | URL |
|---|---|
| Docs index (product map) | https://developers.facebook.com/docs/ |
| Graph API | https://developers.facebook.com/docs/graph-api/ |
| Create an App / App Types | https://developers.facebook.com/docs/development/create-an-app/ |
| WhatsApp Cloud API | https://developers.facebook.com/docs/whatsapp/cloud-api |
| WhatsApp Flows | https://developers.facebook.com/docs/whatsapp/flows |
| WhatsApp pricing & limits | https://developers.facebook.com/docs/whatsapp/pricing |
| Webhooks | https://developers.facebook.com/docs/graph-api/webhooks/getting-started |
| Messenger Platform | https://developers.facebook.com/docs/messenger-platform/ |
| Instagram Platform | https://developers.facebook.com/docs/instagram-platform/ |
| Official WhatsApp Node SDK | https://whatsapp.github.io/WhatsApp-Nodejs-SDK/ |
| Meta Business SDK (Node) | https://github.com/facebook/facebook-nodejs-business-sdk |
The platform map
| Family | Products |
|---|---|
| Core | Graph API, App Development, Webhooks, App Dashboard |
| Business Messaging | WhatsApp Business Platform (Cloud API), WhatsApp Flows, Messenger, Instagram Messaging |
| Social | Pages API, Instagram Platform, Threads API, Sharing, Stories |
| Identity | Facebook Login, Facebook Login for Business |
| Ads & Commerce | Marketing API, Conversions API, Catalog, Commerce Platform |
| SDKs | JS SDK, Android, iOS, whatsapp (Node), Meta Business SDK |
Always pin a version (v23.0+). Unversioned calls default to the oldest
supported version — a silent footgun.
Setup — register, create an app, add a product
- Register at developers.facebook.com with a Facebook account; land in the App Dashboard.
- Create App via the modern use-case flow — a use case auto-attaches the permissions/features/products it needs. You receive an App ID + App Secret (your OAuth client credentials — the secret never ships to a client).
- Add Product → WhatsApp → Set up provisions a test WABA, a test phone number
(free messages to 5 verified recipients), and the pre-approved
hello_worldtemplate.
Tokens at a glance
| Token | Lifetime | Use |
|---|---|---|
| User access token (short) | ~1–2 h | Client reads after login |
| User access token (long) | ~60 days | Server calls on behalf of a user |
| App access token | Long | App config, webhook subscriptions |
| System user token | Configurable / non-expiring | Production server automation (WhatsApp standard) |
| Business integration token | Long | Multi-tenant SaaS acting on a customer's WABA (via Embedded Signup) |
Harden server-to-server calls with appsecret_proof (HMAC-SHA256 of the access
token keyed with the App Secret) and enable Require App Secret so a stolen bare
token is useless. See examples/graph-api-call.ts.
Quickstart
First Graph API call (official Meta Business SDK, Node)
npm install facebook-nodejs-business-sdk// Read the node behind a token, then walk an edge. Same pattern for every product.
const adsSdk = require("facebook-nodejs-business-sdk");
adsSdk.FacebookAdsApi.init(process.env.META_SYSTEM_USER_TOKEN);
// e.g. account.read([...]) / account.getCampaigns([...]) for Marketing APIFirst WhatsApp message (official whatsapp SDK, verified quickstart)
npm install whatsapp
# .env: WA_PHONE_NUMBER_ID= CLOUD_API_ACCESS_TOKEN= CLOUD_API_VERSION=v23.0import WhatsApp from "whatsapp";
const wa = new WhatsApp(Number(process.env.WA_PHONE_NUMBER_ID)); // sender phone-number id
async function sendMessage(recipient) {
// text() works only inside the 24h service window; use template() to initiate.
const res = await wa.messages.text({ body: "Habari! Your order has shipped." }, recipient);
console.log((await res).rawResponse());
}For raw curl/PowerShell sends, interactive messages, templates, and media, the
focused whatsapp-business-api guide has
the runnable recipes. This guide owns the platform-wide patterns below.
Key patterns
Webhooks (the universal push channel)
One mechanism delivers inbound WhatsApp/Messenger/Instagram messages, delivery statuses, template-review outcomes, Page events, and more — all as signed HTTPS POSTs. The contract is always:
- GET verification handshake: echo
hub.challengeiffhub.verify_tokenmatches. - POST delivery: validate
X-Hub-Signature-256over the raw bytes, then ACK 200 immediately and process asynchronously (queue-first). Meta retries non-200 with backoff, which floods slow synchronous handlers. - Payloads are arrays — walk every
entry[].changes[].messages[]. Handling only[0]silently drops messages. Dedupe onwamid/event id (retries happen).
See examples/webhook-router.ts for a complete queue-first receiver.
WhatsApp Flows — chat that behaves like an app
Flows ship multi-screen
native UI (forms, booking, lead-gen) inside the thread. Static Flows (pure
Flow JSON) deliver collected data to your webhook on completion; Dynamic Flows
add an encrypted data endpoint for live validation/availability. Published
Flows can only be deprecated, not deleted. See examples/booking-flow.json for a
Kenyan-business intake Flow.
Embedded Signup — onboard other businesses
For Tech Providers/agencies: a Meta-hosted popup (built on Facebook Login for Business) that creates/links a customer's portfolio + WABA + phone number and returns a code your server exchanges for a business token scoped to that customer. This is how you operate WhatsApp for many SMEs from one dashboard.
Build ideas for Kenyan businesses
WhatsApp is the default channel in East Africa, so the highest-leverage builds
pair a WhatsApp surface with M-Pesa (see MPESA_PATTERNS.md /
daraja-api). A starter catalog —
the full list with effort/revenue notes is in reference/build-ideas-kenya.md:
- Duka order bot — a WhatsApp Flow catalog + cart; checkout fires an M-Pesa STK Push; utility template confirms inside the free service window.
- Boda / delivery dispatch — inbound location message → assign rider → delivery-status templates; rider replies drive the 24h window.
- Clinic / salon booking — a booking Flow writes to Neon; reminder utility templates 24h before; reschedule via reply buttons.
- Sacco / chama assistant — members check balances and contribution status; authentication templates send OTPs; statements as document messages.
- School fees & comms — fee-balance utility templates + an M-Pesa paybill link; broadcast announcements via marketing templates (with opt-out).
- Agri price & advisory — daily market-price templates by crop; a Flow captures produce listings; buyers reply to express interest.
Every one of these is a thin WhatsApp/Flows front-end over the codeAmani stack (Next.js + Neon/Supabase + Daraja), which is exactly the build sweet spot.
codeAmani notes
- Secrets server-side only. App Secret, system user tokens, and Flow private
keys never reach a client. Store in
.env.local/ Vercel env (seeENV_MASTER.md). Rungitleaksbefore any push. - Webhook verification is non-negotiable — HMAC-SHA256 of the raw body with
timingSafeEqual, mirroring our Stripe/Clerk webhook discipline (SECURITY.md). - Phone format: WhatsApp's JSON
touses E.164 without+(254712345678). This matches Daraja's254…rule — but normalize per API; never reuse a Daraja-formatted string directly in a Twilio call (Twilio wantswhatsapp:+254…). - AI routing: put the reply brain (Claude primary per
AI_WORKFLOWS.md) in the async webhook worker, never inline in the 200-ACK path. Cap output to WhatsApp's text limits. - Payments: Kenyan-targeted WhatsApp commerce → M-Pesa/Daraja; US-first → Stripe (the default rail). The build ideas above assume the Kenyan rail.
- Pricing discipline: prefer utility templates inside the open 24h window
(free) over marketing templates; record per-message pricing category from webhook
statusesfor cost rollups.