Send Address Messages

The 'Send Address Message API' helps WhatsApp users to share their shipping address with businesses in a simple way.
The API V2 payload contains the messaging_object that holds the information about the WhatsApp address message and the extra_info part can contain any additional information related to the API requests submitted to send the address message.

📘

Note:

The Send Address API V2 supports all the business use cases that the API V1 supports, such as,

Prerequisites

  1. Before you get started, Create an API Key. To view the API Key and the SID, see View API Key and SID.
    A prerequisite for using Kaleyra WhatsApp APIs is to have an active WhatsApp plan on kaleyra platform.
  2. To set up a WhatsApp account on kaleyra.io, see Manual Signup
    and Embedded Signup.
  3. An active WhatsApp for Business API plan that includes:
    • A WhatsApp business number.
    • An associated profile with the business number.
    • A WhatsApp verified and approved profile.

Base URL

https://<api_domain>/v2/<SID>

API Domains and Values

API Request to Send Address Message

To send address messages, use the endpoint:
https://<api_domain>/v2/<sid>/whatsapp/<phone_number>/messages

Request Format

curl -X POST \
  https://<api_domain>/v2/<sid>/whatsapp/<phone_number>/messages \
  -H 'Content-Type: application/json' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d  '{
    "messaging_object": {
        "messaging_product": "<messaging_product>",
        "recipient_type": "<recipient_type>",
        "to": "<to_phone_number>",
        "type": "<type>",
        "interactive": {
            "type": "<type>",
            "body": {
                "text": "<Body Text to request for customer address>"
            }
            "action": {
                "name": "<name>",
                "parameters": {
                    "country": "<coutry_iso_code>"
                }
            }
        }
    },
    "extra_info": {
        "ref": "<ref>",
        "ref1": "<ref1>",
        "ref2": "<ref2>",
        "wa_source": "<wa_source>"
    }
}'

Sample API Request

curl --location --request POST
  'https://api.in.kaleyra.io/v2/xxxxx6913850xxxx/whatsapp/+XX731xxxx124/messages' \
  -H 'Content-Type: application/json' \
  -H 'api-key: xxxxx3b8497f58a94e84b671aca43xxxx' \
  -H 'cache-control: no-cache' \
  -d  '{
    "messaging_object": {
        "messaging_product": "whatsapp",
        "recipient_type": "individual",
        "to": "+91xxxxxxxxxx",
        "type": "interactive",
        "interactive": {
            "type": "address_message",
            "body": {
            "text": "Thanks for your order! Tell us what address you’d like this order delivered to."
            },
            "action": {
                "name": "address_message",
                "parameters": {
                    "country": "COUNTRY_ISO_CODE"
                }
            }
        }
    },
    "extra_info": {
        "ref": "customer1",
        "ref1": "marketing",
        "ref2": "dictionary",
        "wa_source": "api"
    }
}'

Parameters and Data Types

The following table describes all the payload parameters of the Address Message API.

ParameterData TypeDescriptionExampleMandatory?
sidStringAccount SID (Security Identifier).Account SID (Security Identifier).Yes
phone_numberStringPhone number of end customer you want to send a message to.+91XXXXXXXXXXYes
content_typeStringIndicates the format of the content the API will be processing.The only value allowed is application/jsonYes
api-keyStringAPI key generated from Kaleyra platform account.Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3Yes
messaging_objectObjectThe messaging_object is the part of the payload that contains the message object to send WhatsApp address messages.See the specific table for details.Yes
extra_infoObjectThis payload object contains additional details that a user can send for certain functionalities.See the specific table for details.No

The following table describes the parameters of the object 'messaging_object'.

ParameterData TypeDescriptionExampleMandatory?
messaging_productStringMessaging service used for the request.Only 'WhatsApp' value is allowed.Yes
recipient_typeStringCurrently, you can only send messages to individuals. Default is individual.IndividualNo
toA valid WhatsApp number of the recipient. Ensure that the country code is prefixed to the number. (E164 format).

Note: You can add multiple recipients, separate each number using the comma (,) delimiter.
+91xxxxxxxxxxxYes
typeStringThe type of message you want to send. The default value is 'text'.textNo
interactiveObjectThis object enables you to send interactive messages.See the specific table for details.Yes

