Send a message

To send text and media messages to any particular user or group you can use the below API.

info

{api-base-url} can be obtained from the MirrorFly console.

HTTP request#

curl -X POST "https://{api-base-url}/api/v1/chat/sendmessage"
-H "accept: application/json;charset=UTF-8"
-H "Authorization: AuthToken"
-H "Content-Type: application/x-www-form-urlencoded"
-d "chatType=":chatType""
-d "toUser=":toUser""
-d "messageType=":messageType""
-d "message=":message""
-d "replyTo=":replyTo""
-d "file=@":file""
-d "fileEncryption=":fileEncryption""
-d "caption=":caption""
-d "contactName=":contactName""
-d "contactPhone=":contactPhone""
-d "contactKey=":contactKey""
-d "latitude=":latitude""
-d "longitude=":longitude""
-d "locationKey=":locationKey""
-d "topicId=":topicId""

Request Params#

ParamDataTypeRequiredDescription
chatTypeStringYesChat type. Possible values singlechat, groupchat
toUserStringYesUser/Group to send message
messageTypeStringYesType of message to be sent. Possible values are text,audio,video,image,file,location,contact
messageStringNoMessage to be sent. Applicable only if messageType=text. If want to mention any user then use @username syntax
replyToStringNoMessage Id to which you want to reply
fileFileYesFile (Image, Video, Audio, Docs). Applicable only if messageType != text
fileEncryptionBooleanNoEncryption option of the uploaded file. Applicable only if messageType != text, default value is false. If the fileEncryption value is true file would be uploaded as encrypted format.
captionNumberNoCaption of the uploaded file. Applicable only if messageType != text. If want to mention any user then use @username syntax
contactNameStringNoName of the contact to be sent. Applicable only if messageType=contact
contactPhoneStringNoPhone number of the contact to be sent. Applicable only if messageType=contact
contactKeyStringNoKey to encrypt the contact to be sent. Applicable only if messageType=contact
latitudeStringNolocation latitude. Applicable only if messageType=location
longitudeStringNolocation longitude. Applicable only if messageType=location
locationKeyStringNoKey to encrypt the location to be sent. Applicable only if messageType=location
topicIdStringNoTopicId for the topic

Note : Topics can be created from here Create Topic

Responses#

If successful, this action returns below response, in the response body.

{
"status": 200,
"data": {
"messageId": "", // String - Message Id of the message sent
},
"message": "Message sent successfully"
}

Error#

In the case of an error, an error object like below is returned.

When the token passed in Headers is expired

{
"status": 401,
"message": "Token Expired"
}

In the case of a Bad Request, an error message is returned

{
"status": 400,
"message": "Error Message"
}