WhatsApp APIs

Introduction

Onextel’s 365cx.io WhatsApp APIs offer robust, secure, and flexible integrations with your system, allowing seamless incorporation of WhatsApp capabilities into your applications. With the Onextel WhatsApp API, you can efficiently send messages, ensuring reliable communication with your users globally.

To start using the API, you will need to generate a token using the Generate token API and pass the same token as authentication for all the send message APIs. This authentication token is valid for one hour and the validity keeps on increasing if it is being used.

1. Generate token API #

Request URL: https://365cx.io/account/enterprise/login
HTTP Method: POST

ParametersDescription
emailIndicates the email id used for logging in to the 365cx.io platform.
passwordIndicates the password used for logging in to the 365cx.io platform.
longTermTokenIndicates if the authentication token remains valid indefinitely

Sample Curl Request:

curl --location 'https://365cx.io/account/enterprise/login' \

--header 'Content-Type: application/x-www-form-urlencoded' \

--data-urlencode 'email=xx \

--data-urlencode 'password=xx

Success Response:

{

    "response": {

        "uId": 100,

        "token": "VFl6Zz6ZMezrz+12+8CqIHRZdtxxxxxxxxxxxxxxxx"

    },

    "message": {

        "code": 0,

        "message": "Login success"

    },

    "status": true

}

Failure Response:

{

    "message": {

        "code": 1403,

        "message": "Login failed! wrong email id and password combination"

    },

    "status": false

}


Send message APIs #

Mandatory parameters #

Please note that these are mandatory and common parameters for all APIs

ParametersDescriptionMandatory
authentication-tokenToken generated from Generate Token APIYes
fromSpecifies the sender’s phone number.Yes
toSpecifies the recipient’s phone number.Yes
journeyIdRepresents the unique identifier for the journey associated with the message.Yes
templateIdIdentifies the specific template for the message.Yes



Note – To get journeyId, follow these steps:

1. Log in to the 365cx.io platform.
2. Go to Flow Builder -> Streams and click on the stream.
3. Under Configurations, copy journey id from the webhook URL.
Eg: If webhook URL is https://365cx.io/chatbird/message/66c3054f9xxxxxxx61f5501e/send, journey id is 66c3054f9xxxxxxx61f5501e.

Optional parameters #

Please note that these are optional and common parameters for all APIs

ParametersDescriptionMandatory
deptIdRepresents the department of the given account.No
callbackUrlIndicates the URL used for receiving delivery callbacks (Sent, Delivered, Failed, Read)No
metaDataIt contains custom tags (tag1, tag2, tag3) that provide additional context or categorization for each message.

tag1, tag2, tag3: These are customizable fields where you can specify extrainformation for the particular message.

Info! By including these tags while sending a message, you can easily filter messages in the Delivery Report section of the 365cx.io platform based on these tags. This allows for efficient categorization andretrieval of messages according to your specific criteria.
No

1. Send Message API : Text #

Sample Curl Request :

curl --location 'https://365cx.io/chatbird/api/message/send' \

--header 'authentication-token: xx' \

--header 'Content-Type: application/json' \

--data '{

    "from": "xx",

    "to": "xx",

    "journeyId": "xx",

    "message": {

        "template": {

            "templateId": "xx"

        }

    },

    "deptId": "xx",

    "callbackUrl": "xx",

    "metaData": {

        "tag1": "xx",

        "tag2": "xx",

        "tag3": "xx"

    }

}'

2. Send Message API : Text, Variable, Dynamic header, Buttons #


Sample Curl Request

curl --location 'https://365cx.io/chatbird/api/message/send' \

--header 'authentication-token: xx' \

--header 'Content-Type: application/json' \