The following table describes the parameters of the 'interactive' object.

ParameterData TypeDescriptionExampleMandatory?
typeStringThe type of message sentinteractiveYes
bodyObjectThe message bodySee the specific table for details.No
actionObjectThe action object in the API request defines the fields that will be shown to the end-user and into which the data (address information) is sent back.See the specific table for details.Yes

The following table describes the parameters of the 'body' object.

ParameterData TypeDescriptionExampleMandatory?
textStringThe address message sent to the customer."Thanks for your order! Tell us what address you’d like this order delivered to."No

The following table describes the parameters of the 'action' object.

ParameterData TypeDescriptionExampleMandatory?
nameStringType of action to be performed.
In this case, the action is to accept the address information.
address_messageYes
parametersObjectThe address parameter values that should be accepted from the customer. See the specific table for details.Yes

The following table describes the parameters of the 'parameters' object.

ParameterData TypeDescriptionExampleMandatory?
parametersObjectName of the country for which the address values are accepted.
The only allowed values are IN or SG(as per Meta).
countryYes

The following table describes the parameters of the object extra_info.

ParameterData TypeDescriptionExampleMandatory?
refStringInclude any contextual information in this parameter you want to associate with the request. For Example, Name, Customer ID, and many more.
Limit: The variable can be 255 characters long only. This parameter will be available in report and callback.
customer1No
ref1StringInclude any contextual information in this parameter you want to associate with the request. For Example, Name, Customer ID, and many more.
Limit: The variable can be 255 characters long only. This parameter will be available in report and callback.
marketingNo
ref2StringInclude any contextual information in this parameter you want to associate with the request. For Example, Name, Customer ID, and many more.
Limit: The variable can be 255 characters long only. This parameter will be available in report and callback.
dictionaryNo
wa_sourceStringIndicates the source from where the API has been triggered.
Supported values for wa_source are "api", "clevertap", "zoho", "webengage", "shopify", "leadsquared", "responsys", "braze", "hubspot", "salesforce", "zapier", "eloqua", and "moengage".

Note: When you pass any value other than above specified values, the system will override that as the "API".
wa_sourceNo

Sample Success Response

The following success message appears with the status 202 Accepted:

202 Accepted 
{
"code":"WA202"
"message":"Request Accepted",
"data":{
  "message_id":"AXXXXXXXXXXXXXXXXXXX"
}
"error":{}
}

Failure Responses

Following are the error responses for the API level and the business level validations.

Sample Failure Response

The following are the failure responses:

401 Unauthorized
{
    "code": "RBC001",
    "message": "Incorrect SID or API key.",
    "data": [],
    "error": {
        "error": "Incorrect SID or API key."
    }
}
401 Unauthorized phone number
{
    "code": "WA401",
    "message": "Phone number is not present or does not belong to the account.",
    "data": {},
    "error": {
        "phone_number": "Phone number is not present or does not belong to the account."
    }
}
400 Incorrect payload
{
    "code": "WA400",
    "message": "Refer to correct payload format",
    "data": {},
    "error": {
        "payload": "Incorrect payload format"
    }
}
500 Internal Server Error
{
    "code": "WA500",
    "message": "Please try again later",
    "data": {},
    "error": {
        "error": "Internal server error"
    }
}
400 Low balance
{
    "code": "E110",
    "message": "Please check your balance, You have a low balance!",
    "data": {},
    "error": {
        "balance": "Please check your balance, You have a low balance!"
    }
}
401 Unauthorised Account type
{
    "code": "WA-401",
    "message": "API is not available for given customer.Please contact support for more info",
    "data": {},
    "error": {
        "account": "API is not available for given customer.Please contact support for more info"
    }
}
401 Unauthorized phone number version
{
    "code": "WA-401",
    "message": "The phone number you're using is associated with different Version of our WA API. Please use the appropriate endpoint.",
    "data": {},
    "error": {
        "phone_number": "The phone number you're using is associated with different Version of our WA API. Please use the appropriate endpoint."
    }
}