Block Users

This API endpoint allows you to block one or more WhatsApp users from sending messages to your WhatsApp Business application. Blocked users will not be able to send messages, and your app will not receive any incoming messages from them. This is useful for preventing spam, harassment, or unwanted communication. Use the unblock endpoint to restore messaging for previously blocked users.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
ℹ️

When you block a WhatsApp user, the following happens:

  • The user cannot contact your business or see that you are online.
  • Your business cannot message the user. If you do, you will encounter an error.
  • You cannot use this API to block another WhatsApp Business

Errors on the API occur per-number since blocks might be successful on some numbers and not others.

The Block Users API is synchronous.

Request Parameters

KeyDescriptionValueData typeRequired/OptionalConstraints
AuthorizationAccess Token for the application{{PARTNER_APP_TOKEN}}StringRequiredShould be a valid Partner App Access Token
appIdApp ID to fetch the access token{{APP_ID}}StringRequired
  • The Id should be a valid app Id of Gupshup.
  • The App must be associated with the account that owns the PARTNER_APP_TOKEN being used.
messaging_productwhatsappStringRequiredMessaging service used for the request. Must be "whatsapp". Cloud API only.
block_usersObjectRequiredList of user(s) to block.
Each element contains a user field.
userStringRequiredThe phone number or WhatsApp ID to be blocked.

Sample Request

curl --location 'https://partner.gupshup.io/partner/app/{{APP_ID}}/user/block' \
--header 'Authorization: {{PARTNER_APP_TOKEN}}' \
--header 'Content-Type: application/json' \
--data '{
    "messaging_product": "whatsapp",
    "block_users": [
        {
            "user": "<PHONE_NUMBER>"
        }
    ]
}'

Sample Response

{
    "block_users": 
	{
        "added_users": 
		[
            {
                "input": "919163805873",
                "wa_id": "919163805873"
            }
        ]
    },
    "messaging_product": "whatsapp",
    "status": "success"
}

Status Codes

Status CodeResponseComments
Success
200

{

"block_users":

{"added_users":[{"input": "919163805873","wa_id": "919163805873"}]
},
"messaging_product": "whatsapp",
"status": "success"
}
}

Error
400

{

"messaging_product": "whatsapp",

"block_users": {"added_users": [{"input": "<PHONE_NUMBER> or <WA_ID>","wa_id": "<WA_ID>"},{"input": "<PHONE_NUMBER> or <WA_ID>",
"wa_id": "<WA_ID>"
},
...
],
"failed_users": [
{
"input": "<PHONE_NUMBER> or <WA_ID>",
"wa_id": "<WA_ID>"
},
{
"input": "<PHONE_NUMBER> or <WA_ID>",
"wa_id": "<WA_ID>"
},
...
"errors": [{
"message": "<MESSAGE>",
"code": "<CODE>",
"error_data": {
"details": "<DETAILS>""
}]
}
}
]
},
"error": {
"message": "(#139100) Failed to block/unblock users",
"type": "OAuthException",
"code": 139100,
"error_data": {
"details": "Failed to block some users, see the block_users response list for details"
},
"fbtrace_id": "<FBTRACE_ID>"
}
}
}

Path Params
string
required
Body Params
Headers
string
Responses

Language
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json