--data '{

    "from": "xx",

    "to": "xx",

    "journeyId": "xx",

    "message": {

        "template": {

            "templateId": "xx",

            "headerParameterValues": {

                "0": "xx"

            },

            "parameterValues": {

                "0": "xx"

            },

            "buttons": [

                {

                    "type": "xx",

                    "text": "xx",

                    "payload": "xx"

                },

                {

                    "payload": "xx",

                    "text": "xx",

                    "type": "xx"

                },

                {

                    "type": "xx",

                    "text": "xx",

                    "payload": "xx"

                }

            ]

        }

    },

    "deptId": "xx",

    "callbackUrl": "xx",

    "metaData": {

        "tag1": "xx",

        "tag2": "xx",

        "tag3": "xx"

    }

}'
ParametersDescriptionMandatory
headerParameterValuesIdentifies variable values in Header contentYes if header is dynamic
parameterValuesIdentifies variable values in Body contentYes if template have variables
Buttons
typeSpecifies that the button is a “URL” or “Quick_Reply” or “Phone_Number” button.Yes if template have buttons
textSpecifies the button text as passed in the templateNo
payloadPayload associated with the URL or Quick Reply or Phone Number button.Yes if its Dynamic URL

3. Send Message API : Media #

Sample Curl Request :

{

    "from": "xxxxxxxx",

    "to": "xxxxxxxx",

    "journeyId": "xxxxxxxx",

    "message": {

        "template": {

            "templateId": "xxxxxxxx",

            "media": {

                "type": "xx",

                "url": "xxxxxxxx",

                "fileName": "xxxxxxxx"

            }

        }

    },

    "deptId": "xx",

    "callbackUrl": "xx",

    "metaData": {

        "tag1": "xx",

        "tag2": "xx",

        "tag3": "xx"

    }

}'
ParametersDescriptionMandatory
Media
typeIndicates the type of media. It could be
1. IMAGE for image templates
2. DOC for pdf templates
3. VIDEO for video templates
Yes if template have media
urlRepresents the URL of the media file (image, document, or video) to be sentYes if template have media
fileNameSpecifies the name of the media file attached.No

4.Send Message API : Media, Variable, Buttons #

Sample Curl Request :

curl --location 'https://365cx.io/chatbird/api/message/send' \

--header 'authentication-token: xx \

--header 'Content-Type: application/json' \

--data '{

    "from": "xx",

    "to": "xx",

    "journeyId": "xx",

    "message": {

        "template": {

            "templateId": "xx”

            "parameterValues": {

                "0": "xx"

            },

            "media": {

                "type": "xx",

                "url": "xx",

                "fileName": "xx"

            },

            "buttons": [

                {

                    "type": "xx",

                    "text": "xx",

                    "payload": "xx"

                },

                {

                    "type": "xx",

                    "text": "xx",

                    "payload": "xx"

                }

            ]

        }

    },

    "deptId": "xx",

    "callbackUrl": "xx",

    "metaData": {

        "tag1": "xx",

        "tag2": "xx",

        "tag3": "xx"

    }

}
ParametersDescriptionMandatory
parameterValuesIdentifies variable values in Body contentYes if template have variables
Media
typeIndicates the type of media. Enter: could be
1. IMAGE for image templates
2. DOC for pdf templates
3. VIDEO for video templates
Yes if template have media
urlRepresents the URL of the media file (image, document, or video) to be sentYes if template have media
fileNameSpecifies the name of the media file attached.
Buttons
typeSpecifies that the button is a URL or Quick Reply button.Yes if template have buttons
textSpecifies the button text as passed in the templateNo
payloadPayload associated with the URL or Quick Reply button.Yes if its Dynamic URL

Sample Curl Request :

curl --location 'https://365cx.io/chatbird/api/message/send' \

--header 'authentication-token: xx \

--header 'Content-Type: application/json' \

