Sync outbound (and inbound) messages and files between the chats using the Messaging API

To sync a message with a specific chat session, please use the standard “message“ method with the sessionid parameter:

{ "method": "message", "params":{ "from": "9003", "to": "234567668", "content": "Hello", "orgid": "17076444409917912922", "sessionid": "1710004869211-d3103a34bd2ce6023a" } }
{ "result": { "messageid": "1710100373597-8b065154afbbddfb96" } }

sessionid refers to the existing chat session, which you receive as a response from the API server once a chat has been created.

A new “sessionid“ will be returned if a message is sent to a session which is already closed.

In addition, you can implicitly create a chat session for other users (if you need to sync messages with the users who don't have a chat session with an external number yet) by sending a message method without the content and sessionid parameters. Specify the external contact number in the from parameter and user’s extension number (for whom a chat session will be created) in to:

{ "method": "message", "params":{ "from": "234567668", "to": "9004", "orgid": "17076444409917912922" } }

Now you can use the provided 'sessionid' in the follow-up API request to sync the message with the user's chat session:

Alternatively, instead of content you can specify the messageid parameter, which is particularly useful for syncing files: