DEV Community

Cover image for How to Verify Whatsapp Number via Sendchamp API
Aliyu Abubakar
Aliyu Abubakar

Posted on

How to Verify Whatsapp Number via Sendchamp API

The WhatsApp Number Validation API allows you to validate WhatsApp number to determine if a number is active or not.

Let’s walk through how to validate WhatsApp numbers with Sendchamp step by step so you can get on to the important steps like sending WhatsApp messages.

Prerequisite

Before getting started, ensure you have:

  • JavaScript knowledge and familiarity with Nodejs.
  • Nodejs installed on your machine
  • Sendchamp account sign up on Sendchamp.

Navigate to your Sendchamp Dashboard to get your API key in the account settings section.

Setting up your Nodejs Application

Create a .js file, let’s call it index.js, and in the file, initialize an instance with your credentials:

const options = {
  method: 'POST',
  headers: {
    accept: 'application/json',
    'content-type': 'application/json',
    Authorization: 'Bearer ACCESS_KEY’
  },

Enter fullscreen mode Exit fullscreen mode

Make sure to replace ACCESS_KEY with your correct public access key on your Sendchamp dashboard.

Validate WhatsApp Number

The WhatsApp Number validation API takes only one parameter, which is the WhatsApp phone number you want to validate.

Let’s try to hard-code a WhatsApp phone number which should start with a country code, e.g. “2349039099438” to test out the WhatsApp Number validation API:

body: JSON.stringify({"phone_number": "2349039099438",)
};
fetch('https://api.sendchamp.com/api/v1/whatsapp/validate', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
Enter fullscreen mode Exit fullscreen mode

Let’s look at the response.

{
    "code": 200,
    "data": {
        "is_valid": true,
        "phone_number": "2349039099438"
    },
    "errors": null,
    "message": "whatsapp number validated",
    "status": "success"
}
Enter fullscreen mode Exit fullscreen mode

The response shows that the phone number was validated and active. Thanks for following up.

Join Sendchamp Slack developer community for questions you might have and valuable resources.

For quicker testing, you can import our Postman collection and test APIs on Postman

Top comments (0)