Short URL in Email API Request for a single contact

In the following API request, the ‘URL shortener' feature is used to shorten a URL. The URL shortener supports specific user tracking to provide information not only about the number of clicks on a link but also about who clicked.

📘

Note:

You can use the ‘URL shortener’ feature only in the 'html_body' parameter.
To know how to create a URL shortener, see: Create URL Shortener.

After you get a short URL, use the short URL in the html_body parameter of your email API request.
Both 'static' and 'dynamic' textly URLs are supported in the email request.

To create an Email API request with a URL shortener,

The following email API request uses a short URL in the html_body parameter.

curl --location 'https://api.kaleyra.io/v1/<SID>/email'\
--header ‘api-key: <API_KEY>'\
--header 'Content-Type: text/plain'\
--data-raw '{
        "from":"[email protected]",
        "from_name": "no reply email",
        "reply-to":"[email protected]",
        "to":"[email protected]",
        "type":"OTP",
         "subject": "a subject",
         "tag": "Tag the InvitationTag!",
          "ref":"1234value",
     "ref1":"value",
     "ref2":"@#$%📧☎️",
      "callback_profile_id": "",
        "dynamic_content": true,
        "template_id":"",
        "text_body": "",
 "html_body": "<b><a ref='\'https://klr.bz/Wxu/{kadvanced}'\'>Static txtly URL in html body</a></b> and dynamic txtly url in html body: {{Name}}",
        "attachments": [
            {
                "content": "aHR0cHM6Ly9yYXcuZ2l0aHViLmNvbS9ub2RlbWFpbGVyL25vZGVtYWlsZXIvbWFzdGVyL0xJQ0VOU0U=",
                "content_type": "application/pdf",
                "filename": "solution1.txt"

            },
            {
                "content": "JVBERi0xLjcKJeLjz9MKNCAwIG9iago8PAovVHlwZSAvWE9iamVj7wWeCmVuZHN0cmVhbQplbmRvYmoKc3RhcnR4cmVmCjg5NjEKJSVFT0YK",
                "content_type": "application/pdf",
                "filename": "download.pdf"
            }
        ],
        "params": {
       "Name": "https://klr.bz/4ju/{kadvanced}"
       
    },
        "metadata": {
            "quantity": "50001929295000192929500019292950001929295000192929500019292950001929295000192929500019292950001929",
            "dMarketValue": "819167.0000",
            "OTP": "PMBND"
     
        }
      
    }'

The Email API response is shown.

{
        "data": [
        {
            "message_id": "3cb96caf-e730-402a-ba3e-4c26249e0405:1",
            "to": "[email protected]",
            "from": "[email protected]",
            "subject": "a subject"
        }
    ],
    "error": {}
    }

The email is received by the recipient in the mailbox with a URL as shown.

Short URL in Email API Request for multiple contacts (Batch Email)

The following email API request uses a short URL to be sent to multiple contacts.

curl --location 'https://api.kaleyra.io/v1/<SID>/email/batch/' 
--header 'api-key: <API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '[{
        "from":"[email protected]",
        "from_name": "no reply email",
        "reply-to":"[email protected]",
        "to":"[email protected]",
        "type":"OTP",
         "subject": "a subject",
         "tag": "Tag the InvitationTag!",
          "ref":"1234value",
     "ref1":"value",
     "ref2":"@#$%📧☎️",
      "callback_profile_id": "",
        "dynamic_content": true,
        "template_id":"",
        "text_body": "",
        "html_body": "<b><a href='\'https://klr.bz/Wxu/{kadvanced}'\''>Static txtly URL in html body</a></b> and dynamic txtly url in html body: {{Name}}",
        "attachments": [
            {
                "content": "JVBERi0xLjcKJeLjz9MKNCAwIG9iago8PAovVHlwZSAvWE9iamVj7wWeCmVuZHN0cmVhbQplbmRvYmoKc3RhcnR4cmVmCjg5NjEKJSVFT0YK",
                "content_type": "application/pdf",
                "filename": "sol.txt"
            },
            {
                "content": "JVBERi0xLjcKJeLjz9MKNCAwIG9iago8PAovVHlwZSAvWE9iamVj7wWeCmVuZHN0cmVhbQplbmRvYmoKc3RhcnR4cmVmCjg5NjEKJSVFT0YK",
                "content_type": "application/pdf",
                "filename": "download.pdf"
            }
        ],
        "params": {
       "Name": "https://klr.bz/4ju/{kadvanced}"
       
    },
        "metadata": {
            "quantity": "500",
            "dMarketValue": "819167.0000",
            "OTP": "PMBND"
     
        }
        },
    {
        "from":"[email protected]",
        "from_name": "no reply email",
        "reply-to":"[email protected]",
        "to":"[email protected]",
        "type":"OTP",
         "subject": "a subject",
         "tag": "Tag the InvitationTag!",
          "ref":"1234value",
     "ref1":"value",
     "ref2":"@#$%📧☎️",
      "callback_profile_id": "",
        "dynamic_content": true,
        "template_id":"",
        "text_body": "",
        "html_body": "<b><a href='\''https://klr.bz/Wxu/{kadvanced}'\''>Static txtly URL in html body</a></b> and dynamic txtly url in html body: {{Name}}",
        "attachments": [
            {
                "content": "https://raw.github.com/nodemailer/nodemailer/master/LICENSE",
                "content_type": "application/pdf",
                "filename": "sol.txt"
            },
            {
                "content": "JVBERi0xLjcKJeLjz9MKNCAwIG9iago8PAovVHlwZSAvWE9iamVj7wWeCmVuZHN0cmVhbQplbmRvYmoKc3RhcnR4cmVmCjg5NjEKJSVFT0YK",
                "content_type": "application/pdf",
                "filename": "download.pdf"
            }
        ],
        "params": {
       "Name": "https://klr.bz/4ju/{kadvanced}"
        },
        "metadata": {
            "quantity": "500",
            "dMarketValue": "819167.0000",
            "OTP": "PMBND"     
        }     
    }]'