WhatsApp· 5 min read

Block and unblock users with the WhatsApp Cloud API


Block a WhatsApp user with a POST to https://graph.facebook.com/v26.0/PHONE_NUMBER_ID/block_users, listing each user’s phone number in block_users. A DELETE with the same body unblocks them, and a GET lists the blocklist. Meta’s Block Users page sets the condition: “You can only block users that have messaged your business in the last 24 hours” (Meta Block Users, accessed 2026-11-04). Once blocked, “The user cannot contact your business or see that you are online.” Your business can’t message them either, and send attempts return an error.

Who you can block

The 24-hour rule decides most of the design. You can’t keep a list of abusive numbers and block them next week. Block from your webhook consumer while the user’s last message is still inside that window. A user outside it comes back with error 131047, “Re-engagement required”, the same code Meta uses for an invalid WhatsApp user.

“You cannot block another WhatsApp account.” Your own number returns 131021. “Each request can include a maximum of 1,000 users.” “The blocklist has a 64,000 user limit”, and a full list returns 139101.

The Block Users page names no permission scope. It asks for a system or business token as a Bearer token, covered in Cloud API access tokens.

Block a user

This is Meta’s block sample, with shell variables in place of the phone number ID and token.

curl "https://graph.facebook.com/v26.0/$PHONE_NUMBER_ID/block_users" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '
{
  "messaging_product": "whatsapp",
  "block_users": [
    { "user": "+16505551234" },
    { "user": "+14155559876" }
  ]
}'

Each blocked user comes back under added_users with the input you sent and a wa_id.

{
  "messaging_product": "whatsapp",
  "block_users": {
    "added_users": [
      { "input": "+16505551234", "wa_id": "16505551234" },
      { "input": "+14155559876", "wa_id": "14155559876" }
    ]
  }
}

The user value matches the input value returned when you message that user. Meta adds a warning that “a WhatsApp user’s phone number and ID may not always match.” Store the wa_id from the response next to the number you blocked. One request takes up to 1,000 entries, so a moderation queue can group several users into a single call.

Unblock users and read partial failures

To unblock, send the same body with curl -X DELETE. Successful entries move to removed_users. Users that failed land in failed_users, each with its own errors array. Meta’s unblock sample shows one of each, reindented here.

{
  "messaging_product": "whatsapp",
  "block_users": {
    "removed_users": [
      { "input": "+16505551234", "wa_id": "16505551234" }
    ],
    "failed_users": [
      {
        "input": "+14155559876",
        "wa_id": "14155559876",
        "errors": [
          {
            "message": "Re-engagement required",
            "code": 131047,
            "error_data": { "details": "User has not messaged in the last 24 hours" }
          }
        ]
      }
    ]
  },
  "error": {
    "message": "(#139100) Failed to block/unblock users",
    "type": "OAuthException",
    "code": 139100,
    "error_data": {
      "details": "Failed to unblock some users, see the block_users response list for details"
    },
    "fbtrace_id": "<FBTRACE_ID>"
  }
}

One response carries both the per-user lists and a top-level error with code 139100. Meta doesn’t state the HTTP status for this case. Read failed_users on every response, whatever the status code says.

The failure in Meta’s sample is a 131047 on an unblock, so the 24-hour rule appears to cover unblocking too. The page doesn’t say how to unblock a user once that window has closed.

Block the sender of a webhook message

This script builds the block request from one item of a webhook’s messages array. It reads the phone number from from and falls back to the BSUID in from_user_id when from is absent. Meta’s samples write user with a leading plus, so the script adds one. The docs don’t say whether bare digits work. It needs requests (pip install requests), even in offline mode. Without WHATSAPP_TOKEN set, it prints the body and parses Meta’s partial-failure sample instead of calling the API.

# block_sender.py
import json
import os
import sys

import requests

GRAPH_VERSION = os.environ.get("GRAPH_VERSION", "v26.0")
MAX_USERS = 1000

# Trimmed from Meta's unblock sample with one failed user (Block Users page)
SAMPLE_RESPONSE = {
    "messaging_product": "whatsapp",
    "block_users": {
        "removed_users": [{"input": "+16505551234", "wa_id": "16505551234"}],
        "failed_users": [
            {
                "input": "+14155559876",
                "wa_id": "14155559876",
                "errors": [{"message": "Re-engagement required", "code": 131047}],
            }
        ],
    },
    "error": {"message": "(#139100) Failed to block/unblock users", "code": 139100},
}


def block_entry(message):
    phone = message.get("from")
    if phone:
        return {"user": phone if phone.startswith("+") else "+" + phone}
    bsuid = message.get("from_user_id")
    if bsuid:
        return {"user_id": bsuid}
    raise ValueError("message has neither 'from' nor 'from_user_id'")


def request_body(entries):
    if not 1 <= len(entries) <= MAX_USERS:
        raise ValueError(f"send 1 to {MAX_USERS} users per request")
    return {"messaging_product": "whatsapp", "block_users": entries}


