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

  1. 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.

  1. 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.

ReplaceWithExampleMandatory
SIDAccount SID (Security Identifier)HXXXXXXX071USTrue
CONTENT_TYPEIndicates the format of the content the API will be processing.application/jsonTrue
API_KEYYour API Key generated by Kaleyra.io.Ac4XXXXX21fTrue
TO_NUMBERA 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.
+1202XXXXXXXTrue
MESSAGE_TYPEMessage format for the message.textTrue
CONTENTContent of the message. You must include the link of the web page here.Hi, Your order has been shipped.True
PREVIEW_URLThe URL you want to include in the messagehttps://www.facebook.com/KaleyraPlatformTrue
CHANNEL_NAMEChannel on which message must be sent.WhatsAppTrue
FROM_NUMBERThe 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).+1202XXXXXXXTrue
CALLBACK_URLThe 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-53a476b9a2f9False
  1. 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