django-meta-whatsapp maintains a local mirror of Meta’s block list in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/rahul-baberwal/django-meta-whatsapp/llms.txt
Use this file to discover all available pages before exploring further.
WhatsAppBlockedUser model. Blocked users are automatically excluded from campaign sends and marked in the contact database, giving agents a clear view of who is blocked directly in the inbox.
WhatsAppBlockedUser Model Fields
| Field | Type | Description |
|---|---|---|
account | ForeignKey | The WhatsAppAccount that owns this block record |
phone_number | CharField | Blocked phone number in +E.164 format (e.g. "+919876543210") |
wa_id | CharField | Meta’s internal wa_id, which may differ from the phone number |
blocked_at | DateTimeField | Auto-set timestamp when the block record was created |
blocked_by | CharField | Username or email of the agent who triggered the block |
reason | TextField | Internal note (e.g. "spam", "abuse") |
is_active | BooleanField | True = currently blocked; False = unblocked (record kept for audit history) |
unblocked_at | DateTimeField | Timestamp when the user was unblocked (null if still blocked) |
unblocked_by | CharField | Username or email of the agent who unblocked the user |
meta_error | TextField | Error detail stored if the Meta block API call failed |
(account, phone_number). Unblocking a user sets is_active=False but retains the record for audit trail purposes.
Blocking a User
Useblock_users() to block one or more phone numbers. The function calls Meta’s block API and then updates the local WhatsAppBlockedUser and WhatsAppContact records.
- A
WhatsAppBlockedUserrecord is created or updated withis_active=True - The corresponding
WhatsAppContact.is_blockedis set toTruefor fast inbox filtering
WhatsAppBlockedUser record stores the Meta error in meta_error with is_active=False.
Unblocking a User
Useunblock_users() to remove one or more phone numbers from the block list.
- The
WhatsAppBlockedUserrecord is updated:is_active=False,unblocked_at=now() - The corresponding
WhatsAppContact.is_blockedis set toFalse
WhatsAppBlockedUser record is kept with is_active=False so you maintain a full audit history of who was blocked and when.
Syncing the Block List from Meta
To pull the current state of Meta’s block list and reconcile it with your local database, usesync_blocked_users_from_meta():
- Paginates through all blocked users on Meta (100 per page) using cursor-based pagination
- Creates or updates local
WhatsAppBlockedUserrecords withis_active=True - Sets
WhatsAppContact.is_blocked=Truefor any matching contact records
/whatsapp/contacts/blocked/sync/.
Bulk Operations
For blocking or unblocking large sets of contacts at once:| Operation | UI Endpoint | Python function |
|---|---|---|
| Bulk block | POST /whatsapp/contacts/bulk-block/ with phones list | block_users(phone_list, account=account) |
| Bulk unblock | POST /whatsapp/contacts/bulk-unblock/ with phones list | unblock_users(phone_list, account=account) |
block_users() and unblock_users() accept lists of up to 1,000 phone numbers per call, matching Meta’s API limit.
Campaign Exclusion
Blocked contacts are automatically excluded from campaign sends. Whenaudience_type="contacts", the campaign audience resolver filters the contact queryset as:
is_blocked flag on WhatsAppContact.