Updated on November 4, 2026
A multi-tenant SaaS on the official WhatsApp Business API works best with one messaging account (WABA) per customer, connected through Embedded Signup, and a single webhook endpoint that identifies the tenant by phone_number_id or WABA ID. Each customer gets its own token, stored encrypted on your servers, and its own send queue, so one tenant’s limits, quality and errors never spill over to the others.
This guide covers the data model, webhook routing with code, token storage, and how to isolate limits, queues and costs per tenant.
The model: one WABA per customer
One question shapes the whole architecture: who owns the phone number? In SaaS, the right answer is almost always “the customer”. Each customer has its own Meta business portfolio, its own messaging account with its own templates, and its own number. Your app is granted access to that account; it doesn’t own it.
| Option | How it works | When it makes sense |
|---|---|---|
| One WABA per customer, in the customer’s portfolio | The customer connects via Embedded Signup; you get a token scoped to them | Most SaaS (CRM, support, e-commerce, scheduling) |
| Several numbers for one customer in the same WABA | A customer with branches or departments | Large customer, single brand |
| All customers’ numbers in your own portfolio | You own everything | Rarely: limits and quality become one shared bucket |
Why the first option wins:
- Messaging limits. According to the messaging limits docs, the limit is calculated per business portfolio, and all numbers in that portfolio share it. If every tenant lives in your portfolio, one customer’s campaign can burn the daily limit for everyone.
- Templates and display name. Templates live in the messaging account. Each customer gets its own templates approved under its own display name.
- Churn. If a customer cancels, the number and its templates stay with them. You only lose access.
- Verification and policy. Each business is accountable for its own verification and its own policy violations.
How many numbers a portfolio can hold, and what numbers share, is covered in how many numbers you can have on the API. The new split between WhatsApp account and messaging account is explained in WhatsApp account vs. messaging account.
Onboarding: Embedded Signup and what to store
Customers connect their WhatsApp through Embedded Signup, Meta’s flow that runs inside your product. When it finishes, your front end receives a code, the waba_id and the phone_number_id. On your server you:
- Exchange the
codefor a business token withGET /oauth/access_token(client_id,client_secret,code). The onboarding docs are explicit that these calls are server-to-server, never from the browser. - Subscribe your app to the customer’s WABA webhooks with
POST /{WABA_ID}/subscribed_apps. - Register the number with
POST /{PHONE_NUMBER_ID}/registerand a 6-digit PIN (skip this with coexistence, where the number is already registered).
The returned token is a business integration system user access token. Per the access tokens page, it is scoped to that single customer and avoids future re-authentication. That is what a SaaS should store: one per tenant. Never run production on a user access token; it expires within hours.
Want to try it while you read? Create a Vectalk account and send your first message through the official API. Create free account →
Data model
Four tables cover the essentials. The key invariant: phone_number_id and waba_id are unique across the whole system and map to exactly one tenant_id.
create table tenants (
id uuid primary key default gen_random_uuid(),
name text not null,
status text not null default 'active', -- active, suspended, offboarded
daily_send_quota int, -- your own cap, on top of Meta's
created_at timestamptz default now()
);
create table wa_accounts (
waba_id text primary key,
tenant_id uuid not null references tenants(id),
business_id text,
token_ciphertext bytea not null, -- encrypted token (envelope encryption)
token_key_id text not null, -- which KMS key encrypted it
connected_at timestamptz default now(),
revoked_at timestamptz
);
create table wa_phone_numbers (
phone_number_id text primary key,
waba_id text not null references wa_accounts(waba_id),
tenant_id uuid not null references tenants(id),
display_phone_number text,
coexistence boolean default false, -- changes throughput
max_mps int default 80
);
create table wa_events (
id bigint generated always as identity primary key,
tenant_id uuid, -- null if the ID wasn't recognized
waba_id text,
phone_number_id text,
field text not null,
dedup_key text unique not null,
payload jsonb not null,
received_at timestamptz default now()
);
Every business table (contacts, conversations, messages) carries tenant_id. If your database supports it, turn on row-level security filtered by tenant_id, so a query bug can’t leak one customer’s data to another.
Routing webhooks per tenant
There is one webhook per app: Meta sends events from every subscribed WABA to the same callback URL. Routing relies on two IDs in the payload:
entry[].id: the messaging account (WABA) ID. Present on every field.changes[].value.metadata.phone_number_id: the number that received or sent the message. Present on themessagesfield, but not on template or account events.
So the rule is: try phone_number_id first, then fall back to entry.id. The Node.js example below validates the signature, resolves the tenant, stores the event and returns 200 before doing any processing:
import express from "express";
import crypto from "node:crypto";
const app = express();
app.use(express.raw({ type: "application/json" })); // raw body for the signature
function validSignature(raw, header) {
if (!header?.startsWith("sha256=")) return false;
const expected = crypto.createHmac("sha256", process.env.META_APP_SECRET).update(raw).digest("hex");
const received = header.slice(7);
return received.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(received), Buffer.from(expected));
}
async function resolveTenant(db, wabaId, phoneNumberId) {
if (phoneNumberId) {
const n = await db.oneOrNone(
"select tenant_id from wa_phone_numbers where phone_number_id = $1", [phoneNumberId]);
if (n) return n.tenant_id;
}
const a = await db.oneOrNone(
"select tenant_id from wa_accounts where waba_id = $1 and revoked_at is null", [wabaId]);
return a?.tenant_id ?? null;
}
app.post("/webhook", async (req, res) => {
if (!validSignature(req.body, req.get("x-hub-signature-256"))) return res.sendStatus(401);
const payload = JSON.parse(req.body.toString("utf8"));
for (const entry of payload.entry ?? []) {
for (const change of entry.changes ?? []) {
const v = change.value ?? {};
const phoneNumberId = v.metadata?.phone_number_id ?? null;
const tenantId = await resolveTenant(req.app.locals.db, entry.id, phoneNumberId);
const item = v.messages?.[0]?.id ?? v.statuses?.[0]?.id ?? v.message_template_id ?? v.event ?? "";
const dedupKey = `${entry.id}:${change.field}:${item}:${v.statuses?.[0]?.status ?? ""}:${entry.time ?? ""}`;
await req.app.locals.db.none(
`insert into wa_events (tenant_id, waba_id, phone_number_id, field, dedup_key, payload)
values ($1, $2, $3, $4, $5, $6) on conflict (dedup_key) do nothing`,
[tenantId, entry.id, phoneNumberId, change.field, dedupKey, change]);
}
}
res.sendStatus(200); // workers process wa_events per tenant, outside the request
});
Three production details:
- Orphan events. If
tenant_idcomes back null, store the event anyway and raise an alert. It happens when a customer reconnects a different WABA or onboarding failed halfway. - One app secret for everyone. The signature uses your app’s secret, not the customer’s. See how to validate the webhook signature.
- Deduplication. Meta retries unacknowledged events for up to 7 days and may batch up to 1,000 updates per POST, per the webhook endpoint docs. The unique key on
wa_eventsabsorbs retries.
Dedicated webhook per tenant (overrides)
Enterprise customers sometimes want their number’s events delivered to separate infrastructure. Meta lets you override the callback URL per WABA (POST /{WABA_ID}/subscribed_apps with override_callback_uri and verify_token) or per number (POST /{PHONE_NUMBER_ID} with webhook_configuration). Precedence is number, then WABA, then app.
The catch: overrides only apply to fields such as messages, message_echoes, calls, standby and history. Template webhooks (like message_template_status_update) and account webhooks (like account_update) always go to the app’s default callback URL. Your central endpoint stays mandatory.
Where and how to store tokens
Each tenant’s token grants full access to that customer’s messaging. Treat it like a password:
- Use envelope encryption. A master key in a KMS (AWS KMS, Google Cloud KMS, Azure Key Vault or HashiCorp Vault) encrypts data keys; the database stores only ciphertext plus the key ID. A database dump exposes no tokens.
- Decrypt only in the sending worker. Your front end and your SaaS’s public API never see the token.
- Don’t log it. Mask
Authorizationin logs, APM and error messages. - Handle error 190. An invalid or revoked token returns error 190; mark the account as disconnected and ask the customer to reconnect instead of retrying. See error 190: expired or invalid token.
- Listen for offboarding. The
account_updatefield reports events likePARTNER_REMOVED, when the customer removes your app’s access. Setrevoked_atand stop that tenant’s queues.
If you also run numbers of your own (your SaaS’s support line, for instance), use a separate system user token, as described in permanent access token with a system user.
Per-tenant limits: Meta’s and yours
There are two kinds of limits, and both must be isolated per tenant.
| Limit | Value (Meta) | Scope | What to do in your SaaS |
|---|---|---|---|
| Messaging limit | 250 unique recipients per 24 h for new portfolios; then 2,000, 10,000, 100,000 and unlimited | Customer’s portfolio | Read the current tier and block campaigns that exceed it |
| Throughput | Up to 80 messages per second per number; 20 mps with coexistence | Number | One rate limiter per phone_number_id |
| Throughput exceeded | Error 130429 | Number | Back off and retry |
| Too many messages to the same user | Pair rate limit error (131056) | Number + user pair | Space out messages to the same person |
Sources: messaging limits and throughput. Handling details in WhatsApp API rate limits and throughput.
The classic multi-tenant failure is the noisy neighbor: one customer blasts 50,000 messages and a global queue stalls everyone else’s support replies. The fix:
- One queue (or partition) per tenant, with fair consumption across queues (round-robin or plan-based weights).
- Priority within a tenant: support replies and OTPs jump ahead of campaigns.
- A rate limiter per number, honoring 80 or 20 mps from the
max_mpscolumn. - Your own per-plan quota (
daily_send_quota), which also protects customers from a surprise bill.
Queue, retry and idempotency design is covered in WhatsApp API integration architecture.
Billing: who pays Meta
Every delivered message is billed to the messaging account that sent it. In SaaS the question is who holds the payment method: the customer adds their own card to the account, or a partner extends a credit line and passes the cost through. The options are laid out in WhatsApp API payment methods. Whatever the model, record per tenant_id what each customer sent by category. As a reference, for recipients in Brazil since October 1, 2026, Meta charges BRL 0.3217 per delivered marketing message and BRL 0.0350 for utility, authentication and service; rates differ by recipient country.
How to do it with Vectalk
Vectalk is a proxy for the official WhatsApp API and already ships the organization-and-instances structure a SaaS would otherwise build. Per the instances docs, each instance is a phone_number_id with its waba_id, created through Embedded Signup (POST /api/onboarding/embedded-signup with the code) or manually; the Meta access token is stored by the Hub.
In practice:
- An organization token sends through every instance, with
phone_number_idin the body. Instance tokens are locked to a single number, which limits the blast radius if one leaks (authentication). - Webhooks per instance: you can register one or several URLs per instance, receiving Meta’s payload unchanged, so the
phone_number_idrouting in this article works as is. - Billing: Vectalk attaches its own credit line to the customer’s number and deducts each delivered message from a prepaid balance; the customer doesn’t add a card at Meta.
The dashboard has no inbox, AI or bulk sending: that’s your SaaS. To get started, create an account or read the quickstart.
Frequently asked questions
Do I need one Meta app per customer?
No. One app serves every tenant: each customer grants access through Embedded Signup and you store one token per customer. Webhooks from all WABAs arrive at your app’s URL.
How do I know which tenant a template event belongs to?
From entry[].id, the messaging account ID. Template and account events carry no phone_number_id, so a waba_id → tenant_id mapping is mandatory.
Can I put every customer’s number in my own portfolio?
You can, but the messaging limit belongs to the portfolio and would be split among all of them. One customer’s campaign would affect the rest, and customers couldn’t take their number with them when they leave.
Does the customer’s token expire?
According to Meta, the business integration system user token from Embedded Signup doesn’t require periodic re-authentication. It stops working if the customer removes access; handle error 190 and the PARTNER_REMOVED event.
Can I send one tenant’s webhooks to a different server?
Yes, with a WABA or phone number override, but only for message fields. Template and account events still go to the app’s default endpoint.
Official sources checked on November 4, 2026: Messaging limits, Throughput, Access tokens, Embedded Signup, Onboarding as a Tech Provider, Webhook overrides, Create a webhook endpoint, account_update, Vectalk: instances, Vectalk: authentication, Vectalk: webhooks.
Put your business on the official WhatsApp
Create your account, connect your number to the official API (you can keep the app with coexistence) and start serving customers and sending messages.
