This method allows an app to send a message to a user or a group.

The method endpoint is https://api.flock.co/v1/chat.sendMessage and follows the method calling conventions.

Parameters

NameTypeRequiredDescription
tokenStringYesToken of the user on whose behalf the message is being sent
toStringYesIdentifier of the user to whom the message is to be sent
textStringYesText of the message
flockmlStringNoFlockML alternative to message text. If present this will be shown instead of message text.
notificationStringNoNotification to be shown for the message. If not present, text is used for the notification.
mentionsArrayNo

An array of user identifiers indicating users who have been mentioned in the message.
Only relevant for group messages.

sendAsSendAsNoUse this field if you want to display another name and image as the sender.
attachmentsArrayNo

An array of attachments. Any rich content to be included with the message is sent as an attachments.
Note: Currently, there is a limitation of one attachment per message.

onBehalfOfStringNoNeeded when a bot sends a message to a channel. Set its value to the id of the user on whose behalf the bot is sending a message. See how bots can send a message to a channel.
visibleToArrayNoUse this to display the message to a limited number of members in a channel. Its value should be an array of user ids.

SendAs

The attributes of the sendAs field are as follows:

Name
Type
Required
Description
nameStringYesName of the sender.
profileImageStringYesURL of the sender's profile image.

Response

The uid of the message.

{
    "uid": "d9e054e0-a679-4a7a-9cfa-7299669aa083"
}

Errors

Error CodeHTTP StatusDescriptionAdditional Parameters
UnknownRecipient400The recipient of the message in the to field is unknown 
MissingTextOrAttachment400The message contains neither text nor any attachment