Preview of the URL
POST Method
Description
When you send a link in the message, the Preview URL parameter will display the preview of the landing page associated with that link. You have to add the preview_url parameter and set the value as True in the request.
Note:
The preview of the URL is only supported for the non-template type (text) of messages.
Base URL
<https://api.kaleyra.io/v1/><SID>
To display the preview
- Signup or Login to Kaleyra.io 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 must complete the KYC to access all the features in Kaleyra.io.
- API Call
Execute the following API command to include the preview of the URL in a message.
curl --location --request POST 'https://api.kaleyra.io/v1/<SID>/messages'
--H 'Content-Type: <CONTENT_TYPE>'
--H 'api-key: <API_KEY>'
--f 'to=<TO_NUMBER>'
--f 'type=<MESSAGE_TYPE>'
--f 'body=<CONTENT>'
--f 'preview_url=true'
--f 'channel=<CHANNEL_NAME>'
--f 'from=<FROM_NUMBER>'
--f 'callback_url=<CALLBACK_URL>'
--f 'lang_code=en'
Ensure to 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 | Mandatory |
---|---|---|---|
SID | Account SID (Security Identifier) | HXXXXXXX071US | True |
CONTENT_TYPE | Indicates the format of the content the API will be processing. | application/json | True |
API_KEY | Your API Key generated by Kaleyra.io. | Ac4XXXXX21f | True |
TO_NUMBER | 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. | +1202XXXXXXX | True |
MESSAGE_TYPE | Message format for the message. | text | True |
CONTENT | Content of the message. You must include the link of the web page here. | Hi, Your order has been shipped. | True |
PREVIEW_URL | The URL you want to include in the message | https://www.facebook.com/KaleyraPlatform | True |
CHANNEL_NAME | Channel on which message must be sent. | True | |
FROM_NUMBER | The number registered with WhatsApp business from which the message is to be sent. Ensure that the country code is prefixed to the number. (E164 format). | +1202XXXXXXX | True |
CALLBACK_URL | The URL that Kaleyra.io should send information to when your number receives a response. This URL can be accessed publicly. | https://webhook.site/4e196e4c-cf5d-43c7-aaec-53a476b9a2f9 | False |
- Below is the success response format
{
"id": "bae798f8-4ad5-4e9d-a60f-6ce60a347d89",
"type": "text",
"body": "https://www.facebook.com/KaleyraPlatform",
"createdDateTime": "2020-10-12 10:40:32+00:00",
"totalCount": 1,
"data": [
{
"message_id": "bae798f8-4ad5-4e9d-a60f-6ce60a347d89:0",
"recipient": "91xxxxxxxxxx"
}
],
"error": {}
}
Note:
In case of error, ensure that the above replaceable values are correct. See Standard Error Codes
Updated 3 months ago