Add a WhatsApp Number

POST Method

The Add a WhatsApp Number API is used to add a new WhatsApp number to the user's account.

You can add the following WhatsApp number details:

  • Display Name
  • WA Number
  • Incoming URL (“incoming_url“)
  • Image (display_image)
  • Address (address)
  • Business Description (business_description)
  • Business Category - Exact String match accepted Case insensitive (business_catregory)
  • Contact Email (contact_email)
  • Website (website)

📘

Note:

  • The Display Name and the WhatsApp Number are the mandatory fields.
  • The Incoming URL (“incoming_url“), Image (display_image), Address (address), Business Description (business_description), Business Category - Exact String match accepted Case insensitive (business_catregory), Contact Email (contact_email), and Website (website) are optional fields.

Base URL:

<https://api.kaleyra.io/v1/><SID>

To add WhatsApp number, perform the following steps:

  1. Signup or Login to Kaleyra.io and create your API key.

Before you get started, Create an API Key. To view the API Key and the SID, see View API Key and SID.

📘

Note:

After you sign up, your account will be on the trial version. You must complete the KYC to access all the features in Kaleyra.io.

Prerequisite:

  • A WhatsApp verified and approved profile.
  1. API command to Add WhatsApp Number.

Request Format - POST

To add a WhatsApp number, use the /Whatsapp/number endpoints.

curl --location --request POST '{url}/v1/{SID}/whatsapp/number' \
--header 'api-key: <API_KEY>' \
--header 'Content-Type: <CONTENT_TYPE>' \
--data-raw '{
    "display_name":<DISPLAY_NAME>,
    "wa_number":"+13236xxxxx7",
	"address":<MY_ADDRESS>,
    "incoming_url":<INCOMING_URL>,
    "display_image":<DISPLAY_FILE>,
    "business_description": <BUSINESS_DESCRIPTION>,
    "business_category": <BUSINESS_CATEGORY>,
    "contact_email":<CONTACT_EMAIL>,
    "website": <WEBSITE>
}'

Parameters and Variables

The following table displays the parameter and variables used:

ParameterVariableDescriptionExampleMandatory
SIDStringAccount SID (Security Identifier). Generated by Kaleyra.io while creating an API key.HXXXXXXX071USTrue
API_KEYStringYour API Key generated by Kaleyra.io.Ac4XXXXX21fTrue
CONTENT_TYPEAlphanumericIndicates the format of the content the API will be processing.application/JSONTrue
DISPLAY_NAMEStringSpecifies the WhatsApp number display name.TestTrue
WA_NUMBERStringSpecifies the registered WhatsApp number in E164 format.+13236xxxxx7True
ADDRESSStringSpecifies the registered WhatsApp number address.567, "Test", 2nd Phase, Bangalore.False
INCOMMING_URLStringSpecifies the URL for which you receive the incoming callback.https://{your_company_domain}/{incoming_endpoint}False
DISPLAY_IMAGEStringSpecifies the WhatsApp display image to be shown to end customers.https://s3.ap-south-1.amazonaws.com/stage-hexa/docs/1620380334flower-729512__340.jpgFalse
BUSINESS_DESCRIPTIONStringSpecifies the registered WhatsApp number business description.Brief description about the Company.False
BUSINESS CATEGORYStringSpecifies the registered WhatsApp number business category.
The following are the values accepted for Business Category: a) Automotive b) Beauty, Spa, and Salon
c) Clothing and Apparel d) Education e)Entertainment f) Event Planning and Service g) Finance and Banking h) Food and Grocery i) Public Service j) Hotel and Lodging k) Medical and Health l) Non-profit m) Professional Services n) Shopping and Retail o) Travel and Transportation p) Restaurant q) Other
EducationFalse
CONTACT EMAILStringSpecifies the registered WhatsApp number contact Email.[email protected]False
WEBSITEStringSpecifies the business website.https://www.kaleyra.comFalse

Response Format

Success Format

This section provides you the successful JSON response format.

HTTP Response: 
{
    "code": "I102",
    "message": "Phone Number created successfully.",
    "data": [
        {
            "company_id": "ZXXX932d",
            "phone_number": "+13236xxxxx7",
            "country": "ahmedabad local, gujarat",
            "iso_code": "IN",
            "status": 2,
            "description": "business description",
            "address": "my address",
            "email": "[email protected]",
            "name": "xyz",
            "website": [
                "https://google.com/testing"
            ],
            "incoming_url": <url>,
            "category": "medical and health",
            "profile_image": <file_url>,
            "meta_value": null,
            "created_by": "125XXX2647",
            "created_at": 162XXX5490,
            "id": 102,
            "notFirstRequest": 1
        }
    ],
    "error": {}
}

Failure Response

The display_name and wa_number is a mandatory field and cannot be empty. Pass the wa_number and display_name key and its value.

{
    "code": "E947",
    "message": "Failed to create new WA number.",
    "data": [],
    "error": {
        "code": "E413",
        "type": "VALIDATION_ERROR",
        "parameter": "display_name,wa_number",
        "message": "display_name is required and cannot be empty.,wa_number field is required and cannot be empty.",
        "reference": ""
    }
}

The business_catregory value is invalid. Pass the accepted categories.

{
    "code": "E947",
    "message": "Failed to create new WA number.",
    "data": [],
    "error": {
        "code": "E413",
        "type": "VALIDATION_ERROR",
        "parameter": "business_category",
        "message": "business_catregory value is invalid. Valid values are: Automotive,Beauty, Spa, and Salon,Clothing and Apparel,Education,Entertainment,Event Planning and Service,Finance and Banking,Food and Grocery,Public Service,Hotel and Lodging,Medical and Health,Non-profit,Professional Services,Shopping and Retail,Travel and Transportation,Restaurant,Other",
        "reference": ""
    }
}

The display_image cannot be empty. Pass the appropriate value, else do not pass the key.

{
    "error": {
        "code": "E962",
        "type": "VALIDATION_ERROR",
        "parameter": "display_image",
        "message": "display_image cannot be empty",
        "reference": ""
    }
}

Sample Request

The following code is a sample request:

curl --location --request POST '{url}/v1/{sid}/whatsapp/number' \
--header 'api-key: {api-key}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "display_name":"xyz",
    "wa_number":"+13236xxxxx7",
	"address":"my address",
    "incoming_url":<url>,
    "display_image":<file_url>,
    "business_description":"business description",
    "business_category":"medical and health",
    "contact_email":"[email protected]",
    "website":"https://google.com/testing"
}'

Error Codes

The following table provides information about the error codes you would receive when executing the Add WhatsApp Number API.

Error CodeDescription
E413display_name and wa_number field is required and cannot be empty.
E962display_image cannot be empty.