Learning path: Your first WhatsApp Cloud API integrationStep 6 of 7

WhatsApp· 5 min read

WhatsApp opt-in: how to collect consent that holds up


Before you message someone on WhatsApp, you need two things: the person gave you their number, and they agreed to receive messages from your business. Meta sets two requirements on the wording. You must “clearly state that a person is opting in to receive communication from the business”, and name the business (Meta, Get opt-in for WhatsApp, accessed 2026-11-02). The method is your choice, and so is the proof. Store what the person saw, when, and where, one row per consent event.

What Meta requires

The developer page quotes the November 2024 policy update. Businesses may contact people on WhatsApp if “(a) they have given their mobile phone number”. The second condition is “(b) businesses have received opt-in permission from the recipient confirming that they wish to receive subsequent messages or calls from a particular business”. The permission “can be general and not specifically for WhatsApp, as long as businesses comply with all local laws”.

The third requirement is “Businesses must comply with applicable law”. Meta does not define a legal standard for consent in your market. The WhatsApp Business Messaging Policy (last updated 23 September 2026) puts that on you: “You are solely responsible for determining the method of opt-in”. Check the consent rules of each country you send to with whoever handles your legal review.

A template does not replace consent. Approval says the content is acceptable; it says nothing about whether this recipient agreed to hear from you.

Where to collect it

Meta lists supported methods: SMS, a website, a phone call through an interactive voice response flow, and “In person or on paper”. “As long as the opt-in method meets the above requirements, it will be policy compliant.”

Four places where an integration can collect it:

Where What the person does What you store as proof
Signup or contact form Ticks an unticked box next to the disclosure text Form ID, text version, timestamp, phone number entered
Checkout Ticks a box for order updates, a second one for offers Order ID, one row per category
SMS Replies YES to a message that names the business Inbound SMS ID and the text of your request
WhatsApp chat Answers yes to a question asked inside the customer service window Message IDs of your question and their answer

A customer who writes to you opens a 24-hour customer service window, and you can reply in it (131047 and the window). Meta’s page does not treat a first message as permission for later ones. Ask inside the window, name the business and the kind of messages, and keep both message IDs.

Meta also gives a utility template objective for this. “Opt-In Management on WhatsApp” covers confirming opt-in “as a follow-up to opt-in collected via other channels”, for example “Thanks for confirming opt-in! You’ll now receive notifications via WhatsApp.” (template categorization).

What the disclosure should say

The two required elements are the business name and a clear statement that the person is opting in. Meta’s tips add three more. Cover “the different categories of messages that a business will send”, or collect “separate opt-in by specific message category”. Give “clear instructions for how people can opt out”. And businesses “should clearly communicate the value of receiving this information”.

A checkbox text that does all of it:

[ ] Send me order and delivery updates from Acme Store on WhatsApp.
[ ] Send me offers and new arrivals from Acme Store on WhatsApp.
Reply STOP in the chat at any time to stop these messages.

Two boxes map to two categories, so a customer can take shipping updates without offers. Meta says separate opt-in “mitigates the risk that users will block your business because they receive unsolicited messages.”

Store proof you can show later

Keep consent as an append-only log of events. A boolean on the contact tells you the current answer. The log tells you who said it, where, and what they were shown.

CREATE TABLE whatsapp_consent_events (
  id            bigserial PRIMARY KEY,
  phone_e164    text        NOT NULL,
  business_name text        NOT NULL,
  category      text        NOT NULL CHECK (category IN ('utility', 'marketing')),
  action        text        NOT NULL CHECK (action IN ('opt_in', 'opt_out')),
  source        text        NOT NULL,  -- 'web_form', 'checkout', 'sms', 'whatsapp_chat', 'meta_user_preferences'
  text_shown    text        NOT NULL,  -- the exact wording, or 'STOP' for a keyword opt-out
  evidence_ref  text,                  -- form submission id, order id, message id
  captured_at   timestamptz NOT NULL DEFAULT now()
);

CREATE INDEX ON whatsapp_consent_events (phone_e164, category, captured_at DESC);

-- current state per number and category: the latest event wins
SELECT DISTINCT ON (phone_e164, category) phone_e164, category, action, captured_at
FROM whatsapp_consent_events
WHERE phone_e164 = '+525512345678'
ORDER BY phone_e164, category, captured_at DESC;

Store text_shown as the full string, not a template key. Wording changes, and the record has to show what this person read on that day. Query the current state before every send outside an open window, and skip numbers whose latest event for that category is opt_out.

Opt-out: there is no built-in STOP

None of the Meta pages cited here describes a keyword that unsubscribes a user on the Cloud API. A customer typing STOP reaches your webhook as an ordinary text message. The policy still requires you to act on it. You “must respect all requests (either on or off WhatsApp) by a person to block, discontinue, or otherwise opt out” (WhatsApp Business Messaging Policy).

Match the keyword on inbound text and write an opt_out row before anything else runs:

const OPT_OUT = new Set(["stop", "unsubscribe", "cancel", "baja", "parar", "sair"]);

function isOptOut(text) {
  const word = (text ?? "").trim().toLowerCase().replace(/[.!¡]/g, "");
  return OPT_OUT.has(word);
}

console.log(isOptOut("STOP"), isOptOut("Baja"), isOptOut("stop sending the menu"));

Exact matching after trimming avoids treating “stop sending the menu” as an opt-out. Route longer messages that contain those words to a person. The reply confirming the opt-out goes out inside the window the STOP message opened, so it is a free-form message.

WhatsApp has its own control for marketing. Users can stop marketing templates from your business in the Offers and announcements setting (marketing templates). The user_preferences webhook reports it with category marketing_messages and value stop or resume. Write those as consent events with source meta_user_preferences. A marketing template sent anyway fails with error 131050, and Meta’s guidance is “Do not retry sending messages to this user”.

Why it matters on the QR connection too

A QR connection has no template review, no Offers and announcements control and no user_preferences webhook. Your keyword handler and consent log are the only opt-out mechanism you have.

If the number behind the connection runs the WhatsApp Business app, the policy covers it. Its list of governed services names “The WhatsApp Business App” alongside the platform. It also states that “Users can block or report businesses”, and that “Our systems may limit the amount of messages a business can send” based on that feedback. Unsolicited messages produce the blocks and reports that put new numbers at risk, as the post on warming new numbers describes.

Z-API Omni team