Share Location Information
POST and GET Methods
Overview
Share your business-related location like nearest ATM, or a store from your WhatsApp account using API. To send the location information, you need to add latitude and longitude coordinates as additional parameters to the standard outbound WhatsApp API request.
To send location information
- Sign in to KCloud and create your API key.
Refer to the Create an API Key page for steps to create your 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 need to complete the KYC to access all the features of KCloud.
- Send the location information
You can use the below API’s for the location information via WhatsApp account
POST
cURL -X POST "https://api.kaleyra.io/v1/<SID>/messages" \
-H "Content-Type: <CONTENT_TYPE>" \
-H "api-key:<API_KEY>" \
-d "to=<TO_NUMBER>" \
-d "type=<MESSAGE_TYPE>" \
-d "param_lat=<LATITUDE GEO CO-ORDINATE>" \
-d "channel=<CHANNEL_NAME>" \
-d "from=<FROM_NUMBER>" \
-d "callback_url=<CALLBACK_URL>"
-d "param_long=<LONGITUDE GEO CO-ORDINATE>" \
-d "param_name=<RECEIVER NAME>" \
-d "param_address=<RECEIVER ADDRESS>" \
GET
curl --location --request GET 'https://api.kaleyra.io/v1/<SID>/messages?channel=<CHANNEL_NAME>&to=<TO_NUMBER>&from=<FROM_NUMBER>&type=<MESSAGE_TYPE>¶m_lat=<LATITUDE GEO CO-ORDINATE>¶m_long=<LONGITUDE GEO CO-ORDINATE>¶m_name=<RECEIVER NAME>¶m_address=<RECEIVER ADDRESS>'
--header 'api-key:<API_KEY>'
Ensure that you replace the parameter values with the proper inputs in the above code. The below table has a list of parameters and their information.
Replace | With | Example | Required |
---|---|---|---|
| Account SID (Security Identifier) | HXXXXXXX071US | Yes |
| The format in which the data is sent. | application/x-www-form-urlencoded | Yes |
| API Key generated by KCloud. | Ac4XXXXX21f | Yes |
| A valid WhatsApp number of the recipient. Ensure that the country code is prefixed to the number. (E164 format).
| +1202XXXXXXX | Yes |
| Format of the message. | location | Yes |
| Latitude coordinate | 38.846439 | Yes |
| Channel on which the message should be sent. | Yes | |
| The WhatsApp business number registered with KCloud from which the message is to be sent. Ensure the number is prefixed with the country code. (E164 format). | +1202XXXXXXX | Yes |
| The URL that KCloud should send information to when your number receives a response. This URL can be accessed publicly. | Optional | |
| Longitude coordinate | -94.547432 | Yes |
| Name of the receiver who receives the location information | John | Yes |
| Address of the receiver | LA | Yes |
- Below is the response sample of both the GET and POST methods.
{
"id": "794a85fa-3d92-4ca4-86df-f3459aacd128",
"type": "location",
"createdDateTime": "2020-10-06 08:57:22+00:00",
"totalCount": 1,
"data": [
{
"message_id": "794a85fa-3d92-4ca4-86df-f3459aacd128:0",
"recipient": "91xxxxxxxxxx"
}
],
"error": {}
}
Note:In case of an error, ensure that the parameter values are correct in the above code. Refer to the Error Codes and their Description page for detailed information.
Updated 1 day ago