Send a message
const url = 'https://api.aelyst.ai/v1/contact/example/message';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"channelId":0,"message":{"type":"text","text":"There has been an update in your account..."}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.aelyst.ai/v1/contact/example/message \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "channelId": 0, "message": { "type": "text", "text": "There has been an update in your account..." } }'Sends a message to a specific contact through specific channel. If channelId is not specified, the message will be sent through last interacted channel. Note that for custom payload message type only supported for Telegram, Facebook, Viber and Line, channelId must be specified in order to send a custom payload message. Example for identifier - id:123 | email:abdc@gmail.com | phone:+60121233112
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Identifier of the contact that can either be a phone number, email or contact ID. Examples: id:123 , email:abdc@gmail.com , phone:+60121233112
Request Bodyrequired
Section titled “Request Bodyrequired”object
ID of the channel to send the message on.
null to send message on the last interacted channel (if any).
object
Required if the channel is facebook or instagram and the message is being sent outsde the standard 24 hour messaging window. Reference
object
object
Attachments must be hosted on a publicly accessible platform and provided as a URL in the API request. Direct links to files that are not hosted properly may result in delivery issues, even if the API response is successful. Use reputable hosting services like Amazon S3, Google Cloud Storage, or Dropbox. Ensure the URL is publicly accessible and formatted correctly in the payload.
object
Refer to the channel documentation for the payload.
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
object
Examples
{ "channelId": 0, "message": { "type": "text", "text": "There has been an update in your account..." }}{ "channelId": 0, "message": { "type": "text", "text": "Hello {{$contact.name}}, How can we help you?" }}{ "channelId": 0, "message": { "type": "attachment", "attachment": { "type": "image", "url": "http://example.com/some-file.pdf" } }}{ "channelId": 0, "message": { "type": "custom_payload", "payload": {} }}{ "channelId": 0, "message": { "type": "quick_reply", "title": "Quick reply title", "replies": [ "How are you?" ] }}{ "channelId": 0, "message": { "type": "email", "text": "Example email text", "subject": "Example email subject", "bcc": [ "test@example.com" ], "cc": [ "test@example.com" ], "replyToMessageId": 1262965213, "attachments": [ { "type": "image", "url": "https://cdn.aelyst.ai/johndoe.png", "fileName": "filename.png" } ] }}{ "channelId": 0, "message": { "type": "whatsapp_template", "template": { "name": "ordernumber", "languageCode": "en", "components": [ { "type": "header", "format": "image", "parameters": [ { "type": "image", "image": { "link": "https://png.pngtree.com/templates/20181023/technology-logo-template-png_37582.jpg" } } ] }, { "type": "body", "text": "Hello {{1}}, Thank you for your order. Order Number: {{2}} We'\\''ll let you know when your order is shipped.", "parameters": [ { "type": "text", "text": "$contact.name" }, { "type": "text", "text": "$contact.name" } ] }, { "type": "footer", "text": "AcmeTech Innovations, Inc." } ] } }}{ "channelId": 0, "message": { "type": "whatsapp_template", "template": { "name": "product_offer", "languageCode": "en", "components": [ { "type": "header", "format": "image", "parameters": [ { "type": "image", "image": { "link": "https://example.com/product-image.jpg" } } ] }, { "type": "body", "text": "Hello {{1}}, We have an exciting new product that we think you'll love! Are you interested?", "parameters": [ { "type": "text", "text": "John Doe" } ] }, { "type": "buttons", "buttons": [ { "type": "quick_reply", "text": "Yes, tell me more!" }, { "type": "quick_reply", "text": "Not interested, thanks." } ] }, { "type": "footer", "text": "ABC Products, Inc." } ] } }}{ "channelId": 0, "message": { "type": "whatsapp_template", "template": { "name": "test_location_new_template_testing", "languageCode": "en", "components": [ { "type": "header", "format": "location", "parameters": [ { "type": "location", "location": { "name": "name", "address": "address", "latitude": "22.22", "longitude": "22.22" } } ] }, { "type": "body", "text": "Hi {{1}} \nWe would like to know the location of our next meetup.\nThanks & Regards\n {{2}}", "parameters": [ { "type": "text", "text": "John" }, { "type": "text", "text": "Sarah" } ] } ] } }}{ "channelId": 0, "message": { "type": "whatsapp_template", "template": { "name": "catalog", "languageCode": "en", "components": [ { "type": "body", "text": "body here" }, { "type": "buttons", "buttons": [ { "type": "catalog", "text": "View catalog", "parameters": [ { "type": "action", "action": { "thumbnail_product_image_url": "image_address", "thumbnail_product_retailer_id": "0" } } ] } ] } ] } }}{ "channelId": 0, "message": { "type": "whatsapp_template", "template": { "name": "mpm", "languageCode": "en", "components": [ { "type": "header", "format": "text", "text": "header" }, { "type": "body", "text": "body" }, { "type": "buttons", "buttons": [ { "type": "mpm", "text": "View items", "parameters": [ { "type": "action", "action": { "thumbnail_product_retailer_id": "0", "thumbnail_product_image_url": "image_address", "sections": [ { "product_items": [ { "product_retailer_id": "1", "image_url": "image_address", "name": "Red Shoes (Unisex)", "price": "10.00", "availability": "in stock", "currency": "USD", "description": "A vibrant red crewneck Shoes for all shapes and sizes. Made from 100% cotton." }, { "product_retailer_id": "0", "image_url": "image_address", "name": "Blue Shoes (Unisex)", "price": "10.00", "availability": "in stock", "currency": "USD", "description": "A vibrant blue crewneck Shoes for all shapes and sizes. Made from 100% cotton." } ] } ] } } ] } ] } ] } }}{ "channelId": 123456, "message": { "type": "whatsapp_template", "template": { "name": "send_otp", "languageCode": "en", "components": [ { "text": "*{{1}}* is your verification code.", "type": "body", "parameters": [ { "text": "123456", "type": "text" } ] }, { "type": "buttons", "buttons": [ { "type": "url", "text": "Copy Code", "url": "https://www.whatsapp.com/otp/code/?otp_type=COPY_CODE&code=otp{{1}}", "parameters": [ { "type": "text", "text": "123456" } ] } ] } ] } }}{ "channelId": 0, "message": { "type": "text", "text": "Message text", "messageTag": "ACCOUNT_UPDATE" }}{ "channelId": 0, "message": { "type": "whatsapp_template", "template": { "name": "track_order", "languageCode": "en", "components": [ { "text": "Track your order", "type": "body" }, { "type": "buttons", "buttons": [ { "text": "Visit website", "type": "url", "parameters": [ { "type": "text", "text": "23232" } ], "url": "https://www.test.com/my-en/home/tracking/tracking-global-forwarding.html?submit=1&tracking-id=/{{1}}", "example": [ "23232" ] } ] } ] } }}Responses
Section titled “Responses”object
The id of the message so that you can track it later
Examplegenerated
{ "messageId": 1}object
Example
{ "code": 400, "message": "Validation error."}object
Example
{ "code": 401, "message": "UN_AUTHORIZED"}object
Example
{ "code": 429, "message": "Too Many Requests"}Headers
Section titled “Headers”Example
1Number of seconds until you can retry the request
Example
10Number of request allowed for this end point
Example
5Number of request remaining for this end point
object
Example
{ "code": 449, "message": "Your request cannot be processed at the moment as it is currently in queue. Please try again in a few minutes."}object
Example
{ "code": 500, "message": "Unexpected error occurred"}