Messages
This section contains what all messages related actions can be performed using Application APIs.
Get Messages
Retrieves the list of messages from a conversation.
GET https://api.channelize.io/v2/conversations/{conversation_id}/messages
Path Params
This table lists all possible parameters this API request supports.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
conversation_id | string | yes | - | The unique ID of the conversation. |
Query Params
The following table lists the parameters this API call supports to get filtered results.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
ids | string | no | null | Search the messages with message IDs. |
types | string | no | null | Search the messages with types separated by commas. Allowed values are normal, forward, reply, admin . By default all the messages are retrieved. |
customTypes | string | no | null | Search the messages with custom types separated by commas. |
attachmentTypes | string | no | null | Search the messages with type field of attachments separated by commas. like text, image, audio, video, location, gif, sticker, document etc. |
ownerIds | string | no | null | Search the messages with message's owner IDs separated by commas. |
parentId | string | no | null | Search the reply messages of given parent message. |
showInConversation | boolean | no | null | Search the messages with showInConversation. |
pinned | boolean | no | null | Search for pinned or unpinned messages. |
sort | string | no | updatedAt DESC | Specifies the sorting criteria for the returned results. Allowed values are updatedAt ASC and updatedAt DESC. |
limit | int | no | 50 | Specifies the number of results to return. |
skip | int | no | 0 | Specifies the number of results you want to skip from the beginning. |
Request Example
https://api.channelize.io/v2/conversations/42ab4d40-666a-11e9-bdcd-0bf68210bf49/messages
Response
Status Code: 200
[
{
"id": "5a928b10-4258-11ea-9c07-831a487bf6af",
"conversationId": "1021",
"type": "normal",
"customType": "text",
"createdAt": "2020-01-29T05:29:43.233Z",
"updatedAt": "2020-01-29T05:29:43.233Z",
"body": "hi",
"ownerId": "18646",
"reactionsCount": {
"like": 2
},
"reactions": {
"like": [
"18646",
"318714"
]
},
"attachments": [
{
"type": "image",
"fileUrl": "https://sample-file-url/1576213941566-unnamed.jpg",
"name": "unnamed.jpg",
"mimeType": "image/jpeg",
"extension": "jpg",
"size": 95860,
"thumbnailUrl": "https://sample-file-url/media/1576213941566-unnamed-thumbnail.png",
"id": "5df31dba3a22d30037d62066"
}
],
"owner": {
"id": "18646",
"displayName": "Alen Joe",
"profileImageUrl": "https://sample-file-url/media/b5ceb45b2d6c74e4fc89673a5675c09c.jpg"
},
"mentionedUsers": [
{
"wordCount": 2,
"order": 1,
"userId": "18664",
"user": {
"id": "18664",
"displayName": "Antonis",
"profileImageUrl": "https://sample-file-url/media/1576213941566.png"
}
},
{
"wordCount": 2,
"order": 2,
"userId": "18714",
"user": {
"id": "18714",
"displayName": "Alle",
"profileImageUrl": "https://sample-file-url/media/1576213941566.png"
}
}
],
"replyCount" : 0,
"showInConversation" : true,
"pinned": false
}
]
Get Messages Count
Retrieves the total number of messages in a conversation.
GET https://api.channelize.io/v2/conversations/{conversation_id}/messages/count
Path Params
This table lists all possible parameters this API request supports.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
conversation_id | string | yes | - | The unique ID of the conversation. |
Body Params
This table lists all possible parameters body of this API request supports.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
ids | string | no | null | Search the messages with message IDs. |
types | string | no | null | Search the messages with types separated by commas. Allowed values are normal, forward, reply, admin. By default all the messages are retrived. |
customTypes | string | no | null | Search the messages with custom types separated by commas. |
attachmentTypes | string | no | null | Search the messages with attachment types(Match with type field in attachment) separated by commas. like text, image, audio, video, location, gif, sticker, document etc. |
ownerIds | string | no | null | Search the messages with message's owner IDs separated by commas. |
parentId | string | no | null | Search the reply messages of given parent message. |
showInConversation | boolean | no | null | Search the messages with showInConversation. |
pinned | boolean | no | null | Search for pinned or unpinned messages. |
Request Example
https://api.channelize.io/v2/conversations/42ab4d40-666a-11e9-bdcd-0bf68210bf49/messages/count
Response
Status Code: 200
{
"count": 6
}
Send Messages
Sends a message to a conversation.
POST https://api.channelize.io/v2/messages/send
Channelize supports different types of messages like normal, reply, forward, admin.
normal : A normal message created in the conversation.
forward : A forwarded message from previous message. Moreover Forward messages API call automatically send messages of this type.
reply : A message in a reply thread. Messages created with parent_id are automatically of this type. The replyCount of the parent message will be increased by 1.
admin : A message generated by a system event, like updating the group, add members, remove members etc.
Request Body
Name | Type | Required | Default | Description |
---|---|---|---|---|
id | string | no | auto generated | The unique ID of the message. |
type | string | no | normal | Specify the type of message. Allowed values are normal,reply,forward,admin . |
customType | string | no | null | Specify the custom type of message which is used for grouping of messages. |
body | string | no | null | The content of the message. |
userId | string | yes (if no conversationId) | - | Specify the user ID of message receiver. |
conversationId | string | yes (if no userId) | - | Specify the conversation ID of the conversation where the message is sent to. |
parentId | string | no | null | The ID of the parent message, if the message is a reply. |
showInConversation | boolean | no | true | Specify the showInConversation value of message. |
recipients | array | no | [] | The ID of users who you want to send and display messages in a conversation but not for other users. If recipients field is not passed, by default the message is sent to all members of a conversation. |
mentionedUsers | array | no | [] | Specify users mentioned in the message. Please see below for more details. |
attachments | array | no | [] | A list of attachments (text, image, audio, video, document, location, gif and sticker). |
events | object | no | All events are true | You can send supportable events with their values. |
createdAt | date | no | Auto generated | The creation time of message. |
encrypted | boolean | no | false | Specify if message is encrypted or not. |
metaData | Object | no | null | Additional information of the message that you can save like tags etc. |
Events in a message: Need to set below object pattern in events
key.
{
"sendPushNotification": true, // Determines whether to send push notification, default value is true.
"updateUnreadCount": true, // Determines whether to send update unread message count of a conversation, default value is true.
}
Mention users in a message: Need to set below object pattern in mentionedUsers
key.
[
{
"wordCount": 2, // Mentioned user's name word count
"order": 1, // Mention user's order in the message in reference to another mentioned user.
"userId": "USER_ID" // User ID of mentioned user
},
{
"wordCount": 2,
"order": 2,
"userId": "USER_ID"
}
]
By default Channelize’s pre built UI components support the following attachment types:
- Audio
- Video
- Image
- Text
- Location
- Gif & Sticker
- Admin Message
- Document
NOTE: If you want to build your own UI, the API allows type
field value different apart from supported by our UI components. Moreover you are able to send extra keys as well as different keys in attachments apart from supported by our UI components. If you take type
field value different and different extra keys, our UI components will not be supporting these attachments.
Message Attachment Format For Image/Audio/Video/Document
Name | Type | Required | Default | Description |
---|---|---|---|---|
type | string | yes | null | Specifies the type of attachment like text, image, audio, video, location, gif, sticker, document etc. This value can be different. |
fileUrl | string | yes | null | The url of original file. |
name | string | yes | null | The name of file. |
mimeType | string | yes | null | The mime type of file. |
extension | string | yes | null | The extension of file. |
size | number | yes | null | The size of file in bytes. |
thumbnailUrl | string | yes | null | The url of thumbnail file. |
customType | string | yes | null | The cusom type of attachment. |
{
"id": "5df31dba3a22d30037d62066"
"type": "image", // Type of attachment
"fileUrl": "https://sample-file-url/1576213941566-unnamed.jpg", // The original file url
"name": "unnamed.jpg", // The name of file
"mimeType": "image/jpeg", // The mime type of file.
"extension": "jpg", // The extension of file.
"size": 95860, // The size of file in bytes.
"thumbnailUrl": "https://sample-file-url/media/1576213941566-unnamed-thumbnail.png", //The url of thumbnail file.
}
Message Attachment Format For Location
{
"type": "location",
"latitude" : 37.7873589,
"title" : "Union Square",
"longitude" : -122.408227,
"address" : "320 Geary St, San Francisco 94102, United States"
}
Message Attachment Format For Gif & Sticker
{
"type": "sticker",
"downsampledUrl": "https://media3.giphy.com/media/KenDhChWfWEgliudjI/200_d.gif",
"originalUrl": "https://media3.giphy.com/media/KenDhChWfWEgliudjI/200.gif",
"stillUrl": "https://media3.giphy.com/media/KenDhChWfWEgliudjI/200_s.gif"
}
Message Attachment Format For Admin Message
The below sample attachment displays Alen Joe created group Dynamic Paradigm Coordinator
message in our chat UI component.
{
"type": "text", // The type of attachment
"adminMessageType": "admin_group_create", // This is type of admin message which indicates the unique system event names.
"metaData": {
"subId": "20697", // The subject resource id of the message, here this value is id of Alen Joe user
"subType": "user", // The subject type of the message
"objType": "group", // The object type of the message
"objValues": "Dynamic Paradigm Coordinator" // The object values of the message like here this value is new group name "Dynamic Paradigm Coordinator".
}
}
Response
Status Code : 201
{
"id": "5a928b10-4258-11ea-9c07-831a487bf6af",
"conversationId": "1021",
"type": "normal",
"customType": "text",
"isDeleted": false,
"encrypted": false,
"createdAt": "2020-01-29T05:29:43.233Z",
"updatedAt": "2020-01-29T05:29:43.233Z",
"body": "hi",
"ownerId": "18646",
"reactionsCount": {},
"reactions": {},
"metaData": {},
"attachments": [
{
"type": "image",
"fileUrl": "https://sample-file-url/1576213941566-unnamed.jpg",
"name": "unnamed.jpg",
"mimeType": "image/jpeg",
"extension": "jpg",
"size": 95860,
"thumbnailUrl": "https://sample-file-url/media/1576213941566-unnamed-thumbnail.png",
"id": "5df31dba3a22d30037d62066"
}
],
"owner": {
"id": "18646",
"displayName": "Alen Joe",
"profileImageUrl": "https://sample-file-url/media/b5ceb45b2d6c74e4fc89673a5675c09c.jpg"
},
"mentionedUsers": [
{
"wordCount": 2,
"order": 1,
"userId": "18664",
"user": {
"id": "18664",
"displayName": "Antonis",
"profileImageUrl": "https://sample-file-url/media/1576213941566.png"
}
},
{
"wordCount": 2,
"order": 2,
"userId": "18714",
"user": {
"id": "18714",
"displayName": "Alle",
"profileImageUrl": "https://sample-file-url/media/1576213941566.png"
}
}
],
"replyCount" : 0,
"showInConversation" : true,
"pinned": false
}
Add Reaction
Adds a Reaction to the message. The conversation members can add a reaction to received messages.
POST https://api.channelize.io/v2/messages/{message_id}/add_reaction
Path Params
This table lists all possible parameters this API request supports.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
message_id | string | yes | - | The unique ID of the message. |
Body Params
This table lists all possible parameters body of this API request supports.
Name | Type | Required | Default | Description |
---|---|---|---|---|
type | string | yes | - | Specifies a reaction type. Example 'like', 'dislike' and more. |
Response
Status Code : 204
No Content
Remove Reaction
Removes a reaction from a message. Only the conversation members can remove their reactions.
POST https://api.channelize.io/v2/messages/{message_id}/remove_reaction
Path Params
This table lists all possible parameters this API request supports.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
message_id | string | yes | - | The unique ID of the message. |
Body Params
This table lists all possible parameters body of this API request supports.
Name | Type | Required | Default | Description |
---|---|---|---|---|
type | string | yes | - | Specifies a reaction type. Example 'like', 'dislike' and more. |
Response
Status Code : 204
No Content
List Reactions
Retrieves the list of reactions on a message.
GET https://api.channelize.io/v2/messages/{message_id}/reactions
Path Params
This table lists all possible parameters this API request supports.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
message_id | string | yes | - | The unique ID of the message. |
Query Params
This table lists all parameters this API request supports to get filtered results.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
type | string | yes | - | Specifies a reaction type. Example 'like', 'dislike' and more. |
limit | int | no | 25 | Specifies the number of results to return. |
skip | int | no | 0 | Specifies the number of results you want to skip from the beginning. (Useful in Pagination) |
Request Example
https://api.channelize.io/v2/messages/72e45ec0-7e1a-11ea-adc3-2747866b135c/reactions?&type=like&limit=3&skip=0
Response
Status Code: 200
[
{
"id": "18646",
"displayName": "alex de bougex",
"profileImageUrl": "https://sample-file-url/media/ff29_078f.jpg"
},
{
"id": "18664",
"displayName": "antonis chatzipetrou",
"profileImageUrl": "http://sample-file-url/media/fff4_0edb.jpg"
},
{
"id": "18714",
"displayName": "alle cavallaro",
"profileImageUrl": "http://sample-file-url/mediea/10263_dd51.jpg"
}
]
Pin Message
Pin a message in the conversation. This action can only be performed by conversation admins.
POST https://api.channelize.io/v2/messages/{message_id}/pin
Path Params
This table lists all possible parameters this API request supports.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
message_id | string | yes | - | The unique ID of the message. |
Response
Status Code : 204
No Content
Unpin Message
Unpin a pinned message in the conversation. This action can only be performed by conversation admins.
POST https://api.channelize.io/v2/messages/{message_id}/unpin
Path Params
This table lists all possible parameters this API request supports.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
message_id | string | yes | - | The unique ID of the message. |
Response
Status Code : 204
No Content
Broadcast Messages
Allows 1-to-N broadcast of messages.
POST https://api.channelize.io/v2/messages/broadcast
NOTE: Supports all types of messages supported by Send Messages API call. To know the body of different types of supported messages check Application API > Messages > Send Messages.
Response Body
Status Code : 200
[]
Forward Messages
Forward a message into one or multiple conversations. Consider the forwarded messages as a new instance of the message.
POST https://api.channelize.io/v2/messages/forward
Body Params
This table lists all possible parameters body of this API request supports.
Name | Type | Required | Default | Description |
---|---|---|---|---|
messageIds | array | yes | null | Specifies an array of one or more unique IDs of the messages to forward. |
conversationIds | array | yes (in case of no userIds) | null | Specifies an array of one or more unique IDs of the conversations where the message is sent to. |
userIds | array | yes (in case of no conversationIds) | null | Specifies an array of one or more unique IDs of the users who'll get the message. |
Response
Status Code : 204
No Content
Mark Messages Read
Mark all messages read in a targeted conversation for a user.
PUT https://api.channelize.io/v2/conversations/{conversation_id}/mark_as_read
Path Params
This table lists all possible parameters this API request supports.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
conversation_id | string | yes | - | The unique ID of the conversation in which messages are to be marked Read. |
Body Params
This table lists all possible parameters this API request supports.
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
timestamp | date | no | Current date | Specifies the timestamp to be the reference point of marking as read. If specified, the messages received before the specified time are marked as read. |
Response
Status Code: 204
No Content
Delete Messages (Own Copy)
Deletes a message from a conversation. Deleting a copy of the message is not allowed in public conversations.
POST https://api.channelize.io/v2/messages/delete
Body Params
This table lists all possible parameters body of this API request supports.
Name | Type | Required | Default | Description |
---|---|---|---|---|
messageIds | array | yes | null | Specifies an array of one or more unique IDs of the messages to delete from a conversation. |
Response
Status Code : 204
No Content
Delete Messages for Everyone / Recall sent messages
Recalls messages that you sent from the inbox of the recipients. You can also substitute a replacement message. Recalling a sent message is allowed in both Public and Private Conversations.
POST https://api.channelize.io/v2/messages/delete_for_everyone
Body Params
This table lists all possible parameters body of this API request supports.
Name | Type | Required | Default | Description |
---|---|---|---|---|
messageIds | array | yes | null | Specifies an array of one or more unique IDs of the messages to recall from a conversation. |
Response
Status Code : 200
[]
Get Unread Message Count
Retrieves the total number of unread messages for a user.
GET https://api.channelize.io/v2/messages/unread/count
Response
Status Code : 200
{
"count": 12
}