How can I remove the WhatsApp phone number of an end-user profile?

Question

How can I delete a WhatsApp number from the user's profile? From the context panel of your ticket, the phone number shows after the WhatsApp field:

Answer

From the UI, you cannot remove WhatsApp numbers like other phone numbers. WhatsApp users are identified after contacting Zendesk for the first time and WhatsApp phone numbers are stored as an identity in the back-end. From the end user profile, no phone number will appear, however the WhatsApp number is linked to that user.

To remove that number, developers can make use of the API and the User Identities endpoint.

Locate the user_id from your browser after opening the profile from the user you want to edit. It is the long number in the URL :

Follow this end point and build the path below. Replace yousubdomain with your actual subdomain and user_id with the value you found:
https://yoursubdomain.zendesk.com/api/v2/users/user_id/identities

The existing identities for that user will appear:

Delete the messaging type using Postman, or any other tool, with a delete request using this path, gather the id to replace entity_id from the previous step, and replace yousubdomain with your subdomain:

https://yoursubdomain.com/api/v2/users/{user_id}/identities/entity_id.json

After running the API call, you will see this on Postman:

Once you delete that identity, the user profile will no longer show the number:

Disclaimer: This article is provided for instructional purposes only. Zendesk does not support or guarantee the code, which might become obsolete over time. Zendesk can't provide support for third-party technologies such as JavaScript, jQuery, or CSS. Post any issues you have in the comments section or try searching for a solution online.

For more information, see these articles:

Why are some users not correctly identified when they message in through WhatsApp?

User Identities