--data '{

    "from": "xx",

    "to": "xx",

    "journeyId": "xx",

    "message": {

        "template": {

            "templateId": "xx",

            "cards": [

                {

                    "media": {

                        "type": "xx",

                        "url": "xx"

                    },

                    "buttons": [

                        {

                            "type": "xx",

                            "payload": "xx"

                        }

                    ]

                },

                {

                    "media": {

                        "type": "xx",

                        "url": "xx"

                    },

                    "buttons": [

                        {

                            "type": "xx",

                            "payload": "xx"

                        }

                    ]

                },

                {

                    "media": {

                        "type": "xx",

                        "url": "xx"

                    },

                    "buttons": [

                        {

                            "type": "xx",

                            "payload": "xx"

                        }

                    ]

                }

            ]

        }

    }

}'
ParametersDescription
parameterValuesIdentifies variable values in Body content
For eg: 0 maps value for variable 1 and 1 maps value for variable 2
callbackUrlIndicates the URL used for receiving callbacks
Media
urlIndicates the URL of the media.
typeSpecifies the type of the media (e.g., IMAGE or VIDEO).
Buttons
typeSpecifies that the button is a URL or Quick Reply button.
payloadPayload associated with the URL or Quick Reply button.

Response Codes #

Success Response:

{

    "message": null,

    "code": 100,

    "status": true,

    "data": {

        "id": "669e5778a8f5d50aad723e7c"

    }

}

Failure Responses:

Wrong Journey ID
{

    "message": "Journey not found",

    "code": 101,

    "status": false,

    "data": null

}

Delivery events #

Sample Payload :

{

    "context": {

        "id": "xxxxxxxx"

    },

    "from": "xxxxxxxx",

    "to": "xxxxxxxx",

    "type": "event",

    "event": {

        "status": "DELIVERED"

    },

    "error": {

        "code": "0",

        "message": "Failed Retry"

    },

    "conversation": {

        "id": "xxxxxxxx",

        "type": "marketing",

        "billable": true

    },

    "timestamp": xxxxxxxx

}
ParametersDescription
context.idThe message ID used to identify which message the event corresponds to.
fromThe sender’s phone number
toThe recipient’s phone number.
event.statusThe delivery status of the message. Possible values are READ,DELIVERED, SENT, FAILED.
errorProvides error details if the message delivery fails.
conversationContains details about the conversation, such as the ID, type (e.g., marketing), and indicating whether the message is billable.
timestampThe time when the event status has been changed.

Delivery reports
#

The Delivery Report in the 365cx.io platform provides a comprehensive overview of all messages sent through various channels. This feature also allows users to track the status of each message, including whether it was sent, delivered, read, or failed. The Delivery Report is essential for analyzing communication effectiveness and identifying any issues in message delivery.


Filtering Messages Using Tags

To enhance message tracking and categorization, the 365cx.io platform allows users to filter

messages in the Delivery Report using metadata tags. By including metadata tags in the “Send

Message” API Request payload, you can filter messages in the Delivery Report to view specific

messages sent based on these tags.

To Filter Messages in Delivery Report,

1. Choose the resource type as API, for messages sent through the API.

2. Specify the channel type (e.g., WhatsApp) and channel name used for the messages.

3. Set the desired time range for your message search.

4. Use the tag fields (Message Tag 1, Message Tag 2 and Message Tag 3) to filter

messages. Enter the specific tags (tag1, tag2, tag3) you used in the API request to narrow

down your results.

Live Agent Satisfaction Rating API

Use this API for enabling the live agent Average Rating feature in Converse Reports on 365cx.io platform. Create a live agent flow with API widget for capturing ratings assigned to the agent from end users. #

Request URL: https://365cx.io/whatsapp/chat/feedback

HTTP Method: POST

Headers: Add a new key referring to the table below.

KeyValue
chatIdIdentifies and works as a unique identifier for chats 
customerPhoneNumberIndicates the end user’s phone number
ratingIndicates the variable which stores the rating provided by the end user



Sample Curl Request:
{

    “chatId”: “${chatId}”,

    “customerPhoneNumber”: “${_sys.phoneNumber}”,

    “rating”: ${rating}

}

Updated on November 5, 2024
Scroll to Top