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,
- Send the saved address for confirmation
- Send back the address with validation error.
For more information,
see: Send WhatsApp Address Messages
Send an Interactive WhatsApp Address Message.
Prerequisites
- 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. - To set up a WhatsApp account on kaleyra.io, see Manual Signup
and Embedded Signup. - 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_domain | Value |
---|---|
IN pod | https://api.in.kaleyra.io/ |
SG Pod | https://api.ap.kaleyra.io/ |
EU Pod | https://api.eu.kaleyra.io/ |
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.
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
sid | String | Account SID (Security Identifier). | Account SID (Security Identifier). | Yes |
phone_number | String | Phone number of end customer you want to send a message to. | +91XXXXXXXXXX | Yes |
content_type | String | Indicates the format of the content the API will be processing. | The only value allowed is application/json | Yes |
api-key | String | API key generated from Kaleyra platform account. | Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3 | Yes |
messaging_object | Object | The 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_info | Object | This 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'.
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
messaging_product | String | Messaging service used for the request. | Only 'WhatsApp' value is allowed. | Yes |
recipient_type | String | Currently, you can only send messages to individuals. Default is individual. | Individual | No |
to | A 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. | +91xxxxxxxxxxx | Yes | |
type | String | The type of message you want to send. The default value is 'text'. | text | No |
interactive | Object | This object enables you to send interactive messages. | See the specific table for details. | Yes |
The following table describes the parameters of the 'interactive' object.
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
type | String | The type of message sent | interactive | Yes |
body | Object | The message body | See the specific table for details. | No |
action | Object | The 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.
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
text | String | The 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.
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
name | String | Type of action to be performed. In this case, the action is to accept the address information. | address_message | Yes |
parameters | Object | The 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.
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
parameters | Object | Name of the country for which the address values are accepted. The only allowed values are IN or SG(as per Meta). | country | Yes |
The following table describes the parameters of the object extra_info.
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
ref | String | Include 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. | customer1 | No |
ref1 | String | Include 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. | marketing | No |
ref2 | String | Include 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. | dictionary | No |
wa_source | String | Indicates 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_source | No |
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."
}
}
Updated about 15 hours ago