def call(method, body):
    url = (
        f"https://graph.facebook.com/{GRAPH_VERSION}/"
        f"{os.environ['PHONE_NUMBER_ID']}/block_users"
    )
    r = requests.request(
        method,
        url,
        json=body,
        headers={"Authorization": f"Bearer {os.environ['WHATSAPP_TOKEN']}"},
        timeout=10,
    )
    try:
        return r.status_code, r.json()
    except ValueError:
        r.raise_for_status()
        raise


def summarize(data):
    lists = data.get("block_users") or {}
    done = lists.get("added_users", []) + lists.get("removed_users", [])
    failed = lists.get("failed_users", [])
    for user in done:
        print("ok", user.get("user_id") or user.get("input"), user.get("wa_id", ""))
    for user in failed:
        codes = [e.get("code") for e in user.get("errors", [])]
        print("failed", user.get("input"), codes)
    if "error" in data:
        print("error", data["error"].get("code"), data["error"].get("message"))
    return not failed and "error" not in data


if __name__ == "__main__":
    action = sys.argv[1] if len(sys.argv) > 1 else "block"
    if action not in ("block", "unblock"):
        sys.exit("usage: block_sender.py [block|unblock] [MESSAGE_JSON_FILE]")
    if len(sys.argv) > 2:
        with open(sys.argv[2]) as f:
            message = json.load(f)
    else:  # test message in the shape of a webhook messages[] item
        message = {"from": "14155559876", "id": "wamid.TEST", "type": "text"}
    body = request_body([block_entry(message)])
    print(json.dumps(body))
    if "WHATSAPP_TOKEN" not in os.environ:
        print("WHATSAPP_TOKEN not set, parsing Meta's sample response")
        summarize(SAMPLE_RESPONSE)
        sys.exit(0)
    status, data = call("POST" if action == "block" else "DELETE", body)
    print("HTTP", status)
    sys.exit(0 if summarize(data) else 1)

Run python block_sender.py block message.json with WHATSAPP_TOKEN and PHONE_NUMBER_ID exported. The script exits with 1 when any user failed, so a job runner can flag it. Inside a live webhook handler, call block_entry() and then call() right after you decide to block, while the 24-hour window is still open.

Block by BSUID

BSUID support is documented on Meta’s business-scoped user IDs page, not on the Block Users page (Meta business-scoped user IDs, accessed 2026-11-04). The changes apply to block and unblock requests. To block by BSUID, set user_id and leave out user. Meta says you can include both, and then “user (phone number) will take precedence.” This is Meta’s request syntax with its <!-- ADDED --> markers stripped, since HTML comments aren’t valid JSON.

{
  "messaging_product": "whatsapp",
  "block_users": [
    { "user": "<USER_PHONE_NUMBER>" },
    { "user_id": "<BSUID>" }
  ]
}

A BSUID starts with a two-letter country code and a period, as in US.13491208655302741918. Meta says BSUIDs began appearing in webhooks in early April 2026, so a blocklist built before then holds phone numbers only. “Parent BSUIDs are not supported for blocking or unblocking users”, and a request that uses one fails. Meta added that rule on May 4, 2026.

Responses gained a user_id property, set to the BSUID when you blocked or unblocked with one. Since March 18, 2026, the blocklist GET also returns user_id, plus parent_user_id when parent BSUIDs are enabled. wa_id is omitted when the user has turned on usernames and Meta can’t include the phone number. Key your blocklist on user_id when it’s present. Usernames and business-scoped user IDs explains where BSUIDs come from.

List the blocklist

A GET returns blocked users in pages, with limit, after and before as parameters. This is Meta’s sample with shell variables.

curl "https://graph.facebook.com/v26.0/$PHONE_NUMBER_ID/block_users?limit=10" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Each item in data has messaging_product and wa_id, and paging.cursors holds after and before. If the blocklist changes while you page through it, Meta returns 139102, “Blocklist concurrent update”, meaning the version_id no longer matches. The page describes no recovery step, so restart from the first page when that happens.

Error codes

Code Name What it means
139100 Failed to block/unblock some users The block request failed for some or all users; read failed_users
139101 Blocklist limit reached “The blocklist has reached its 64,000 user limit.”
139102 Blocklist concurrent update The list changed during pagination and version_id doesn’t match
139103 Internal error “Internal error. Try the request again.”
130429 Rate limit hit Too many numbers in the request or too many requests in a short time
131021 Self block “Cannot block your own phone number.”
131047 Re-engagement required No message from the user in the last 24 hours, or an invalid WhatsApp user

Retry 139103 and 130429 with backoff. The rest need a different request. Pacing for 130429 is covered in Cloud API rate limits.

What the docs leave open

Meta’s pages don’t say whether the user is told about the block, whether a block expires, or whether a webhook reports it. They don’t name the error code returned when you message a blocked user. Meta’s pages don’t connect blocking to quality rating or to the restrictions in policy enforcement. If a user asks you to stop messaging, record that opt-out in your own system as well, as described in collecting WhatsApp opt-in.

Z-API Omni team