diff --git a/calls.json b/calls.json index 856a66959..e0c6a18a1 100644 --- a/calls.json +++ b/calls.json @@ -7,9 +7,9 @@ }, "servers": [ { - "url": "https://{appId}.call-{region}.cometchat.io/v3", + "url": "https://{appid}.call-{region}.cometchat.io/v3", "variables": { - "appId": { + "appid": { "default": "appId", "description": "(Required) App ID" }, @@ -302,7 +302,7 @@ ], "summary": "Get Call", "description": "Fetches all the details of the call whose sessionId is passed in the URL.", - "operationId": "retrieve-call-details", + "operationId": "retreive-call-details", "parameters": [ { "$ref": "#/components/parameters/onBehalfOf" diff --git a/chat-apis.json b/chat-apis.json index 595147810..21ece5a1c 100644 --- a/chat-apis.json +++ b/chat-apis.json @@ -1869,23 +1869,12 @@ "content": { "application/json": { "schema": { - "discriminator": { - "propertyName": "category", - "mapping": { - "message": "#/components/schemas/messageCategorySchema", - "interactive": "#/components/schemas/interactiveCategorySchema", - "custom": "#/components/schemas/customCategorySchema" - } - }, "oneOf": [ { "$ref": "#/components/schemas/messageCategorySchema" }, { "$ref": "#/components/schemas/customCategorySchema" - }, - { - "$ref": "#/components/schemas/interactiveCategorySchema" } ] }, @@ -2130,7 +2119,7 @@ } }, { - "name": "mentionsWithTagInfo", + "name": "mentionswithTagInfo", "in": "query", "description": "Provides user tags for the mentioned users.", "schema": { @@ -2826,6 +2815,87 @@ ] } }, + "/messages/{id}/interacted": { + "patch": { + "tags": [ + "Messages" + ], + "summary": "Mark message as Interacted", + "description": "Mark message as Interacted on behalf of a user.", + "operationId": "mark-message-as-interacted", + "parameters": [ + { + "$ref": "#/components/parameters/requiredonBehalfOf" + }, + { + "name": "id", + "in": "path", + "description": "Id of the message whose details are to be fetched.", + "required": true, + "schema": { + "type": "string" + }, + "examples": { + "string": { + "summary": "Message ID", + "value": "" + } + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "interactions": { + "description": "A list of element Ids to be marked as interacted!", + "type": "array", + "items": { + "type": "string" + } + } + }, + "type": "object" + } + } + } + }, + "responses": { + "200": { + "description": "Marking Message as Interacted", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "properties": { + "": { + "$ref": "#/components/schemas/deleteSchema" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "success": true, + "message": "The message id 7 has been marked as interacted for the user superhero1." + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + } + }, "/messages/{id}/reactions": { "get": { "tags": [ @@ -3313,294 +3383,199 @@ ] } }, - "/conversations": { - "get": { + "/messages/{id}/pin": { + "post": { "tags": [ - "Conversations" + "Messages" ], - "summary": "List conversations", - "description": "Fetching all the conversations", - "operationId": "list-all-conversations", + "summary": "Pin message", + "description": "Pins a message in its conversation. Without the onBehalfOf header the message is pinned as the app itself (app_system); with it, the message is pinned as that user and their scope permissions apply.", + "operationId": "pin-message", "parameters": [ { "name": "onBehalfOf", "in": "header", - "description": "UID of the user on whose behalf the action is performed.\n\n\nIf onBehalfOf header is not passed,then list Conversations API will be ordered based on `uid`, `updatedAt` and then `conversationWith`\n\nIf onBehalfOf header is passed, then list Conversations API will be ordered based on `updatedAt` and then `conversationWith`.", + "description": "UID of the user to pin the message as. Leave it out to pin the message as the app itself.", "required": false, "schema": { "type": "string" } }, { - "name": "searchKey", - "in": "query", - "description": "Fetches conversations that include the specified searchKey, allowing you to search for conversations based on the name of a User or Group.", - "schema": { - "type": "string" - } - }, - { - "name": "conversationType", - "in": "query", - "description": "Retrieves only the specified conversation type (user and group) while fetching conversations list.", + "name": "id", + "in": "path", + "description": "Id of the message to pin.", + "required": true, "schema": { "type": "string" + }, + "examples": { + "string": { + "summary": "Message ID", + "value": "" + } } - }, - { - "name": "withTags", - "in": "query", - "description": "Includes those groups that have tags.", - "schema": { - "type": "boolean" - } - }, - { - "name": "tags", - "in": "query", - "description": "Fetches only those groups that have these tags.", - "style": "form", - "explode": false, - "schema": { - "type": "array", - "items": { - "type": "string" + } + ], + "responses": { + "200": { + "description": "Pinning a message", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "properties": { + "": { + "$ref": "#/components/schemas/messageSchema" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "id": "2", + "conversationId": "superhero1_user_superhero2", + "sender": "superhero1", + "receiverType": "user", + "receiver": "superhero2", + "category": "message", + "type": "text", + "data": { + "text": "Hi," + }, + "sentAt": 1700210266, + "updatedAt": 1700210266, + "pinnedBy": "app_system", + "pinnedAt": 1700210300 + } + } } } }, - { - "name": "withUserAndGroupTags", - "in": "query", - "description": "Retrieves conversations with tags", - "schema": { - "type": "boolean" + "400": { + "description": "The conversation has reached its pinned message limit", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_PINNED_MESSAGES_LIMIT_EXCEEDED", + "message": "The number of pinned messages for the conversation with id superhero1_user_superhero2 exceeds the allowed limit of 5." + } + } + } } }, - { - "name": "includeBlockedUsers", - "in": "query", - "description": "Set to true to include conversations with blocked users in the response.", - "schema": { - "type": "boolean", - "default": false + "403": { + "description": "Pinned messages are switched off for this app, or the user may not pin", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_PERMISSION_DENIED", + "message": "Permission denied for action pinMessage with role default as per RBAC policy." + } + } + } } - }, + } + }, + "security": [ { - "name": "withBlockedInfo", - "in": "query", - "description": "Set to true to include block status details of users in each conversation.", - "schema": { - "type": "boolean", - "default": false - } - }, + "apiKey": [] + } + ] + }, + "delete": { + "tags": [ + "Messages" + ], + "summary": "Unpin message", + "description": "Unpins a message. Anyone with unpin permission may unpin, not only the user who pinned it. Idempotent.", + "operationId": "unpin-message", + "parameters": [ { - "name": "userTags", - "in": "query", - "description": "Filters conversations by tags associated with the user entity in the conversationWith property.", - "style": "form", - "explode": false, + "name": "onBehalfOf", + "in": "header", + "description": "UID of the user to unpin the message as. Leave it out to unpin as the app itself.", + "required": false, "schema": { - "type": "array", - "items": { - "type": "string" - } + "type": "string" } }, { - "name": "groupTags", - "in": "query", - "description": "Filters conversations by tags associated with the group entity in the conversationWith property.", - "style": "form", - "explode": false, + "name": "id", + "in": "path", + "description": "Id of the message to unpin.", + "required": true, "schema": { - "type": "array", - "items": { - "type": "string" + "type": "string" + }, + "examples": { + "string": { + "summary": "Message ID", + "value": "" } } - }, - { - "name": "unread", - "in": "query", - "description": "Lists only unread conversations by excluding the conversations with conversation.unreadMessageCount=0", - "schema": { - "type": "boolean" - } - }, - { - "name": "perPage", - "in": "query", - "description": "Number of conversations to be fetched in a request. The default value is 100 and the maximum value is 1000.", - "schema": { - "type": "integer", - "default": "100" - } - }, - { - "name": "page", - "in": "query", - "description": "Page number.", - "schema": { - "type": "integer", - "default": "1" - } - }, - { - "name": "hideAgentic", - "in": "query", - "description": "Hides agentic conversations from the list.", - "schema": { - "type": "boolean" - } - }, - { - "name": "onlyAgentic", - "in": "query", - "description": "Shows only agentic conversations in the list.", - "schema": { - "type": "boolean" - } - }, - { - "name": "useCursoredIndex", - "in": "query", - "description": "Enables cursor-based pagination for more efficient conversations listing.", - "schema": { - "type": "integer", - "default": 1, - "enum": [ - 0, - 1 - ] - } - }, - { - "name": "unique", - "in": "query", - "description": "Enables unique conversation mode, returning only unique conversations in the response (super-admin only). Cannot be used together with the onBehalfOf header.", - "schema": { - "type": "integer", - "enum": [ - 0, - 1 - ] - } } ], "responses": { "200": { - "description": "Get Conversations", + "description": "Unpinning a message. pinnedBy and pinnedAt are left out of the response once the message is no longer pinned.", "content": { "application/json": { "schema": { "properties": { "data": { - "type": "array", - "items": {} - }, - "meta": { + "properties": { + "": { + "$ref": "#/components/schemas/messageSchema" + } + }, "type": "object" } }, "type": "object" }, "example": { - "data": [ - { - "conversationId": "group_project-group", - "conversationType": "group", - "unreadMessageCount": "0", - "createdAt": 1630071782, - "updatedAt": 1630481413, - "lastMessage": { - "id": "50", - "conversationId": "group_project-group", - "sender": "superhero4", - "receiverType": "group", - "receiver": "project-group", - "category": "action", - "type": "groupMember", - "data": { - "action": "unbanned", - "entities": { - "by": { - "entity": { - "uid": "superhero4", - "name": "Wolverine", - "role": "default", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png", - "status": "offline", - "createdAt": 1629869270 - }, - "entityType": "user" - }, - "on": { - "entity": { - "uid": "superhero3", - "link": "https://data-us.cometchat.io/assets", - "name": "Captain America", - "role": "default", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", - "status": "offline", - "createdAt": 1629869270, - "updatedAt": 1629964825, - "conversationId": "superhero3_user_superhero4" - }, - "entityType": "user" - }, - "for": { - "entity": { - "guid": "project-group", - "icon": "http://placehold.it/120x120&text=image1", - "name": "Project Group1", - "type": "private", - "owner": "superhero4", - "createdAt": 1630071341, - "updatedAt": 1630305525, - "updatedBy": "superhero4", - "description": "project related discussions between members", - "membersCount": 4, - "conversationId": "group_project-group" - }, - "entityType": "group" - } - } - }, - "sentAt": 1630305562, - "updatedAt": 1630305562, - "receipts": { - "data": [ - [] - ] - } - }, - "conversationWith": { - "guid": "project-group", - "name": "Project Group1", - "description": "project related discussions between members", - "icon": "http://placehold.it/120x120&text=image1", - "type": "private", - "scope": "participant", - "membersCount": 4, - "joinedAt": 1630071782, - "conversationId": "group_project-group", - "hasJoined": true, - "createdAt": 1630071341, - "owner": "superhero4", - "updatedAt": 1630308875, - "updatedBy": "superhero4" - } - } - ], - "meta": { - "pagination": { - "total": 1, - "count": 1, - "per_page": 100, - "current_page": 1, - "total_pages": 1 - } + "data": { + "id": "2", + "conversationId": "superhero1_user_superhero2", + "sender": "superhero1", + "receiverType": "user", + "receiver": "superhero2", + "category": "message", + "type": "text", + "data": { + "text": "Hi," + }, + "sentAt": 1700210266, + "updatedAt": 1700210266 + } + } + } + } + }, + "404": { + "description": "No message with that id", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_MESSAGE_ID_NOT_FOUND", + "message": "Message with the provided info doesn't exist." } } } @@ -3614,135 +3589,89 @@ ] } }, - "/conversations/{conversationId}": { - "get": { + "/messages/{id}/save": { + "post": { "tags": [ - "Conversations" + "Messages" ], - "summary": "Get conversation", - "description": "This API is deprecated please use Get User/Group ConversationAPI", - "operationId": "get-conversation", + "summary": "Save message", + "description": "Saves a message for a user. Saved messages are private to that user, so the onBehalfOf header is required. Idempotent - re-saving keeps the original savedAt.", + "operationId": "save-message", "parameters": [ { - "name": "onBehalfOf", - "in": "header", - "description": "UID of the user on whose behalf the action is performed.", + "$ref": "#/components/parameters/requiredonBehalfOf" + }, + { + "name": "id", + "in": "path", + "description": "Id of the message to save.", "required": true, "schema": { "type": "string" + }, + "examples": { + "string": { + "summary": "Message ID", + "value": "" + } } - }, - { - "$ref": "#/components/parameters/conversationId" } ], "responses": { "200": { - "description": "Get Conversations", + "description": "Saving a message. savedAt appears only for the user the message was saved for.", "content": { "application/json": { "schema": { "properties": { "data": { + "properties": { + "": { + "$ref": "#/components/schemas/messageSchema" + } + }, "type": "object" } }, "type": "object" }, "example": { - "data": [ - { - "conversationId": "group_project-group", - "conversationType": "group", - "unreadMessageCount": "0", - "createdAt": 1630071782, - "updatedAt": 1630481413, - "lastMessage": { - "id": "50", - "conversationId": "group_project-group", - "sender": "superhero4", - "receiverType": "group", - "receiver": "project-group", - "category": "action", - "type": "groupMember", - "data": { - "action": "unbanned", - "entities": { - "by": { - "entity": { - "uid": "superhero4", - "name": "Wolverine", - "role": "default", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png", - "status": "offline", - "createdAt": 1629869270 - }, - "entityType": "user" - }, - "on": { - "entity": { - "uid": "superhero3", - "link": "https://data-us.cometchat.io/assets", - "name": "Captain America", - "role": "default", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", - "status": "offline", - "createdAt": 1629869270, - "updatedAt": 1629964825, - "conversationId": "superhero3_user_superhero4" - }, - "entityType": "user" - }, - "for": { - "entity": { - "guid": "project-group", - "icon": "http://placehold.it/120x120&text=image1", - "name": "Project Group1", - "type": "private", - "owner": "superhero4", - "createdAt": 1630071341, - "updatedAt": 1630305525, - "updatedBy": "superhero4", - "description": "project related discussions between members", - "membersCount": 4, - "conversationId": "group_project-group" - }, - "entityType": "group" - } - } - }, - "sentAt": 1630305562, - "updatedAt": 1630305562, - "receipts": { - "data": [ - [] - ] - } - }, - "conversationWith": { - "guid": "project-group", - "name": "Project Group1", - "description": "project related discussions between members", - "icon": "http://placehold.it/120x120&text=image1", - "type": "private", - "scope": "participant", - "membersCount": 4, - "joinedAt": 1630071782, - "conversationId": "group_project-group", - "hasJoined": true, - "createdAt": 1630071341, - "owner": "superhero4", - "updatedAt": 1630308875, - "updatedBy": "superhero4" - } - } - ] + "data": { + "id": "2", + "conversationId": "superhero1_user_superhero2", + "sender": "superhero1", + "receiverType": "user", + "receiver": "superhero2", + "category": "message", + "type": "text", + "data": { + "text": "Hi," + }, + "sentAt": 1700210266, + "updatedAt": 1700210266, + "savedAt": 1700210300 + } + } + } + } + }, + "400": { + "description": "The user has reached their saved message limit", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_SAVED_MESSAGES_LIMIT_EXCEEDED", + "message": "The number of saved messages for the user with uid superhero1 exceeds the allowed limit of 100." + } } } } } }, - "deprecated": true, "security": [ { "apiKey": [] @@ -3751,33 +3680,44 @@ }, "delete": { "tags": [ - "Conversations" + "Messages" ], - "summary": "Delete Conversation", - "description": "This API is deprecated please use Reset User/GroupConversation API", - "operationId": "deletes-conversation", + "summary": "Unsave message", + "description": "Removes a message from a user's saved list. The onBehalfOf header is required. Idempotent.", + "operationId": "unsave-message", "parameters": [ { - "name": "onBehalfOf", - "in": "header", - "description": "UID of the user on whose behalf the action is performed.", + "$ref": "#/components/parameters/requiredonBehalfOf" + }, + { + "name": "id", + "in": "path", + "description": "Id of the message to remove from the user's saved list.", "required": true, "schema": { "type": "string" + }, + "examples": { + "string": { + "summary": "Message ID", + "value": "" + } } - }, - { - "$ref": "#/components/parameters/conversationId" } ], "responses": { "200": { - "description": "Deleted Conversations", + "description": "Unsaving a message. savedAt is left out of the response once the message is no longer saved.", "content": { "application/json": { "schema": { "properties": { "data": { + "properties": { + "": { + "$ref": "#/components/schemas/messageSchema" + } + }, "type": "object" } }, @@ -3785,15 +3725,24 @@ }, "example": { "data": { - "success": true, - "message": "The conversation group_project-group has been deleted successfully for all the users." + "id": "2", + "conversationId": "superhero1_user_superhero2", + "sender": "superhero1", + "receiverType": "user", + "receiver": "superhero2", + "category": "message", + "type": "text", + "data": { + "text": "Hi," + }, + "sentAt": 1700210266, + "updatedAt": 1700210266 } } } } } }, - "deprecated": true, "security": [ { "apiKey": [] @@ -3801,182 +3750,193 @@ ] } }, - "/users/{uid}/conversation": { + "/conversations": { "get": { "tags": [ "Conversations" ], - "summary": "Get User Conversation", - "description": "Getting user conversation", - "operationId": "get-user-conversations", + "summary": "List conversations", + "description": "Fetching all the conversations", + "operationId": "list-all-conversations", "parameters": [ { "name": "onBehalfOf", "in": "header", - "description": "UID of the user on whose behalf the action is performed.", - "required": true, + "description": "UID of the user on whose behalf the action is performed.\n\n\nIf onBehalfOf header is not passed,then list Conversations API will be ordered based on `uid`, `updatedAt` and then `conversationWith`\n\nIf onBehalfOf header is passed, then list Conversations API will be ordered based on `updatedAt` and then `conversationWith`.", + "required": false, "schema": { "type": "string" } }, { - "$ref": "#/components/parameters/uid--conversation" - } - ], - "responses": { - "200": { - "description": "Get user Conversations", - "content": { - "application/json": { - "schema": { - "properties": { - "data": { - "type": "object" - } - }, - "type": "object" - }, - "example": { - "data": [ - { - "conversationId": "group_project-group", - "conversationType": "group", - "unreadMessageCount": "0", - "createdAt": 1630071782, - "updatedAt": 1630481413, - "lastMessage": { - "id": "50", - "conversationId": "group_project-group", - "sender": "superhero4", - "receiverType": "group", - "receiver": "project-group", - "category": "action", - "type": "groupMember", - "data": { - "action": "unbanned", - "entities": { - "by": { - "entity": { - "uid": "superhero4", - "name": "Wolverine", - "role": "default", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png", - "status": "offline", - "createdAt": 1629869270 - }, - "entityType": "user" - }, - "on": { - "entity": { - "uid": "superhero3", - "link": "https://data-us.cometchat.io/assets", - "name": "Captain America", - "role": "default", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", - "status": "offline", - "createdAt": 1629869270, - "updatedAt": 1629964825, - "conversationId": "superhero3_user_superhero4" - }, - "entityType": "user" - }, - "for": { - "entity": { - "guid": "project-group", - "icon": "http://placehold.it/120x120&text=image1", - "name": "Project Group1", - "type": "private", - "owner": "superhero4", - "createdAt": 1630071341, - "updatedAt": 1630305525, - "updatedBy": "superhero4", - "description": "project related discussions between members", - "membersCount": 4, - "conversationId": "group_project-group" - }, - "entityType": "group" - } - } - }, - "sentAt": 1630305562, - "updatedAt": 1630305562 - }, - "conversationWith": { - "guid": "project-group", - "name": "Project Group1", - "description": "project related discussions between members", - "icon": "http://placehold.it/120x120&text=image1", - "type": "private", - "scope": "participant", - "membersCount": 4, - "joinedAt": 1630071782, - "conversationId": "group_project-group", - "hasJoined": true, - "createdAt": 1630071341, - "owner": "superhero4", - "updatedAt": 1630308875, - "updatedBy": "superhero4" - } - } - ] - } - } + "name": "searchKey", + "in": "query", + "description": "Fetches conversations that include the specified searchKey, allowing you to search for conversations based on the name of a User or Group.", + "schema": { + "type": "string" } - } - }, - "security": [ - { - "apiKey": [] - } - ] - }, - "put": { - "tags": [ - "Conversations" - ], - "summary": "Update User Conversation", - "description": "Updating User Conversation", - "operationId": "updates-user-conversation", - "parameters": [ - { - "$ref": "#/components/parameters/uid--conversation" }, { - "name": "onBehalfOf", - "in": "header", - "description": "UID of the user on whose behalf the action is performed.", - "required": true, + "name": "conversationType", + "in": "query", + "description": "Retrieves only the specified conversation type (user and group) while fetching conversations list.", "schema": { "type": "string" } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "tags": { - "description": "List of tags to identify specific conversation.", - "type": "array", - "items": { - "type": "string" - } - } - }, - "type": "object" + }, + { + "name": "withTags", + "in": "query", + "description": "Includes those groups that have tags.", + "schema": { + "type": "boolean" + } + }, + { + "name": "tags", + "in": "query", + "description": "Fetches only those groups that have these tags.", + "style": "form", + "explode": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "withUserAndGroupTags", + "in": "query", + "description": "Retrieves conversations with tags", + "schema": { + "type": "boolean" + } + }, + { + "name": "includeBlockedUsers", + "in": "query", + "description": "Set to true to include conversations with blocked users in the response.", + "schema": { + "type": "boolean", + "default": false + } + }, + { + "name": "withBlockedInfo", + "in": "query", + "description": "Set to true to include block status details of users in each conversation.", + "schema": { + "type": "boolean", + "default": false + } + }, + { + "name": "userTags", + "in": "query", + "description": "Filters conversations by tags associated with the user entity in the conversationWith property.", + "style": "form", + "explode": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "groupTags", + "in": "query", + "description": "Filters conversations by tags associated with the group entity in the conversationWith property.", + "style": "form", + "explode": false, + "schema": { + "type": "array", + "items": { + "type": "string" } } + }, + { + "name": "unread", + "in": "query", + "description": "Lists only unread conversations by excluding the conversations with conversation.unreadMessageCount=0", + "schema": { + "type": "boolean" + } + }, + { + "name": "perPage", + "in": "query", + "description": "Number of conversations to be fetched in a request. The default value is 100 and the maximum value is 1000.", + "schema": { + "type": "integer", + "default": "100" + } + }, + { + "name": "page", + "in": "query", + "description": "Page number.", + "schema": { + "type": "integer", + "default": "1" + } + }, + { + "name": "hideAgentic", + "in": "query", + "description": "Hides agentic conversations from the list.", + "schema": { + "type": "boolean" + } + }, + { + "name": "onlyAgentic", + "in": "query", + "description": "Shows only agentic conversations in the list.", + "schema": { + "type": "boolean" + } + }, + { + "name": "useCursoredIndex", + "in": "query", + "description": "Enables cursor-based pagination for more efficient conversations listing.", + "schema": { + "type": "integer", + "default": 1, + "enum": [ + 0, + 1 + ] + } + }, + { + "name": "unique", + "in": "query", + "description": "Enables Conversation unique mode (super-admin only). Cannot be used together with the onBehalfOf header.", + "schema": { + "type": "integer", + "enum": [ + 0, + 1 + ] + } } - }, + ], "responses": { "200": { - "description": "Updated user Conversations", + "description": "Get Conversations", "content": { "application/json": { "schema": { "properties": { "data": { + "type": "array", + "items": {} + }, + "meta": { "type": "object" } }, @@ -4069,7 +4029,16 @@ "updatedBy": "superhero4" } } - ] + ], + "meta": { + "pagination": { + "total": 1, + "count": 1, + "per_page": 100, + "current_page": 1, + "total_pages": 1 + } + } } } } @@ -4080,70 +4049,47 @@ "apiKey": [] } ] - }, - "delete": { + } + }, + "/conversations/pinned": { + "get": { "tags": [ "Conversations" ], - "summary": "Reset User Conversation", - "description": "Resetting User Conversation", - "operationId": "resets-user-conversation", - "parameters": [ - { - "name": "onBehalfOf", - "in": "header", - "description": "UID of the user on whose behalf the action is performed.", - "required": true, - "schema": { - "type": "string" - } - }, - { - "$ref": "#/components/parameters/uid--conversation" - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "conversationWith": { - "description": "UID of a user", - "type": "string" - }, - "deleteMessagesPermanently": { - "description": "Permanently deletes messages in that particular conversation", - "type": "boolean" - }, - "preserveOrder": { - "description": "When set to true, maintains the conversation's position in the user's conversation list after reset.", - "type": "boolean", - "default": false - } - }, - "type": "object" - } - } - } - }, + "summary": "List global pinned conversations", + "description": "Lists the global pinned conversations - the conversations pinned at the top for every end user - in display order.", + "operationId": "list-app-pinned-conversations", "responses": { "200": { - "description": "Resetted user Conversations", + "description": "Listing the global pinned conversations, in display order", "content": { "application/json": { "schema": { "properties": { "data": { - "type": "object" + "type": "array", + "items": { + "$ref": "#/components/schemas/conversationSchema" + } } }, "type": "object" }, "example": { - "data": { - "success": true, - "message": "The conversation superhero1_user_superhero2 has been deleted successfully for UID superhero1." - } + "data": [ + { + "conversationId": "supergroup", + "conversationType": "group", + "pinnedBy": "app_system", + "pinnedAt": 1700210300 + }, + { + "conversationId": "superhero1_user_superhero2", + "conversationType": "user", + "pinnedBy": "app_system", + "pinnedAt": 1700210299 + } + ] } } } @@ -4154,38 +4100,47 @@ "apiKey": [] } ] - } - }, - "/users/{uid}/conversation/delivered": { - "post": { + }, + "put": { "tags": [ "Conversations" ], - "summary": "Mark User Conversation As Delivered", - "description": "This API will mark the user conversation as delivered.", - "operationId": "mark-conversation-as-delivered", - "parameters": [ - { - "name": "onBehalfOf", - "in": "header", - "description": "UID of the receiver of the message", - "required": true, - "schema": { - "type": "string" - } - }, - { - "$ref": "#/components/parameters/uid--conversation" - } - ], + "summary": "Replace global pinned conversations", + "description": "Replaces the whole global pinned conversation list - the conversations pinned at the top for every end user. The array is the desired final state and order - entries that are absent get unpinned, new entries get pinned, and array order becomes display order. Send an empty array to clear the list.", + "operationId": "replace-app-pinned-conversations", "requestBody": { + "required": true, "content": { "application/json": { "schema": { + "required": [ + "pinnedConversations" + ], "properties": { - "messageId": { - "description": "The id of the message upto which the conversation needs to be marked as delivered.", - "type": "integer" + "pinnedConversations": { + "description": "The conversations to pin at the top for every end user, in the order they should appear. Each entry names either a user (uid) or a group (guid). Entries left out of the array are unpinned. Send an empty array to clear the list. Repeated entries are kept once, at their first position.", + "type": "array", + "items": { + "properties": { + "uid": { + "description": "UID of the user, for a one-to-one conversation.", + "type": "string" + }, + "guid": { + "description": "GUID of the group, for a group conversation.", + "type": "string" + } + }, + "type": "object" + }, + "example": [ + { + "guid": "supergroup" + }, + { + "uid": "superhero2" + } + ] } }, "type": "object" @@ -4195,21 +4150,50 @@ }, "responses": { "200": { - "description": "Marking Conversation as delivered", + "description": "The new global pinned conversation list, in display order", "content": { "application/json": { "schema": { "properties": { "data": { - "type": "object" + "type": "array", + "items": { + "$ref": "#/components/schemas/conversationSchema" + } } }, "type": "object" }, "example": { - "data": { - "success": true, - "Message": "All the messages from the user {{UID}} are marked as delivered for the user {{onBehalfOf}}." + "data": [ + { + "conversationId": "supergroup", + "conversationType": "group", + "pinnedBy": "app_system", + "pinnedAt": 1700210300 + }, + { + "conversationId": "superhero1_user_superhero2", + "conversationType": "user", + "pinnedBy": "app_system", + "pinnedAt": 1700210299 + } + ] + } + } + } + }, + "400": { + "description": "The global list exceeds its cap, or an entry names neither a uid nor a guid", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_SYSTEM_PINNED_CONVERSATIONS_LIMIT_EXCEEDED", + "message": "The number of pinned conversations exceeds the allowed limit of 5." } } } @@ -4223,46 +4207,31 @@ ] } }, - "/users/{uid}/conversation/read": { - "post": { + "/conversations/{conversationId}": { + "get": { "tags": [ "Conversations" ], - "summary": "Mark User Conversation As Read", - "description": "This API will mark the user conversation as read.", - "operationId": "mark-conversation-as-read", + "summary": "Get conversation", + "description": "This API is deprecated please use Get User/Group ConversationAPI", + "operationId": "get-conversation", "parameters": [ { "name": "onBehalfOf", "in": "header", - "description": "UID of the receiver of the message", + "description": "UID of the user on whose behalf the action is performed.", "required": true, "schema": { "type": "string" } }, { - "$ref": "#/components/parameters/uid--conversation" + "$ref": "#/components/parameters/conversationId" } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "messageId": { - "description": "The id of the message upto which the conversation needs to be marked as read.", - "type": "integer" - } - }, - "type": "object" - } - } - } - }, "responses": { "200": { - "description": "Marking Conversation as read", + "description": "Get Conversations", "content": { "application/json": { "schema": { @@ -4274,15 +4243,99 @@ "type": "object" }, "example": { - "data": { - "success": true, - "Message": "All the messages from the user {{UID}} are marked as read for the user {{onBehalfOf}}." - } + "data": [ + { + "conversationId": "group_project-group", + "conversationType": "group", + "unreadMessageCount": "0", + "createdAt": 1630071782, + "updatedAt": 1630481413, + "lastMessage": { + "id": "50", + "conversationId": "group_project-group", + "sender": "superhero4", + "receiverType": "group", + "receiver": "project-group", + "category": "action", + "type": "groupMember", + "data": { + "action": "unbanned", + "entities": { + "by": { + "entity": { + "uid": "superhero4", + "name": "Wolverine", + "role": "default", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png", + "status": "offline", + "createdAt": 1629869270 + }, + "entityType": "user" + }, + "on": { + "entity": { + "uid": "superhero3", + "link": "https://data-us.cometchat.io/assets", + "name": "Captain America", + "role": "default", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", + "status": "offline", + "createdAt": 1629869270, + "updatedAt": 1629964825, + "conversationId": "superhero3_user_superhero4" + }, + "entityType": "user" + }, + "for": { + "entity": { + "guid": "project-group", + "icon": "http://placehold.it/120x120&text=image1", + "name": "Project Group1", + "type": "private", + "owner": "superhero4", + "createdAt": 1630071341, + "updatedAt": 1630305525, + "updatedBy": "superhero4", + "description": "project related discussions between members", + "membersCount": 4, + "conversationId": "group_project-group" + }, + "entityType": "group" + } + } + }, + "sentAt": 1630305562, + "updatedAt": 1630305562, + "receipts": { + "data": [ + [] + ] + } + }, + "conversationWith": { + "guid": "project-group", + "name": "Project Group1", + "description": "project related discussions between members", + "icon": "http://placehold.it/120x120&text=image1", + "type": "private", + "scope": "participant", + "membersCount": 4, + "joinedAt": 1630071782, + "conversationId": "group_project-group", + "hasJoined": true, + "createdAt": 1630071341, + "owner": "superhero4", + "updatedAt": 1630308875, + "updatedBy": "superhero4" + } + } + ] } } } } }, + "deprecated": true, "security": [ { "apiKey": [] @@ -4293,41 +4346,26 @@ "tags": [ "Conversations" ], - "summary": "Mark Conversation Messages As Unread", - "description": "Allows you to mark messages within a conversation as unread", - "operationId": "mark-conversation-as-unread", + "summary": "Delete Conversation", + "description": "This API is deprecated please use Reset User/GroupConversation API", + "operationId": "deletes-conversation", "parameters": [ { "name": "onBehalfOf", "in": "header", - "description": "UID of the receiver of the message", + "description": "UID of the user on whose behalf the action is performed.", "required": true, "schema": { "type": "string" } }, { - "$ref": "#/components/parameters/uid--conversation" + "$ref": "#/components/parameters/conversationId" } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "messageId": { - "description": "The id of the message upto which the conversation needs to be marked as unread.", - "type": "integer" - } - }, - "type": "object" - } - } - } - }, "responses": { "200": { - "description": "Marking Conversation as unread", + "description": "Deleted Conversations", "content": { "application/json": { "schema": { @@ -4341,13 +4379,14 @@ "example": { "data": { "success": true, - "message": "The messages after the message id 340 from the user demo1 are marked as unread for the user demo3." + "message": "The conversation group_project-group has been deleted successfully for all the users." } } } } } }, + "deprecated": true, "security": [ { "apiKey": [] @@ -4355,14 +4394,14 @@ ] } }, - "/groups/{guid}/conversation": { + "/users/{uid}/conversation": { "get": { "tags": [ "Conversations" ], - "summary": "Get Group Conversation", - "description": "Getting group conversation", - "operationId": "get-group-conversations", + "summary": "Get User Conversation", + "description": "Getting user conversation", + "operationId": "get-user-conversations", "parameters": [ { "name": "onBehalfOf", @@ -4374,7 +4413,7 @@ } }, { - "$ref": "#/components/parameters/guid--conversation" + "$ref": "#/components/parameters/uid--conversation" } ], "responses": { @@ -4488,12 +4527,12 @@ "tags": [ "Conversations" ], - "summary": "Update Group Conversation", - "description": "Updating Group Conversation", - "operationId": "updates-group-conversation", + "summary": "Update User Conversation", + "description": "Updating User Conversation", + "operationId": "updates-user-conversation", "parameters": [ { - "$ref": "#/components/parameters/guid--conversation" + "$ref": "#/components/parameters/uid--conversation" }, { "name": "onBehalfOf", @@ -4639,9 +4678,9 @@ "tags": [ "Conversations" ], - "summary": "Reset Group Conversation", - "description": "Resetting Group Conversation", - "operationId": "resets-group-conversation", + "summary": "Reset User Conversation", + "description": "Resetting User Conversation", + "operationId": "resets-user-conversation", "parameters": [ { "name": "onBehalfOf", @@ -4653,7 +4692,7 @@ } }, { - "$ref": "#/components/parameters/guid--conversation" + "$ref": "#/components/parameters/uid--conversation" } ], "requestBody": { @@ -4661,6 +4700,14 @@ "application/json": { "schema": { "properties": { + "conversationWith": { + "description": "UID of a user", + "type": "string" + }, + "deleteMessagesPermanently": { + "description": "Permanently deletes messages in that particular conversation", + "type": "boolean" + }, "preserveOrder": { "description": "When set to true, maintains the conversation's position in the user's conversation list after reset.", "type": "boolean", @@ -4702,46 +4749,25 @@ ] } }, - "/groups/{guid}/conversation/delivered": { + "/users/{uid}/conversation/pin": { "post": { "tags": [ "Conversations" ], - "summary": "Mark Group Conversation As Delivered", - "description": "This API will mark the group conversation as delivered.", - "operationId": "mark-group-conversation-as-delivered", + "summary": "Pin User Conversation", + "description": "Pins a one-to-one conversation for a user, so it appears at the top of their conversation list. Pins are per user, so the onBehalfOf header is required. Idempotent - re-pinning keeps the original pinnedAt.", + "operationId": "pin-user-conversation", "parameters": [ { - "name": "onBehalfOf", - "in": "header", - "description": "UID of the receiver of the message", - "required": true, - "schema": { - "type": "string" - } + "$ref": "#/components/parameters/requiredonBehalfOf" }, { - "$ref": "#/components/parameters/guid--conversation" + "$ref": "#/components/parameters/uid--conversation" } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "messageId": { - "description": "The id of the message upto which the conversation needs to be marked as delivered.", - "type": "integer" - } - }, - "type": "object" - } - } - } - }, "responses": { "200": { - "description": "Marking Conversation as delivered", + "description": "Pinning a one-to-one conversation", "content": { "application/json": { "schema": { @@ -4754,8 +4780,42 @@ }, "example": { "data": { - "success": true, - "message": "All the messages in group {{GUID}} are marked as delivered for the user {{onBehalfOf}}." + "conversationId": "superhero1_user_superhero2", + "conversationType": "user", + "pinnedBy": "superhero1", + "pinnedAt": 1700210300 + } + } + } + } + }, + "400": { + "description": "The user has reached their pinned conversation limit", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_PINNED_CONVERSATIONS_LIMIT_EXCEEDED", + "message": "The number of pinned conversations for the user with uid superhero1 exceeds the allowed limit of 5." + } + } + } + } + }, + "403": { + "description": "The conversation carries a global pin, so a user cannot pin it themselves", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_SYSTEM_PINNED_CONVERSATION", + "message": "The conversation is pinned for all users by the app and can not be pinned by a user." } } } @@ -4767,48 +4827,25 @@ "apiKey": [] } ] - } - }, - "/groups/{guid}/conversation/read": { - "post": { + }, + "delete": { "tags": [ "Conversations" ], - "summary": "Mark Group Conversation As Read", - "description": "This API will mark the group conversation as read.", - "operationId": "mark-group-conversation-as-read", + "summary": "Unpin User Conversation", + "description": "Removes a user's own pin from a one-to-one conversation. A conversation carrying a global pin cannot be unpinned this way. Idempotent.", + "operationId": "unpin-user-conversation", "parameters": [ { - "name": "onBehalfOf", - "in": "header", - "description": "UID of the receiver of the message", - "required": true, - "schema": { - "type": "string" - } + "$ref": "#/components/parameters/requiredonBehalfOf" }, { - "$ref": "#/components/parameters/guid--conversation" + "$ref": "#/components/parameters/uid--conversation" } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "messageId": { - "description": "The id of the message upto which the conversation needs to be marked as read.", - "type": "integer" - } - }, - "type": "object" - } - } - } - }, "responses": { "200": { - "description": "Marking Conversation as read", + "description": "Unpinning a one-to-one conversation. pinnedBy and pinnedAt are left out of the response once the conversation is no longer pinned.", "content": { "application/json": { "schema": { @@ -4821,8 +4858,24 @@ }, "example": { "data": { - "success": true, - "message": "All the messages in group {{GUID}} are marked as read for the user {{onBehalfOf}}." + "conversationId": "superhero1_user_superhero2", + "conversationType": "user" + } + } + } + } + }, + "403": { + "description": "The conversation carries a global pin, so a user cannot unpin it themselves", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_SYSTEM_PINNED_CONVERSATION", + "message": "The conversation is pinned for all users by the app and can not be unpinned by a user." } } } @@ -4834,26 +4887,28 @@ "apiKey": [] } ] - }, - "delete": { + } + }, + "/users/{uid}/conversation/delivered": { + "post": { "tags": [ "Conversations" ], - "summary": "Mark Group Conversation As Unread", - "description": "This API will mark the group conversation as unread.", - "operationId": "mark-group-conversation-as-unread", + "summary": "Mark User Conversation As Delivered", + "description": "This API will mark the user conversation as delivered.", + "operationId": "mark-conversation-as-delivered", "parameters": [ { "name": "onBehalfOf", "in": "header", - "description": "UID of the group member marking the messages as unread.", + "description": "UID of the receiver of the message", "required": true, "schema": { "type": "string" } }, { - "$ref": "#/components/parameters/guid--conversation" + "$ref": "#/components/parameters/uid--conversation" } ], "requestBody": { @@ -4862,7 +4917,7 @@ "schema": { "properties": { "messageId": { - "description": "The id of the message upto which the conversation needs to be marked as unread.", + "description": "The id of the message upto which the conversation needs to be marked as delivered.", "type": "integer" } }, @@ -4873,7 +4928,7 @@ }, "responses": { "200": { - "description": "Marking Conversation as unread", + "description": "Marking Conversation as delivered", "content": { "application/json": { "schema": { @@ -4887,7 +4942,7 @@ "example": { "data": { "success": true, - "message": "The messages after the message id 340 from the user demo1 are marked as unread for the user demo3." + "Message": "All the messages from the user {{UID}} are marked as delivered for the user {{onBehalfOf}}." } } } @@ -4901,29 +4956,26 @@ ] } }, - "/users/{uid}/auth_tokens": { + "/users/{uid}/conversation/read": { "post": { "tags": [ - "Auth Tokens" + "Conversations" ], - "summary": "Create", - "description": "Creates auth token for a user with the specified UID.", - "operationId": "create-authtoken", + "summary": "Mark User Conversation As Read", + "description": "This API will mark the user conversation as read.", + "operationId": "mark-conversation-as-read", "parameters": [ { - "name": "uid", - "in": "path", - "description": "An UID of a user.", + "name": "onBehalfOf", + "in": "header", + "description": "UID of the receiver of the message", "required": true, "schema": { "type": "string" - }, - "examples": { - "string": { - "summary": "UID", - "value": "" - } } + }, + { + "$ref": "#/components/parameters/uid--conversation" } ], "requestBody": { @@ -4931,9 +4983,9 @@ "application/json": { "schema": { "properties": { - "force": { - "description": "Generates new auth token forcefully.", - "type": "boolean" + "messageId": { + "description": "The id of the message upto which the conversation needs to be marked as read.", + "type": "integer" } }, "type": "object" @@ -4943,17 +4995,21 @@ }, "responses": { "200": { - "description": "Created auth token", + "description": "Marking Conversation as read", "content": { "application/json": { "schema": { + "properties": { + "data": { + "type": "object" + } + }, "type": "object" }, "example": { "data": { - "uid": "superhero1", - "authToken": "superhero1_1630306819c3027ce530b2367f3c97b4106f0cb8", - "createdAt": 1630306819 + "success": true, + "Message": "All the messages from the user {{UID}} are marked as read for the user {{onBehalfOf}}." } } } @@ -4966,81 +5022,59 @@ } ] }, - "get": { + "delete": { "tags": [ - "Auth Tokens" + "Conversations" ], - "summary": "List", - "description": "Lists auth tokens for a user with the specified UID.", - "operationId": "list-authtokens", + "summary": "Mark conversation messages as unread", + "description": "Allows you to mark messages within a conversation as unread", + "operationId": "mark-conversation-as-unread", "parameters": [ { - "name": "uid", - "in": "path", - "description": "An UID of a user.", + "name": "onBehalfOf", + "in": "header", + "description": "UID of the receiver of the message", "required": true, "schema": { "type": "string" - }, - "examples": { - "string": { - "summary": "UID", - "value": "" - } - } - }, - { - "name": "perPage", - "in": "query", - "description": "Number of auth tokens to be fetched in a request. The default value is 100 and the maximum value is 1000.", - "schema": { - "type": "integer", - "default": "100" } }, { - "name": "page", - "in": "query", - "description": "Page number.", - "schema": { - "type": "integer", - "default": "1" - } + "$ref": "#/components/parameters/uid--conversation" } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "messageId": { + "description": "The id of the message upto which the conversation needs to be marked as unread.", + "type": "integer" + } + }, + "type": "object" + } + } + } + }, "responses": { "200": { - "description": "A list of auth tokens", + "description": "Marking Conversation as unread", "content": { "application/json": { "schema": { "properties": { "data": { - "type": "array", - "items": {} - }, - "meta": { "type": "object" } }, "type": "object" }, "example": { - "data": [ - { - "uid": "superhero1", - "authToken": "superhero1_1630306819c3027ce530b2367f3c97b4106f0cb8", - "createdAt": 1630306819 - } - ], - "meta": { - "pagination": { - "total": 1, - "count": 1, - "per_page": 100, - "current_page": 1, - "total_pages": 1 - } + "data": { + "success": true, + "message": "The messages after the message id 340 from the user demo1 are marked as unread for the user demo3." } } } @@ -5052,34 +5086,33 @@ "apiKey": [] } ] - }, - "delete": { + } + }, + "/groups/{guid}/conversation": { + "get": { "tags": [ - "Auth Tokens" + "Conversations" ], - "summary": "Flush", - "description": "Deletes all the auth tokens for the specified UID.", - "operationId": "flush-authtokens", + "summary": "Get Group Conversation", + "description": "Getting group conversation", + "operationId": "get-group-conversations", "parameters": [ { - "name": "uid", - "in": "path", - "description": "An UID of a user.", + "name": "onBehalfOf", + "in": "header", + "description": "UID of the user on whose behalf the action is performed.", "required": true, "schema": { "type": "string" - }, - "examples": { - "string": { - "summary": "UID", - "value": "" - } } + }, + { + "$ref": "#/components/parameters/guid--conversation" } ], "responses": { "200": { - "description": "A list of api keys", + "description": "Get user Conversations", "content": { "application/json": { "schema": { @@ -5091,10 +5124,88 @@ "type": "object" }, "example": { - "data": { - "success": true, - "message": "Cleared Auth Tokens successfully for uid superhero1." - } + "data": [ + { + "conversationId": "group_project-group", + "conversationType": "group", + "unreadMessageCount": "0", + "createdAt": 1630071782, + "updatedAt": 1630481413, + "lastMessage": { + "id": "50", + "conversationId": "group_project-group", + "sender": "superhero4", + "receiverType": "group", + "receiver": "project-group", + "category": "action", + "type": "groupMember", + "data": { + "action": "unbanned", + "entities": { + "by": { + "entity": { + "uid": "superhero4", + "name": "Wolverine", + "role": "default", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png", + "status": "offline", + "createdAt": 1629869270 + }, + "entityType": "user" + }, + "on": { + "entity": { + "uid": "superhero3", + "link": "https://data-us.cometchat.io/assets", + "name": "Captain America", + "role": "default", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", + "status": "offline", + "createdAt": 1629869270, + "updatedAt": 1629964825, + "conversationId": "superhero3_user_superhero4" + }, + "entityType": "user" + }, + "for": { + "entity": { + "guid": "project-group", + "icon": "http://placehold.it/120x120&text=image1", + "name": "Project Group1", + "type": "private", + "owner": "superhero4", + "createdAt": 1630071341, + "updatedAt": 1630305525, + "updatedBy": "superhero4", + "description": "project related discussions between members", + "membersCount": 4, + "conversationId": "group_project-group" + }, + "entityType": "group" + } + } + }, + "sentAt": 1630305562, + "updatedAt": 1630305562 + }, + "conversationWith": { + "guid": "project-group", + "name": "Project Group1", + "description": "project related discussions between members", + "icon": "http://placehold.it/120x120&text=image1", + "type": "private", + "scope": "participant", + "membersCount": 4, + "joinedAt": 1630071782, + "conversationId": "group_project-group", + "hasJoined": true, + "createdAt": 1630071341, + "owner": "superhero4", + "updatedAt": 1630308875, + "updatedBy": "superhero4" + } + } + ] } } } @@ -5105,39 +5216,49 @@ "apiKey": [] } ] - } - }, - "/users/{uid}/auth_tokens/{authToken}": { - "get": { + }, + "put": { "tags": [ - "Auth Tokens" + "Conversations" ], - "summary": "Get", - "description": "Retrieves details of an auth token for the specified UID andauth token.", - "operationId": "get-authtoken", + "summary": "Update Group Conversation", + "description": "Updating Group Conversation", + "operationId": "updates-group-conversation", "parameters": [ { - "name": "uid", - "in": "path", - "description": "An UID of a user.", + "$ref": "#/components/parameters/guid--conversation" + }, + { + "name": "onBehalfOf", + "in": "header", + "description": "UID of the user on whose behalf the action is performed.", "required": true, "schema": { "type": "string" - }, - "examples": { - "string": { - "summary": "UID", - "value": "" - } } - }, - { - "$ref": "#/components/parameters/authToken" } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "tags": { + "description": "List of tags to identify specific conversation.", + "type": "array", + "items": { + "type": "string" + } + } + }, + "type": "object" + } + } + } + }, "responses": { "200": { - "description": "Retrieve Auth Token", + "description": "Updated user Conversations", "content": { "application/json": { "schema": { @@ -5149,11 +5270,93 @@ "type": "object" }, "example": { - "data": { - "uid": "superhero1", - "authToken": "superhero1_1630306819c3027ce530b2367f3c97b4106f0cb8", - "createdAt": 1630306819 - } + "data": [ + { + "conversationId": "group_project-group", + "conversationType": "group", + "unreadMessageCount": "0", + "createdAt": 1630071782, + "updatedAt": 1630481413, + "lastMessage": { + "id": "50", + "conversationId": "group_project-group", + "sender": "superhero4", + "receiverType": "group", + "receiver": "project-group", + "category": "action", + "type": "groupMember", + "data": { + "action": "unbanned", + "entities": { + "by": { + "entity": { + "uid": "superhero4", + "name": "Wolverine", + "role": "default", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png", + "status": "offline", + "createdAt": 1629869270 + }, + "entityType": "user" + }, + "on": { + "entity": { + "uid": "superhero3", + "link": "https://data-us.cometchat.io/assets", + "name": "Captain America", + "role": "default", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", + "status": "offline", + "createdAt": 1629869270, + "updatedAt": 1629964825, + "conversationId": "superhero3_user_superhero4" + }, + "entityType": "user" + }, + "for": { + "entity": { + "guid": "project-group", + "icon": "http://placehold.it/120x120&text=image1", + "name": "Project Group1", + "type": "private", + "owner": "superhero4", + "createdAt": 1630071341, + "updatedAt": 1630305525, + "updatedBy": "superhero4", + "description": "project related discussions between members", + "membersCount": 4, + "conversationId": "group_project-group" + }, + "entityType": "group" + } + } + }, + "sentAt": 1630305562, + "updatedAt": 1630305562, + "receipts": { + "data": [ + [] + ] + } + }, + "conversationWith": { + "guid": "project-group", + "name": "Project Group1", + "description": "project related discussions between members", + "icon": "http://placehold.it/120x120&text=image1", + "type": "private", + "scope": "participant", + "membersCount": 4, + "joinedAt": 1630071782, + "conversationId": "group_project-group", + "hasJoined": true, + "createdAt": 1630071341, + "owner": "superhero4", + "updatedAt": 1630308875, + "updatedBy": "superhero4" + } + } + ] } } } @@ -5165,62 +5368,36 @@ } ] }, - "put": { + "delete": { "tags": [ - "Auth Tokens" + "Conversations" ], - "summary": "Update", - "description": "Updates the details of an auth token for the specified UID andauth token.", - "operationId": "update-authtoken", + "summary": "Reset Group Conversation", + "description": "Resetting Group Conversation", + "operationId": "resets-group-conversation", "parameters": [ { - "name": "uid", - "in": "path", - "description": "An UID of a user.", + "name": "onBehalfOf", + "in": "header", + "description": "UID of the user on whose behalf the action is performed.", "required": true, "schema": { "type": "string" - }, - "examples": { - "string": { - "summary": "UID", - "value": "" - } } }, { - "name": "authToken", - "in": "path", - "description": "An auth token of a user.", - "required": true, - "schema": { - "type": "string" - }, - "examples": { - "string": { - "summary": "Auth Token", - "value": "" - } - } + "$ref": "#/components/parameters/guid--conversation" } ], "requestBody": { - "required": true, "content": { "application/json": { "schema": { "properties": { - "platform": { - "description": "The platform on which the auth token is being used.", - "type": "string" - }, - "userAgent": { - "description": "userAgent from which the auth token is used.", - "type": "string" - }, - "appInfo": { - "description": "JSON data containing app information.", - "type": "object" + "preserveOrder": { + "description": "When set to true, maintains the conversation's position in the user's conversation list after reset.", + "type": "boolean", + "default": false } }, "type": "object" @@ -5230,7 +5407,7 @@ }, "responses": { "200": { - "description": "Updated Auth Token", + "description": "Resetted user Conversations", "content": { "application/json": { "schema": { @@ -5243,9 +5420,8 @@ }, "example": { "data": { - "uid": "superhero1", - "authToken": "superhero1_1630306819c3027ce530b2367f3c97b4106f0cb8", - "createdAt": 1630306819 + "success": true, + "message": "The conversation superhero1_user_superhero2 has been deleted successfully for UID superhero1." } } } @@ -5257,49 +5433,105 @@ "apiKey": [] } ] - }, - "delete": { + } + }, + "/groups/{guid}/conversation/pin": { + "post": { "tags": [ - "Auth Tokens" + "Conversations" ], - "summary": "Delete", - "description": "Deletes an auth token for the specified UID.", - "operationId": "delete-authtoken", + "summary": "Pin Group Conversation", + "description": "Pins a group conversation for a user, so it appears at the top of their conversation list. Pins are per user, so the onBehalfOf header is required. Idempotent - re-pinning keeps the original pinnedAt.", + "operationId": "pin-group-conversation", "parameters": [ { - "name": "uid", - "in": "path", - "description": "An UID of a user.", - "required": true, - "schema": { - "type": "string" - }, - "examples": { - "string": { - "summary": "UID", - "value": "" + "$ref": "#/components/parameters/requiredonBehalfOf" + }, + { + "$ref": "#/components/parameters/guid--conversation" + } + ], + "responses": { + "200": { + "description": "Pinning a group conversation", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "conversationId": "supergroup", + "conversationType": "group", + "pinnedBy": "superhero1", + "pinnedAt": 1700210300 + } + } } } }, - { - "name": "authToken", - "in": "path", - "description": "An auth token of a user.", - "required": true, - "schema": { - "type": "string" - }, - "examples": { - "string": { - "summary": "Auth Token", - "value": "" + "400": { + "description": "The user has reached their pinned conversation limit", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_PINNED_CONVERSATIONS_LIMIT_EXCEEDED", + "message": "The number of pinned conversations for the user with uid superhero1 exceeds the allowed limit of 5." + } + } + } + } + }, + "403": { + "description": "The conversation carries a global pin, so a user cannot pin it themselves", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_SYSTEM_PINNED_CONVERSATION", + "message": "The conversation is pinned for all users by the app and can not be pinned by a user." + } + } } } } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "delete": { + "tags": [ + "Conversations" + ], + "summary": "Unpin Group Conversation", + "description": "Removes a user's own pin from a group conversation. A conversation carrying a global pin cannot be unpinned this way. Idempotent.", + "operationId": "unpin-group-conversation", + "parameters": [ + { + "$ref": "#/components/parameters/requiredonBehalfOf" + }, + { + "$ref": "#/components/parameters/guid--conversation" + } ], "responses": { "200": { - "description": "Deleted Auth token", + "description": "Unpinning a group conversation. pinnedBy and pinnedAt are left out of the response once the conversation is no longer pinned.", "content": { "application/json": { "schema": { @@ -5312,8 +5544,24 @@ }, "example": { "data": { - "success": true, - "message": "User with superhero6 has been deleted successfully." + "conversationId": "supergroup", + "conversationType": "group" + } + } + } + } + }, + "403": { + "description": "The conversation carries a global pin, so a user cannot unpin it themselves", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "error": { + "code": "ERR_SYSTEM_PINNED_CONVERSATION", + "message": "The conversation is pinned for all users by the app and can not be unpinned by a user." } } } @@ -5327,20 +5575,26 @@ ] } }, - "/groups/{guid}/members": { + "/groups/{guid}/conversation/delivered": { "post": { "tags": [ - "Group Members" + "Conversations" ], - "summary": "Add members", - "description": "Adds multiple users as per the scope.", - "operationId": "add-group-members", + "summary": "Mark Group Conversation As Delivered", + "description": "This API will mark the group conversation as delivered.", + "operationId": "mark-group-conversation-as-delivered", "parameters": [ { - "$ref": "#/components/parameters/onBehalfOf" + "name": "onBehalfOf", + "in": "header", + "description": "UID of the receiver of the message", + "required": true, + "schema": { + "type": "string" + } }, { - "$ref": "#/components/parameters/guid" + "$ref": "#/components/parameters/guid--conversation" } ], "requestBody": { @@ -5348,57 +5602,19 @@ "application/json": { "schema": { "properties": { - "admins": { - "description": "UIDs of users to be made admins.", - "type": "array", - "items": { - "type": "string" - }, - "minItems": 1 - }, - "moderators": { - "description": "UIDs of users to be made moderators.", - "type": "array", - "items": { - "type": "string" - }, - "minItems": 1 - }, - "participants": { - "description": "UIDs of users to be made participants.", - "type": "array", - "items": { - "type": "string" - }, - "minItems": 1 - }, - "usersToBan": { - "description": "UIDs of the users to be banned from the group.", - "type": "array", - "items": { - "type": "string" - }, - "minItems": 1 + "messageId": { + "description": "The id of the message upto which the conversation needs to be marked as delivered.", + "type": "integer" } }, "type": "object" - }, - "examples": { - "Add Members": { - "summary": "Add Members", - "value": { - "participants": [ - "cometchat-uid-1" - ] - } - } } } } }, "responses": { "200": { - "description": "Create Group Members", + "description": "Marking Conversation as delivered", "content": { "application/json": { "schema": { @@ -5411,253 +5627,8 @@ }, "example": { "data": { - "usersToBan": { - "superhero6": { - "success": true - } - }, - "admins": { - "superhero1": { - "success": true, - "data": { - "id": "32", - "conversationId": "group_project-group", - "sender": "app_system", - "receiverType": "group", - "receiver": "project-group", - "category": "action", - "type": "groupMember", - "data": { - "action": "added", - "entities": { - "by": { - "entity": { - "uid": "app_system", - "name": "System", - "role": "default", - "status": "offline", - "createdAt": 1596537299 - }, - "entityType": "user" - }, - "on": { - "entity": { - "uid": "superhero1", - "name": "Iron Man", - "role": "default", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/ironman.png", - "status": "offline", - "createdAt": 1596537299 - }, - "entityType": "user" - }, - "for": { - "entity": { - "guid": "project-group", - "icon": "http://placehold.it/120x120&text=image1", - "name": "Project Group", - "tags": [ - "friends", - "project" - ], - "type": "public", - "owner": "superhero2", - "createdAt": 1625460947, - "description": "project related discussions between members", - "membersCount": 2, - "conversationId": "group_project-group" - }, - "entityType": "group" - } - } - }, - "sentAt": 1625460972, - "updatedAt": 1625460972 - } - } - }, - "moderators": { - "superhero3": { - "success": true, - "data": { - "id": "33", - "conversationId": "group_project-group", - "sender": "app_system", - "receiverType": "group", - "receiver": "project-group", - "category": "action", - "type": "groupMember", - "data": { - "action": "added", - "entities": { - "by": { - "entity": { - "uid": "app_system", - "name": "System", - "role": "default", - "status": "offline", - "createdAt": 1596537299 - }, - "entityType": "user" - }, - "on": { - "entity": { - "uid": "superhero3", - "name": "Spiderman", - "role": "default", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/spiderman.png", - "status": "offline", - "createdAt": 1596537299, - "updatedAt": 1625234590 - }, - "entityType": "user" - }, - "for": { - "entity": { - "guid": "project-group", - "icon": "http://placehold.it/120x120&text=image1", - "name": "Project Group", - "tags": [ - "friends", - "project" - ], - "type": "public", - "owner": "superhero2", - "createdAt": 1625460947, - "updatedAt": 1625460972, - "description": "project related discussions between members", - "membersCount": 3, - "conversationId": "group_project-group" - }, - "entityType": "group" - } - } - }, - "sentAt": 1625460973, - "updatedAt": 1625460973 - } - } - }, - "participants": { - "superhero4": { - "success": true, - "data": { - "id": "34", - "conversationId": "group_project-group", - "sender": "app_system", - "receiverType": "group", - "receiver": "project-group", - "category": "action", - "type": "groupMember", - "data": { - "action": "added", - "entities": { - "by": { - "entity": { - "uid": "app_system", - "name": "System", - "role": "default", - "status": "offline", - "createdAt": 1596537299 - }, - "entityType": "user" - }, - "on": { - "entity": { - "uid": "superhero4", - "name": "Wolverine", - "role": "default", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png", - "status": "offline", - "createdAt": 1596537299 - }, - "entityType": "user" - }, - "for": { - "entity": { - "guid": "project-group", - "icon": "http://placehold.it/120x120&text=image1", - "name": "Project Group", - "tags": [ - "friends", - "project" - ], - "type": "public", - "owner": "superhero2", - "createdAt": 1625460947, - "updatedAt": 1625460973, - "description": "project related discussions between members", - "membersCount": 4, - "conversationId": "group_project-group" - }, - "entityType": "group" - } - } - }, - "sentAt": 1625460973, - "updatedAt": 1625460973 - } - }, - "superhero5": { - "success": true, - "data": { - "id": "35", - "conversationId": "group_project-group", - "sender": "app_system", - "receiverType": "group", - "receiver": "project-group", - "category": "action", - "type": "groupMember", - "data": { - "action": "added", - "entities": { - "by": { - "entity": { - "uid": "app_system", - "name": "System", - "role": "default", - "status": "offline", - "createdAt": 1596537299 - }, - "entityType": "user" - }, - "on": { - "entity": { - "uid": "superhero5", - "name": "Cyclops", - "role": "default", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/cyclops.png", - "status": "offline", - "createdAt": 1596537299 - }, - "entityType": "user" - }, - "for": { - "entity": { - "guid": "project-group", - "icon": "http://placehold.it/120x120&text=image1", - "name": "Project Group", - "tags": [ - "friends", - "project" - ], - "type": "public", - "owner": "superhero2", - "createdAt": 1625460947, - "updatedAt": 1625460973, - "description": "project related discussions between members", - "membersCount": 5, - "conversationId": "group_project-group" - }, - "entityType": "group" - } - } - }, - "sentAt": 1625460973, - "updatedAt": 1625460973 - } - } - } + "success": true, + "message": "All the messages in group {{GUID}} are marked as delivered for the user {{onBehalfOf}}." } } } @@ -5669,63 +5640,48 @@ "apiKey": [] } ] - }, - "get": { + } + }, + "/groups/{guid}/conversation/read": { + "post": { "tags": [ - "Group Members" + "Conversations" ], - "summary": "List", - "description": "List the members of a group for a given GUID", - "operationId": "list-group-members", + "summary": "Mark Group Conversation As Read", + "description": "This API will mark the group conversation as read.", + "operationId": "mark-group-conversation-as-read", "parameters": [ { - "$ref": "#/components/parameters/guid" - }, - { - "name": "perPage", - "in": "query", - "description": "Number of users to be fetched in a request. The default value is 100 and the maximum value is 1000.", - "schema": { - "type": "integer", - "default": "100" - } - }, - { - "name": "status", - "in": "query", - "description": "Group members list can be fetched depending on the user status. (available,offline).", - "schema": { - "type": "string", - "enum": [ - "available", - "offline" - ] - } - }, - { - "name": "page", - "in": "query", - "description": "Page Number.", + "name": "onBehalfOf", + "in": "header", + "description": "UID of the receiver of the message", + "required": true, "schema": { - "type": "integer", - "default": "1" + "type": "string" } }, { - "name": "scopes", - "in": "query", - "description": "Fetches group members based on multiple scope.", - "style": "form", - "explode": false, - "schema": { - "type": "array", - "items": {} - } + "$ref": "#/components/parameters/guid--conversation" } ], - "responses": { - "200": { - "description": "Create Group Members", + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "messageId": { + "description": "The id of the message upto which the conversation needs to be marked as read.", + "type": "integer" + } + }, + "type": "object" + } + } + } + }, + "responses": { + "200": { + "description": "Marking Conversation as read", "content": { "application/json": { "schema": { @@ -5737,69 +5693,9 @@ "type": "object" }, "example": { - "data": [ - { - "uid": "superhero2", - "name": "Captain America", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", - "status": "offline", - "role": "default", - "scope": "participant", - "joinedAt": 1638360106, - "createdAt": 1629869270, - "updatedAt": 1630308676, - "conversationId": "superhero2_user_superhero4" - }, - { - "uid": "superhero3", - "name": "Captain America", - "link": "https://data-us.cometchat.io/assets", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", - "metadata": { - "contactNumber": "0123456789" - }, - "status": "offline", - "role": "default", - "scope": "participant", - "joinedAt": 1638360106, - "createdAt": 1629869270, - "updatedAt": 1638351060, - "conversationId": "superhero3_user_superhero4" - }, - { - "uid": "superhero5", - "name": "Cyclops", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/cyclops.png", - "status": "offline", - "role": "default", - "scope": "moderator", - "joinedAt": 1638360106, - "createdAt": 1629869270, - "conversationId": "superhero4_user_superhero5" - }, - { - "uid": "superhero4", - "name": "Wolverine", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png", - "status": "offline", - "role": "default", - "scope": "admin", - "joinedAt": 1638359534, - "createdAt": 1629869270 - } - ], - "meta": { - "pagination": { - "total": 0, - "count": 5, - "per_page": 100, - "current_page": 1, - "total_pages": 1 - } - }, - "cursor": { - "updatedAt": 1638354799, - "affix": "prepend" + "data": { + "success": true, + "message": "All the messages in group {{GUID}} are marked as read for the user {{onBehalfOf}}." } } } @@ -5811,25 +5707,26 @@ "apiKey": [] } ] - } - }, - "/groups/{guid}/members/{uid}": { - "put": { + }, + "delete": { "tags": [ - "Group Members" + "Conversations" ], - "summary": "Change Scope", - "description": "Change scope of a member to the group for a given GUID and UID", - "operationId": "change-group-member-scope", + "summary": "Mark Group Conversation As unread", + "description": "This API will mark the group conversation as unread.", + "operationId": "mark-group-conversation-as-unread", "parameters": [ { - "$ref": "#/components/parameters/onBehalfOf" - }, - { - "$ref": "#/components/parameters/guid" + "name": "onBehalfOf", + "in": "header", + "description": "UID of the group member marking the messages as unread.", + "required": true, + "schema": { + "type": "string" + } }, { - "$ref": "#/components/parameters/uid" + "$ref": "#/components/parameters/guid--conversation" } ], "requestBody": { @@ -5837,10 +5734,9 @@ "application/json": { "schema": { "properties": { - "scope": { - "description": "A scope for the user.", - "type": "string", - "default": "participant" + "messageId": { + "description": "The id of the message upto which the conversation needs to be marked as unread.", + "type": "integer" } }, "type": "object" @@ -5850,26 +5746,12 @@ }, "responses": { "200": { - "description": "Changed Scope of Group Members", + "description": "Marking Conversation as unread", "content": { "application/json": { "schema": { "properties": { "data": { - "properties": { - "guid": { - "type": "string" - }, - "uid": { - "type": "string" - }, - "scope": { - "type": "string" - }, - "joinedAt": { - "type": "integer" - } - }, "type": "object" } }, @@ -5877,10 +5759,8 @@ }, "example": { "data": { - "guid": "supergroup", - "uid": "superhero2", - "scope": "participant", - "joinedAt": 1631690303 + "success": true, + "message": "The messages after the message id 340 from the user demo1 are marked as unread for the user demo3." } } } @@ -5892,42 +5772,61 @@ "apiKey": [] } ] - }, - "delete": { + } + }, + "/users/{uid}/auth_tokens": { + "post": { "tags": [ - "Group Members" + "Auth Tokens" ], - "summary": "Kick", - "description": "Removes a member with given UID from a group for a given GUID.", - "operationId": "kick-group-member", + "summary": "Create", + "description": "Creates auth token for a user with the specified UID.", + "operationId": "create-authtoken", "parameters": [ { - "$ref": "#/components/parameters/onBehalfOf" - }, - { - "$ref": "#/components/parameters/guid" - }, - { - "$ref": "#/components/parameters/uid" + "name": "uid", + "in": "path", + "description": "An UID of a user.", + "required": true, + "schema": { + "type": "string" + }, + "examples": { + "string": { + "summary": "UID", + "value": "" + } + } } ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "force": { + "description": "Generates new auth token forcefully.", + "type": "boolean" + } + }, + "type": "object" + } + } + } + }, "responses": { "200": { - "description": "Kicked Group Members", + "description": "Created auth token", "content": { "application/json": { "schema": { - "properties": { - "data": { - "type": "object" - } - }, "type": "object" }, "example": { "data": { - "success": true, - "message": "The member with superhero3 has been kicked from the Group with supergroup." + "uid": "superhero1", + "authToken": "superhero1_1630306819c3027ce530b2367f3c97b4106f0cb8", + "createdAt": 1630306819 } } } @@ -5939,77 +5838,103 @@ "apiKey": [] } ] - } - }, - "/groups/{guid}/bannedusers/{uid}": { - "post": { + }, + "get": { "tags": [ - "Banned Users" + "Auth Tokens" ], - "summary": "Ban", - "description": "Bans a member from a group for a given GUID and UID.", - "operationId": "ban-group-user", + "summary": "List", + "description": "Lists auth tokens for a user with the specified UID.", + "operationId": "list-authtokens", "parameters": [ { - "$ref": "#/components/parameters/onBehalfOf" - }, - { - "$ref": "#/components/parameters/guid" - }, - { - "$ref": "#/components/parameters/uid" + "name": "uid", + "in": "path", + "description": "An UID of a user.", + "required": true, + "schema": { + "type": "string" + }, + "examples": { + "string": { + "summary": "UID", + "value": "" + } + } } ], "responses": { "200": { - "description": "Create Group", + "description": "A list of auth tokens", "content": { "application/json": { "schema": { "properties": { "data": { + "type": "array", + "items": {} + }, + "meta": { "type": "object" } }, "type": "object" }, "example": { - "data": { - "success": true, - "message": "The user with uid superhero3 has been banned from the Group with supergroup." - } - } - } - } - } - }, - "security": [ - { - "apiKey": [] - } - ] - }, - "delete": { + "data": [ + { + "uid": "superhero1", + "authToken": "superhero1_1630306819c3027ce530b2367f3c97b4106f0cb8", + "createdAt": 1630306819 + } + ], + "meta": { + "pagination": { + "total": 1, + "count": 1, + "per_page": 100, + "current_page": 1, + "total_pages": 1 + } + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "delete": { "tags": [ - "Banned Users" + "Auth Tokens" ], - "summary": "Unban", - "description": "Unban a member with given UID from a group for a given GUID.", - "operationId": "unban-group-user", + "summary": "Flush", + "description": "Deletes all the auth tokens for the specified UID.", + "operationId": "flush-authtokens", "parameters": [ { - "$ref": "#/components/parameters/onBehalfOf" - }, - { - "$ref": "#/components/parameters/guid" - }, - { - "$ref": "#/components/parameters/uid" + "name": "uid", + "in": "path", + "description": "An UID of a user.", + "required": true, + "schema": { + "type": "string" + }, + "examples": { + "string": { + "summary": "UID", + "value": "" + } + } } ], "responses": { "200": { - "description": "Create Group", + "description": "A list of api keys", "content": { "application/json": { "schema": { @@ -6023,7 +5948,7 @@ "example": { "data": { "success": true, - "message": "The user with uid superhero3 has been banned from the Group with supergroup." + "message": "Cleared Auth Tokens successfully for uid superhero1." } } } @@ -6037,117 +5962,52 @@ ] } }, - "/groups/{guid}/bannedusers": { + "/users/{uid}/auth_tokens/{authToken}": { "get": { "tags": [ - "Banned Users" + "Auth Tokens" ], - "summary": "List", - "description": "Lists banned users from a group for a given GUID.", - "operationId": "list-banned-group-users", + "summary": "Get", + "description": "Retrieves details of an auth token for the specified UID andauth token.", + "operationId": "get-authtoken", "parameters": [ { - "$ref": "#/components/parameters/guid" - }, - { - "name": "perPage", - "in": "query", - "description": "Number of banned users to be fetched in a request. The default value is 100 and the maximum value is 1000.", + "name": "uid", + "in": "path", + "description": "An UID of a user.", + "required": true, "schema": { - "type": "integer", - "default": "100" + "type": "string" + }, + "examples": { + "string": { + "summary": "UID", + "value": "" + } } }, { - "name": "page", - "in": "query", - "description": "Page number.", - "schema": { - "type": "integer", - "default": "1" - } + "$ref": "#/components/parameters/authToken" } ], "responses": { "200": { - "description": "get Banned User", + "description": "Retrieve Auth Token", "content": { "application/json": { "schema": { "properties": { "data": { "type": "object" - }, - "meta": { - "type": "object" - }, - "cursor": { - "properties": { - "updatedAt": { - "type": "integer" - }, - "affix": { - "type": "string" - } - }, - "type": "object" } }, "type": "object" }, "example": { - "data": [ - { - "uid": "superhero6", - "name": "Barry Allen", - "link": "http://placehold.it", - "avatar": "http://placehold.it/120x120&text=image1", - "metadata": { - "email": "user@email.com", - "contactNumber": "0123456789" - }, - "status": "offline", - "role": "manager", - "createdAt": 1638354015, - "updatedAt": 1638354799, - "conversationId": "superhero4_user_superhero6" - }, - { - "uid": "superhero2", - "name": "Captain America", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", - "status": "offline", - "role": "default", - "createdAt": 1629869270, - "updatedAt": 1630308676, - "conversationId": "superhero2_user_superhero4" - }, - { - "uid": "superhero3", - "name": "Captain America", - "link": "https://data-us.cometchat.io/assets", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", - "metadata": { - "contactNumber": "0123456789" - }, - "status": "offline", - "role": "default", - "blockedByMe": true, - "blockedByMeAt": 1638346853, - "blockedAt": 1638346853, - "createdAt": 1629869270, - "updatedAt": 1638351060, - "conversationId": "superhero3_user_superhero4" - } - ], - "meta": { - "pagination": { - "total": 0, - "count": 5, - "per_page": 100, - "current_page": 1, - "total_pages": 1 - } + "data": { + "uid": "superhero1", + "authToken": "superhero1_1630306819c3027ce530b2367f3c97b4106f0cb8", + "createdAt": 1630306819 } } } @@ -6159,37 +6019,63 @@ "apiKey": [] } ] - } - }, - "/users/{uid}/friends": { - "post": { + }, + "put": { "tags": [ - "Friends" + "Auth Tokens" ], - "summary": "Add Friends", - "description": "The API allows to add multiple friends for a given UID.", - "operationId": "add-friend", + "summary": "Update", + "description": "Updates the details of an auth token for the specified UID andauth token.", + "operationId": "update-authtoken", "parameters": [ { - "$ref": "#/components/parameters/uid" + "name": "uid", + "in": "path", + "description": "An UID of a user.", + "required": true, + "schema": { + "type": "string" + }, + "examples": { + "string": { + "summary": "UID", + "value": "" + } + } + }, + { + "name": "authToken", + "in": "path", + "description": "An auth token of a user.", + "required": true, + "schema": { + "type": "string" + }, + "examples": { + "string": { + "summary": "Auth Token", + "value": "" + } + } } ], "requestBody": { + "required": true, "content": { "application/json": { "schema": { "properties": { - "accepted": { - "description": "The array of UIDs of the friends.", - "type": "array", - "items": { - "type": "string" - } + "platform": { + "description": "The platform on which the auth token is being used.", + "type": "string" }, - "addToConversations": { - "description": "When enabled, automatically creates chat conversations between users when they become friends.", - "type": "boolean", - "default": false + "userAgent": { + "description": "userAgent from which the auth token is used.", + "type": "string" + }, + "appInfo": { + "description": "JSON data containing app information.", + "type": "object" } }, "type": "object" @@ -6199,20 +6085,12 @@ }, "responses": { "200": { - "description": "Added Friend", + "description": "Updated Auth Token", "content": { "application/json": { "schema": { "properties": { "data": { - "properties": { - "": { - "type": "object" - }, - "": { - "type": "object" - } - }, "type": "object" } }, @@ -6220,16 +6098,9 @@ }, "example": { "data": { - "accepted": { - "superhero2": { - "success": true, - "message": "Created relationship with status accepted." - }, - "superhero3": { - "success": true, - "message": "Created relationship with status accepted." - } - } + "uid": "superhero1", + "authToken": "superhero1_1630306819c3027ce530b2367f3c97b4106f0cb8", + "createdAt": 1630306819 } } } @@ -6242,163 +6113,48 @@ } ] }, - "get": { + "delete": { "tags": [ - "Friends" + "Auth Tokens" ], - "summary": "List Friends", - "description": "The API allows to fetch friends for a given UID.", - "operationId": "list-all-friends", + "summary": "Delete", + "description": "Deletes an auth token for the specified UID.", + "operationId": "delete-authtoken", "parameters": [ { - "$ref": "#/components/parameters/uid" - }, - { - "name": "searchKey", - "in": "query", - "description": "Searches for given keyword in friends list (either UID or name).", + "name": "uid", + "in": "path", + "description": "An UID of a user.", + "required": true, "schema": { "type": "string" + }, + "examples": { + "string": { + "summary": "UID", + "value": "" + } } }, { - "name": "perPage", - "in": "query", - "description": "Number of friends to be fetched in a request. The default value is 100 and the maximum value is 1000.", - "schema": { - "type": "integer", - "default": "100" - } - }, - { - "name": "page", - "in": "query", - "description": "Page Number.", + "name": "authToken", + "in": "path", + "description": "An auth token of a user.", + "required": true, "schema": { - "type": "integer", - "default": "1" - } - } - ], - "responses": { - "200": { - "description": "A list of friends.", - "content": { - "application/json": { - "schema": { - "properties": { - "data": { - "type": "array", - "items": {} - }, - "meta": { - "type": "object" - } - }, - "type": "object" - }, - "example": { - "data": [ - { - "uid": "superhero6", - "name": "Barry Allen", - "link": "http://placehold.it", - "avatar": "http://placehold.it/120x120&text=image1", - "metadata": { - "email": "user@email.com", - "contactNumber": "0123456789" - }, - "status": "offline", - "role": "manager", - "createdAt": 1638354015, - "updatedAt": 1638354799, - "conversationId": "superhero4_user_superhero6" - }, - { - "uid": "superhero2", - "name": "Captain America", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", - "status": "offline", - "role": "default", - "createdAt": 1629869270, - "updatedAt": 1630308676, - "conversationId": "superhero2_user_superhero4" - }, - { - "uid": "superhero3", - "name": "Captain America", - "link": "https://data-us.cometchat.io/assets", - "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", - "metadata": { - "contactNumber": "0123456789" - }, - "status": "offline", - "role": "default", - "blockedByMe": true, - "blockedByMeAt": 1638346853, - "blockedAt": 1638346853, - "createdAt": 1629869270, - "updatedAt": 1638351060, - "conversationId": "superhero3_user_superhero4" - } - ], - "meta": { - "pagination": { - "total": 0, - "count": 5, - "per_page": 100, - "current_page": 1, - "total_pages": 1 - }, - "cursor": { - "updatedAt": 1638354799, - "affix": "prepend" - } - } - } + "type": "string" + }, + "examples": { + "string": { + "summary": "Auth Token", + "value": "" } } } - }, - "security": [ - { - "apiKey": [] - } - ] - }, - "delete": { - "tags": [ - "Friends" - ], - "summary": "Remove Friends", - "description": "The API removes friends for a given UID.", - "operationId": "remove-friend", - "parameters": [ - { - "$ref": "#/components/parameters/uid" - } ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "properties": { - "friends": { - "description": "The array of friends to remove.", - "type": "array", - "items": { - "type": "string" - } - } - }, - "type": "object" - } - } - } - }, "responses": { "200": { - "description": "A list of api keys", + "description": "Deleted Auth token", "content": { "application/json": { "schema": { @@ -6412,7 +6168,7 @@ "example": { "data": { "success": true, - "message": "Deleted the friend relations succussfully" + "message": "User with superhero6 has been deleted successfully." } } } @@ -6426,65 +6182,83 @@ ] } }, - "/users/{uid}/blockedusers": { + "/groups/{guid}/members": { "post": { "tags": [ - "Blocked Users" + "Group Members" ], - "summary": "Block User", - "description": "Blocks the specified user", - "operationId": "block-users", + "summary": "Add members", + "description": "Adds multiple users as per the scope.", + "operationId": "add-group-members", "parameters": [ { - "name": "uid", - "in": "path", - "description": "An UID of a user.", - "required": true, - "schema": { - "type": "string" - }, - "examples": { - "string": { - "summary": "UID", - "value": "" - } - } + "$ref": "#/components/parameters/onBehalfOf" + }, + { + "$ref": "#/components/parameters/guid" } ], "requestBody": { "content": { "application/json": { "schema": { - "required": [ - "blockedUids" - ], "properties": { - "blockedUids": { - "description": "UIDs of the users to be blocked", + "admins": { + "description": "UIDs of users to be made admins.", "type": "array", "items": { "type": "string" - } + }, + "minItems": 1 + }, + "moderators": { + "description": "UIDs of users to be made moderators.", + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + }, + "participants": { + "description": "UIDs of users to be made participants.", + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 + }, + "usersToBan": { + "description": "UIDs of the users to be banned from the group.", + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1 } }, "type": "object" + }, + "examples": { + "Add Members": { + "summary": "Add Members", + "value": { + "participants": [ + "cometchat-uid-1" + ] + } + } } } } }, "responses": { "200": { - "description": "Blocked user", + "description": "Create Group Members", "content": { "application/json": { "schema": { "properties": { "data": { - "properties": { - "": { - "type": "object" - } - }, "type": "object" } }, @@ -6492,29 +6266,1010 @@ }, "example": { "data": { - "superhero4": { - "success": true, - "message": "The user with UID superhero1 has blocked user with UID superhero3 successfully." - } - } - } - } - } - } - }, - "security": [ + "usersToBan": { + "superhero6": { + "success": true + } + }, + "admins": { + "superhero1": { + "success": true, + "data": { + "id": "32", + "conversationId": "group_project-group", + "sender": "app_system", + "receiverType": "group", + "receiver": "project-group", + "category": "action", + "type": "groupMember", + "data": { + "action": "added", + "entities": { + "by": { + "entity": { + "uid": "app_system", + "name": "System", + "role": "default", + "status": "offline", + "createdAt": 1596537299 + }, + "entityType": "user" + }, + "on": { + "entity": { + "uid": "superhero1", + "name": "Iron Man", + "role": "default", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/ironman.png", + "status": "offline", + "createdAt": 1596537299 + }, + "entityType": "user" + }, + "for": { + "entity": { + "guid": "project-group", + "icon": "http://placehold.it/120x120&text=image1", + "name": "Project Group", + "tags": [ + "friends", + "project" + ], + "type": "public", + "owner": "superhero2", + "createdAt": 1625460947, + "description": "project related discussions between members", + "membersCount": 2, + "conversationId": "group_project-group" + }, + "entityType": "group" + } + } + }, + "sentAt": 1625460972, + "updatedAt": 1625460972 + } + } + }, + "moderators": { + "superhero3": { + "success": true, + "data": { + "id": "33", + "conversationId": "group_project-group", + "sender": "app_system", + "receiverType": "group", + "receiver": "project-group", + "category": "action", + "type": "groupMember", + "data": { + "action": "added", + "entities": { + "by": { + "entity": { + "uid": "app_system", + "name": "System", + "role": "default", + "status": "offline", + "createdAt": 1596537299 + }, + "entityType": "user" + }, + "on": { + "entity": { + "uid": "superhero3", + "name": "Spiderman", + "role": "default", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/spiderman.png", + "status": "offline", + "createdAt": 1596537299, + "updatedAt": 1625234590 + }, + "entityType": "user" + }, + "for": { + "entity": { + "guid": "project-group", + "icon": "http://placehold.it/120x120&text=image1", + "name": "Project Group", + "tags": [ + "friends", + "project" + ], + "type": "public", + "owner": "superhero2", + "createdAt": 1625460947, + "updatedAt": 1625460972, + "description": "project related discussions between members", + "membersCount": 3, + "conversationId": "group_project-group" + }, + "entityType": "group" + } + } + }, + "sentAt": 1625460973, + "updatedAt": 1625460973 + } + } + }, + "participants": { + "superhero4": { + "success": true, + "data": { + "id": "34", + "conversationId": "group_project-group", + "sender": "app_system", + "receiverType": "group", + "receiver": "project-group", + "category": "action", + "type": "groupMember", + "data": { + "action": "added", + "entities": { + "by": { + "entity": { + "uid": "app_system", + "name": "System", + "role": "default", + "status": "offline", + "createdAt": 1596537299 + }, + "entityType": "user" + }, + "on": { + "entity": { + "uid": "superhero4", + "name": "Wolverine", + "role": "default", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png", + "status": "offline", + "createdAt": 1596537299 + }, + "entityType": "user" + }, + "for": { + "entity": { + "guid": "project-group", + "icon": "http://placehold.it/120x120&text=image1", + "name": "Project Group", + "tags": [ + "friends", + "project" + ], + "type": "public", + "owner": "superhero2", + "createdAt": 1625460947, + "updatedAt": 1625460973, + "description": "project related discussions between members", + "membersCount": 4, + "conversationId": "group_project-group" + }, + "entityType": "group" + } + } + }, + "sentAt": 1625460973, + "updatedAt": 1625460973 + } + }, + "superhero5": { + "success": true, + "data": { + "id": "35", + "conversationId": "group_project-group", + "sender": "app_system", + "receiverType": "group", + "receiver": "project-group", + "category": "action", + "type": "groupMember", + "data": { + "action": "added", + "entities": { + "by": { + "entity": { + "uid": "app_system", + "name": "System", + "role": "default", + "status": "offline", + "createdAt": 1596537299 + }, + "entityType": "user" + }, + "on": { + "entity": { + "uid": "superhero5", + "name": "Cyclops", + "role": "default", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/cyclops.png", + "status": "offline", + "createdAt": 1596537299 + }, + "entityType": "user" + }, + "for": { + "entity": { + "guid": "project-group", + "icon": "http://placehold.it/120x120&text=image1", + "name": "Project Group", + "tags": [ + "friends", + "project" + ], + "type": "public", + "owner": "superhero2", + "createdAt": 1625460947, + "updatedAt": 1625460973, + "description": "project related discussions between members", + "membersCount": 5, + "conversationId": "group_project-group" + }, + "entityType": "group" + } + } + }, + "sentAt": 1625460973, + "updatedAt": 1625460973 + } + } + } + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "get": { + "tags": [ + "Group Members" + ], + "summary": "List", + "description": "List the members of a group for a given GUID", + "operationId": "list-group-members", + "parameters": [ + { + "$ref": "#/components/parameters/guid" + }, + { + "name": "perPage", + "in": "query", + "description": "Number of users to be fetched in a request. The default value is 100 and the maximum value is 1000.", + "schema": { + "type": "integer", + "default": "100" + } + }, + { + "name": "status", + "in": "query", + "description": "Group members list can be fetched depending on the user status. (available,offline).", + "schema": { + "type": "string", + "enum": [ + "available", + "offline" + ] + } + }, + { + "name": "page", + "in": "query", + "description": "Page Number.", + "schema": { + "type": "integer", + "default": "1" + } + }, + { + "name": "scopes", + "in": "query", + "description": "Fetches group members based on multiple scope.", + "style": "form", + "explode": false, + "schema": { + "type": "array", + "items": {} + } + } + ], + "responses": { + "200": { + "description": "Create Group Members", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": [ + { + "uid": "superhero2", + "name": "Captain America", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", + "status": "offline", + "role": "default", + "scope": "participant", + "joinedAt": 1638360106, + "createdAt": 1629869270, + "updatedAt": 1630308676, + "conversationId": "superhero2_user_superhero4" + }, + { + "uid": "superhero3", + "name": "Captain America", + "link": "https://data-us.cometchat.io/assets", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", + "metadata": { + "contactNumber": "0123456789" + }, + "status": "offline", + "role": "default", + "scope": "participant", + "joinedAt": 1638360106, + "createdAt": 1629869270, + "updatedAt": 1638351060, + "conversationId": "superhero3_user_superhero4" + }, + { + "uid": "superhero5", + "name": "Cyclops", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/cyclops.png", + "status": "offline", + "role": "default", + "scope": "moderator", + "joinedAt": 1638360106, + "createdAt": 1629869270, + "conversationId": "superhero4_user_superhero5" + }, + { + "uid": "superhero4", + "name": "Wolverine", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/wolverine.png", + "status": "offline", + "role": "default", + "scope": "admin", + "joinedAt": 1638359534, + "createdAt": 1629869270 + } + ], + "meta": { + "pagination": { + "total": 0, + "count": 5, + "per_page": 100, + "current_page": 1, + "total_pages": 1 + } + }, + "cursor": { + "updatedAt": 1638354799, + "affix": "prepend" + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + } + }, + "/groups/{guid}/members/{uid}": { + "put": { + "tags": [ + "Group Members" + ], + "summary": "Change Scope", + "description": "Change scope of a member to the group for a given GUID and UID", + "operationId": "change-group-member-scope", + "parameters": [ + { + "$ref": "#/components/parameters/onBehalfOf" + }, + { + "$ref": "#/components/parameters/guid" + }, + { + "$ref": "#/components/parameters/uid" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "scope": { + "description": "A scope for the user.", + "type": "string", + "default": "participant" + } + }, + "type": "object" + } + } + } + }, + "responses": { + "200": { + "description": "Changed Scope of Group Members", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "properties": { + "guid": { + "type": "string" + }, + "uid": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "joinedAt": { + "type": "integer" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "guid": "supergroup", + "uid": "superhero2", + "scope": "participant", + "joinedAt": 1631690303 + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "delete": { + "tags": [ + "Group Members" + ], + "summary": "Kick", + "description": "Removes a member with given UID from a group for a given GUID.", + "operationId": "kick-group-member", + "parameters": [ + { + "$ref": "#/components/parameters/onBehalfOf" + }, + { + "$ref": "#/components/parameters/guid" + }, + { + "$ref": "#/components/parameters/uid" + } + ], + "responses": { + "200": { + "description": "Kicked Group Members", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "success": true, + "message": "The member with superhero3 has been kicked from the Group with supergroup." + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + } + }, + "/groups/{guid}/bannedusers/{uid}": { + "post": { + "tags": [ + "Banned Users" + ], + "summary": "Ban", + "description": "Bans a member from a group for a given GUID and UID.", + "operationId": "ban-group-user", + "parameters": [ + { + "$ref": "#/components/parameters/onBehalfOf" + }, + { + "$ref": "#/components/parameters/guid" + }, + { + "$ref": "#/components/parameters/uid" + } + ], + "responses": { + "200": { + "description": "Create Group", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "success": true, + "message": "The user with uid superhero3 has been banned from the Group with supergroup." + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "delete": { + "tags": [ + "Banned Users" + ], + "summary": "Unban", + "description": "Unban a member with given UID from a group for a given GUID.", + "operationId": "unban-group-user", + "parameters": [ + { + "$ref": "#/components/parameters/onBehalfOf" + }, + { + "$ref": "#/components/parameters/guid" + }, + { + "$ref": "#/components/parameters/uid" + } + ], + "responses": { + "200": { + "description": "Create Group", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "success": true, + "message": "The user with uid superhero3 has been banned from the Group with supergroup." + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + } + }, + "/groups/{guid}/bannedusers": { + "get": { + "tags": [ + "Banned Users" + ], + "summary": "List", + "description": "Lists banned users from a group for a given GUID.", + "operationId": "list-banned-group-users", + "parameters": [ + { + "$ref": "#/components/parameters/guid" + } + ], + "responses": { + "200": { + "description": "get Banned User", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "type": "object" + }, + "meta": { + "type": "object" + }, + "cursor": { + "properties": { + "updatedAt": { + "type": "integer" + }, + "affix": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": [ + { + "uid": "superhero6", + "name": "Barry Allen", + "link": "http://placehold.it", + "avatar": "http://placehold.it/120x120&text=image1", + "metadata": { + "email": "user@email.com", + "contactNumber": "0123456789" + }, + "status": "offline", + "role": "manager", + "createdAt": 1638354015, + "updatedAt": 1638354799, + "conversationId": "superhero4_user_superhero6" + }, + { + "uid": "superhero2", + "name": "Captain America", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", + "status": "offline", + "role": "default", + "createdAt": 1629869270, + "updatedAt": 1630308676, + "conversationId": "superhero2_user_superhero4" + }, + { + "uid": "superhero3", + "name": "Captain America", + "link": "https://data-us.cometchat.io/assets", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", + "metadata": { + "contactNumber": "0123456789" + }, + "status": "offline", + "role": "default", + "blockedByMe": true, + "blockedByMeAt": 1638346853, + "blockedAt": 1638346853, + "createdAt": 1629869270, + "updatedAt": 1638351060, + "conversationId": "superhero3_user_superhero4" + } + ], + "meta": { + "pagination": { + "total": 0, + "count": 5, + "per_page": 100, + "current_page": 1, + "total_pages": 1 + } + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + } + }, + "/users/{uid}/friends": { + "post": { + "tags": [ + "Friends" + ], + "summary": "Add Friends", + "description": "The API allows to add multiple friends for a given UID.", + "operationId": "add-friend", + "parameters": [ + { + "$ref": "#/components/parameters/uid" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "accepted": { + "description": "The array of UIDs of the friends.", + "type": "array", + "items": { + "type": "string" + } + }, + "addToConversations": { + "description": "When enabled, automatically creates chat conversations between users when they become friends.", + "type": "boolean", + "default": false + } + }, + "type": "object" + } + } + } + }, + "responses": { + "200": { + "description": "Added Friend", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "properties": { + "": { + "type": "object" + }, + "": { + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "accepted": { + "superhero2": { + "success": true, + "message": "Created relationship with status accepted." + }, + "superhero3": { + "success": true, + "message": "Created relationship with status accepted." + } + } + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "get": { + "tags": [ + "Friends" + ], + "summary": "List Friends", + "description": "The API allows to fetch friends for a given UID.", + "operationId": "list-all-friends", + "parameters": [ + { + "$ref": "#/components/parameters/uid" + }, + { + "name": "searchKey", + "in": "query", + "description": "Searches for given keyword in friends list (either UID or name).", + "schema": { + "type": "string" + } + }, + { + "name": "perPage", + "in": "query", + "description": "Number of friends to be fetched in a request. The default value is 100 and the maximum value is 1000.", + "schema": { + "type": "integer", + "default": "100" + } + }, + { + "name": "page", + "in": "query", + "description": "Page Number.", + "schema": { + "type": "integer", + "default": "1" + } + } + ], + "responses": { + "200": { + "description": "A list of friends.", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "type": "array", + "items": {} + }, + "meta": { + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": [ + { + "uid": "superhero6", + "name": "Barry Allen", + "link": "http://placehold.it", + "avatar": "http://placehold.it/120x120&text=image1", + "metadata": { + "email": "user@email.com", + "contactNumber": "0123456789" + }, + "status": "offline", + "role": "manager", + "createdAt": 1638354015, + "updatedAt": 1638354799, + "conversationId": "superhero4_user_superhero6" + }, + { + "uid": "superhero2", + "name": "Captain America", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", + "status": "offline", + "role": "default", + "createdAt": 1629869270, + "updatedAt": 1630308676, + "conversationId": "superhero2_user_superhero4" + }, + { + "uid": "superhero3", + "name": "Captain America", + "link": "https://data-us.cometchat.io/assets", + "avatar": "https://data-us.cometchat.io/assets/images/avatars/captainamerica.png", + "metadata": { + "contactNumber": "0123456789" + }, + "status": "offline", + "role": "default", + "blockedByMe": true, + "blockedByMeAt": 1638346853, + "blockedAt": 1638346853, + "createdAt": 1629869270, + "updatedAt": 1638351060, + "conversationId": "superhero3_user_superhero4" + } + ], + "meta": { + "pagination": { + "total": 0, + "count": 5, + "per_page": 100, + "current_page": 1, + "total_pages": 1 + }, + "cursor": { + "updatedAt": 1638354799, + "affix": "prepend" + } + } + } + } + } + } + }, + "security": [ { "apiKey": [] } ] }, "delete": { + "tags": [ + "Friends" + ], + "summary": "Remove Friends", + "description": "The API removes friends for a given UID.", + "operationId": "remove-friend", + "parameters": [ + { + "$ref": "#/components/parameters/uid" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "friends": { + "description": "The array of friends to remove.", + "type": "array", + "items": { + "type": "string" + } + } + }, + "type": "object" + } + } + } + }, + "responses": { + "200": { + "description": "A list of api keys", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "success": true, + "message": "Deleted the friend relations succussfully" + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + } + }, + "/users/{uid}/blockedusers": { + "post": { "tags": [ "Blocked Users" ], - "summary": "Unblock User", - "description": "Unblocks the specified user", - "operationId": "unblock-users", + "summary": "Block User", + "description": "Blocks the specified user", "parameters": [ { "name": "uid", @@ -6541,7 +7296,7 @@ ], "properties": { "blockedUids": { - "description": "UIDs of the users to be unblock", + "description": "UIDs of the users to be blocked", "type": "array", "items": { "type": "string" @@ -6589,13 +7344,12 @@ } ] }, - "get": { + "delete": { "tags": [ "Blocked Users" ], - "summary": "List Blocked Users", - "description": "Retrieves the blocked users", - "operationId": "list-all-blocked-users", + "summary": "Unblock User", + "description": "Unblocks the specified user", "parameters": [ { "name": "uid", @@ -6611,23 +7365,85 @@ "value": "" } } - }, - { - "name": "perPage", - "in": "query", - "description": "Number of blocked users to be fetched in a request. The default value is 100 and the maximum value is 1000.", - "schema": { - "type": "integer", - "default": "100" + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "required": [ + "blockedUids" + ], + "properties": { + "blockedUids": { + "description": "UIDs of the users to be unblock", + "type": "array", + "items": { + "type": "string" + } + } + }, + "type": "object" + } } - }, + } + }, + "responses": { + "200": { + "description": "Blocked user", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "properties": { + "": { + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "superhero4": { + "success": true, + "message": "The user with UID superhero1 has blocked user with UID superhero3 successfully." + } + } + } + } + } + } + }, + "security": [ { - "name": "page", - "in": "query", - "description": "Page number.", + "apiKey": [] + } + ] + }, + "get": { + "tags": [ + "Blocked Users" + ], + "summary": "List Blocked Users", + "description": "Retrieves the blocked users", + "parameters": [ + { + "name": "uid", + "in": "path", + "description": "An UID of a user.", + "required": true, "schema": { - "type": "integer", - "default": "1" + "type": "string" + }, + "examples": { + "string": { + "summary": "UID", + "value": "" + } } } ], @@ -6810,26 +7626,6 @@ "summary": "List", "description": "Lists the user roles", "operationId": "list-roles", - "parameters": [ - { - "name": "perPage", - "in": "query", - "description": "Number of roles to be fetched in a request. The default value is 100 and the maximum value is 1000.", - "schema": { - "type": "integer", - "default": "100" - } - }, - { - "name": "page", - "in": "query", - "description": "Page number.", - "schema": { - "type": "integer", - "default": "1" - } - } - ], "responses": { "200": { "description": "Lists the user roles", @@ -7382,18 +8178,6 @@ "summary": "List Role Permissions", "description": "Lists role permissions", "operationId": "list-role-permissions", - "parameters": [ - { - "name": "role", - "in": "path", - "description": "The role identifier to list permissions for", - "required": true, - "schema": { - "type": "string", - "example": "default" - } - } - ], "responses": { "200": { "description": "Lists role permissions", @@ -7623,28 +8407,6 @@ "summary": "List Scope Permissions", "description": "Lists scope permissions", "operationId": "list-scope-permissions", - "parameters": [ - { - "name": "guid", - "in": "path", - "description": "The group GUID to list scope permissions for", - "required": true, - "schema": { - "type": "string", - "example": "supergroup" - } - }, - { - "name": "scope", - "in": "path", - "description": "The scope identifier (e.g., admin, moderator, participant)", - "required": true, - "schema": { - "type": "string", - "example": "admin" - } - } - ], "responses": { "200": { "description": "Lists scope permissions", @@ -8237,39 +8999,6 @@ "value": "" } } - }, - { - "name": "affix", - "in": "query", - "description": "Determines whether to pull the messages either before or after any message id. Possible values are append(after) and prepend(before).", - "schema": { - "type": "string" - } - }, - { - "name": "id", - "in": "query", - "description": "Retrieves all those messages after the passed id.", - "schema": { - "type": "string" - } - }, - { - "name": "sentAt", - "in": "query", - "description": "Fetches the messages list after a particular sentAt timestamp.", - "schema": { - "type": "integer" - } - }, - { - "name": "limit", - "in": "query", - "description": "The number of records to fetch. Minimum value: 1, Maximum value: 1000", - "schema": { - "type": "integer", - "default": "10" - } } ], "responses": { @@ -8390,7 +9119,7 @@ "description": "Number of threads to be fetched in a request. The default value is 100 and the maximum value is 1000.", "schema": { "type": "integer", - "default": 100 + "default": "100" } }, { @@ -8890,7 +9619,7 @@ } }, { - "name": "mentionsWithTagInfo", + "name": "mentionswithTagInfo", "in": "query", "description": "Provides user tags for the mentioned users.", "schema": { @@ -9377,7 +10106,7 @@ } }, { - "name": "mentionsWithTagInfo", + "name": "mentionswithTagInfo", "in": "query", "description": "Provides user tags for the mentioned users.", "schema": { @@ -12808,8 +13537,178 @@ "basicAuthPassword": "pass122", "isEnabled": true, "useBasicAuth": true, - "useStoredPhNo": false, - "webhookURL": "https://trigger-sms.example.com/cometchat" + "useStoredPhNo": false, + "webhookURL": "https://trigger-sms.example.com/cometchat" + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "put": { + "tags": [ + "Notifications" + ], + "summary": "Update Custom Provider for SMS Notifications", + "description": "Updates the custom provider for SMS Notifications for a given app.", + "operationId": "notifications-update-sms-custom-provider", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomSMSProviderConfig" + } + } + } + }, + "responses": { + "200": { + "description": "Save the push notification's SMS custom provider", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "data": { + "basicAuthUsername": "user889", + "basicAuthPassword": "pass122", + "isEnabled": true, + "useBasicAuth": true, + "useStoredPhNo": false, + "webhookURL": "https://trigger-sms.example.com/cometchat" + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "delete": { + "tags": [ + "Notifications" + ], + "summary": "Delete the Custom Provider for SMS Notifications", + "description": "Deletes the custom provider for SMS Notifications for a given app.", + "operationId": "notifications-delete-sms-custom-provider", + "responses": { + "200": { + "description": "Delete push notification's SMS custom provider", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "data": { + "success": true + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + } + }, + "/notifications/email/v1/providers/custom": { + "get": { + "tags": [ + "Notifications" + ], + "summary": "Get Custom Provider for Email Notifications", + "description": "Fetches the custom provider for Email Notifications for a given app.", + "operationId": "notifications-list-email-custom-provider", + "responses": { + "200": { + "description": "A list of push notification's email custom provider", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "data": { + "basicAuthUsername": "user889", + "basicAuthPassword": "pass122", + "isEnabled": true, + "useBasicAuth": true, + "useStoredEmailID": false, + "webhookURL": "https://trigger-email.example.com/cometchat" + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "post": { + "tags": [ + "Notifications" + ], + "summary": "Save Custom Provider for Email Notifications", + "description": "Saves the custom provider for Email Notifications for a given app.", + "operationId": "notifications-save-email-custom-provider", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/CustomEmailProviderConfig" + }, + { + "required": [ + "isEnabled", + "useStoredEmailID", + "webhookURL", + "basicAuthUsername", + "basicAuthPassword", + "useBasicAuth" + ] + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "Save the push notification's SMS custom provider", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "data": { + "basicAuthUsername": "user889", + "basicAuthPassword": "pass122", + "isEnabled": true, + "useBasicAuth": true, + "useStoredEmailID": false, + "webhookURL": "https://trigger-email.example.com/cometchat" } } } @@ -12826,21 +13725,21 @@ "tags": [ "Notifications" ], - "summary": "Update Custom Provider for SMS Notifications", - "description": "Updates the custom provider for SMS Notifications for a given app.", - "operationId": "notifications-update-sms-custom-provider", + "summary": "Update Custom Provider for Email Notifications", + "description": "Updates the custom provider for Email Notifications for a given app.", + "operationId": "notifications-update-email-custom-provider", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CustomSMSProviderConfig" + "$ref": "#/components/schemas/CustomEmailProviderConfig" } } } }, "responses": { "200": { - "description": "Save the push notification's SMS custom provider", + "description": "Update the push notification's Email custom provider", "content": { "application/json": { "schema": { @@ -12852,8 +13751,8 @@ "basicAuthPassword": "pass122", "isEnabled": true, "useBasicAuth": true, - "useStoredPhNo": false, - "webhookURL": "https://trigger-sms.example.com/cometchat" + "useStoredEmailID": false, + "webhookURL": "https://trigger-email.example.com/cometchat" } } } @@ -12870,12 +13769,12 @@ "tags": [ "Notifications" ], - "summary": "Delete the Custom Provider for SMS Notifications", - "description": "Deletes the custom provider for SMS Notifications for a given app.", - "operationId": "notifications-delete-sms-custom-provider", + "summary": "Delete the Custom Provider for Email Notifications", + "description": "Deletes the custom provider for Email Notifications for a given app.", + "operationId": "notifications-delete-email-custom-provider", "responses": { "200": { - "description": "Delete push notification's SMS custom provider", + "description": "Delete push notification's Email custom provider", "content": { "application/json": { "schema": { @@ -12888,23 +13787,266 @@ } } } - } - }, - "security": [ + } + }, + "security": [ + { + "apiKey": [] + } + ] + } + }, + "/notifications/v1/logs": { + "get": { + "tags": [ + "Notifications" + ], + "summary": "Notifications logs", + "description": "Paginated API to fetch logs for notifications", + "operationId": "notifications-logs", + "parameters": [ + { + "name": "messageId", + "in": "query", + "description": "To filter based on the ID of message or reply.", + "required": false, + "schema": { + "type": "integer" + } + }, + { + "name": "reactionId", + "in": "query", + "description": "To filter based on the ID of the reaction added.", + "required": false, + "schema": { + "type": "integer" + } + }, + { + "name": "from", + "in": "query", + "description": "To get the logs for messages that are sent after the mentioned timestamp in milliseconds.", + "required": false, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "to", + "in": "query", + "description": "To get the logs for messages that are sent after the mentioned timestamp in milliseconds.", + "required": false, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "messageCategory", + "in": "query", + "description": "To filter logs based on the category of the message or reply. Values can be message, interactive.", + "required": false, + "schema": { + "type": "string", + "enum": [ + "message", + "interactive" + ] + } + }, + { + "name": "messageType", + "in": "query", + "description": "To filter logs based on the type of the message or reply. Values are based on the message category.", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "trigger", + "in": "query", + "description": "To filter based on the trigger value of the event that is responsible for triggering the notification.\nFor a message or a reply, the value of this field is after_message.\nFor message actions, the values are message_deleted or message_edited or message_reaction_added.\nFor default calling feature, the values are initiated, rejected, cancelled, unanswered.\nFor group events, the values are: after_group_joined, after_group_left, after_group_members_added, after_group_members_kicked, after_group_members_banned, after_group_members_unbanned, after_scope_changed.", + "required": false, + "schema": { + "type": "string", + "enum": [ + "after_message", + "message_deleted", + "message_edited", + "message_reaction_added", + "initiated", + "rejected", + "cancelled", + "unanswered", + "after_group_joined", + "after_group_left", + "after_group_members_added", + "after_group_members_kicked", + "after_group_members_banned", + "after_group_members_unbanned", + "after_scope_changed" + ] + } + }, + { + "name": "sender", + "in": "query", + "description": "To filter based on the sender of the message. This has to be uid.", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "reactionSender", + "in": "query", + "description": "To filter based on the user who reacted on a message.", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "receiver", + "in": "query", + "description": "To filter based on the receiver of a message. This can be uid or guid based on the receiverType.", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "receiverType", + "in": "query", + "description": "To filter based on the receiver's type. The value of this field can be user or group.", + "required": false, + "schema": { + "type": "string", + "enum": [ + "user", + "group" + ] + } + }, + { + "name": "reactionReceiver", + "in": "query", + "description": "To filter based on the user who is notified when a reaction is added.", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "member", + "in": "query", + "description": "To filter based on the user who is notified in a given group. This is only present when the receiverType is group.", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "channel", + "in": "query", + "description": "To filter based on whether the user was notified using push, email or sms notification.", + "required": false, + "schema": { + "type": "string", + "enum": [ + "push", + "email", + "sms" + ] + } + }, + { + "name": "provider", + "in": "query", + "description": "To filter based on the provider.\nFor channel as push, the value of this field can be fcm, apns, custom.\nFor channel as email, the value of this field can be sendgrid or custom.\nFor channel as sms, the value of this field can be twilio or custom.", + "required": false, + "schema": { + "type": "string", + "enum": [ + "fcm", + "apns", + "sendgrid", + "twilio", + "custom" + ] + } + }, + { + "name": "notificationTriggered", + "in": "query", + "description": "The value is true when the notification provider is triggered. If false, the notification was not triggered due to some preference that is mentioned in the reason field.", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "name": "reason", + "in": "query", + "description": "Available only when the value of notificationTriggered is false.\nThis contains the reason for not triggering the notification provider.\n\nTo filter logs using reason, use the following values: MESSAGES_PREFERENCE, REPLIES_PREFERENCE, MESSAGE_ACTIONS_PREFERENCE, REACTIONS_PREFERENCE, GROUP_ACTIONS_PREFERENCE, DND_PREFERENCE, MUTE_PREFERENCE, SCHEDULE_PREFERENCE, CALL_PREFERENCE, QUOTA_PREFERENCE, MISSING_EMAIL, MISSING_PHNO, INVALID_PUSH_PROVIDER_ID, TIMED_OUT, NOT_FOUND, TWILIO_CREATE_ERROR.", + "required": false, + "schema": { + "type": "string", + "enum": [ + "MESSAGES_PREFERENCE", + "REPLIES_PREFERENCE", + "MESSAGE_ACTIONS_PREFERENCE", + "REACTIONS_PREFERENCE", + "GROUP_ACTIONS_PREFERENCE", + "DND_PREFERENCE", + "MUTE_PREFERENCE", + "SCHEDULE_PREFERENCE", + "CALL_PREFERENCE", + "QUOTA_PREFERENCE", + "MISSING_EMAIL", + "MISSING_PHNO", + "INVALID_PUSH_PROVIDER_ID", + "TIMED_OUT", + "NOT_FOUND", + "TWILIO_CREATE_ERROR" + ] + } + }, { - "apiKey": [] + "name": "success", + "in": "query", + "description": "Available only when the value of notificationTriggered is true.\n\nTo filter based on whether the HTTP request to the provider was successful or not, true indicating that the provider returned success while false indicating that the provider returned an error.", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "name": "affix", + "in": "query", + "description": "To paginate over logs use the value of affix as prepend or append.", + "required": false, + "schema": { + "type": "string", + "enum": [ + "prepend", + "append" + ] + } + }, + { + "name": "logId", + "in": "query", + "description": "To be used with affix for pagination.", + "required": false, + "schema": { + "type": "string" + } } - ] - } - }, - "/notifications/email/v1/providers/custom": { - "get": { - "tags": [ - "Notifications" ], - "summary": "Get Custom Provider for Email Notifications", - "description": "Fetches the custom provider for Email Notifications for a given app.", - "operationId": "notifications-list-email-custom-provider", "responses": { "200": { "description": "A list of push notification's email custom provider", @@ -12914,13 +14056,76 @@ "type": "object" }, "example": { - "data": { - "basicAuthUsername": "user889", - "basicAuthPassword": "pass122", - "isEnabled": true, - "useBasicAuth": true, - "useStoredEmailID": false, - "webhookURL": "https://trigger-email.example.com/cometchat" + "data": [ + { + "_id": "67e3c56babf90e20e2652edb", + "processingStartedAtMS": 1742980459696, + "processingEndedAtMS": 1742980459738, + "totalProcessingTimeInMS": 42, + "component": "notifications-core", + "channel": "push", + "provider": "apns", + "messageId": 3939, + "reactionId": 69, + "trigger": "message_reaction_added", + "messageSentAtMS": 1742980459000, + "sender": "cometchat-uid-4", + "reactionSender": "cometchat-uid-1", + "receiver": "cometchat-guid-1", + "reactionReceiver": "g-muted-yes", + "receiverType": "group", + "member": "g-muted-yes", + "tokenType": "apns_ios_device", + "pushToken": "pushtoken123", + "providerId": "apns-provider", + "payload": { + "payload": { + "title": "cometchat-uid-1", + "body": "Reacted to your message: 😂", + "tag": "69", + "sender": "cometchat-uid-1", + "senderName": "cometchat-uid-1", + "receiver": "cometchat-guid-1", + "receiverName": "cometchat-guid-1", + "receiverType": "group", + "conversationId": "group_cometchat-guid-1", + "type": "chat", + "sessionId": null, + "callAction": null, + "callType": null, + "sentAt": null + }, + "contentAvailable": 1, + "mutableContent": 1, + "topic": "com.example.com", + "alert": { + "title": "cometchat-uid-1", + "body": "Reacted to your message: 😂" + }, + "priority": 10, + "pushType": "alert", + "sound": "default", + "collapseId": "69", + "expiry": 1742984059, + "type": "apns" + }, + "notificationTriggered": false, + "reason": "MUTE_PREFERENCE" + } + ], + "meta": { + "previous": { + "affix": "prepend", + "messageId": 3939 + }, + "current": { + "limit": 20, + "count": 20 + }, + "next": { + "affix": "append", + "messageId": 3939 + } } } } @@ -12932,54 +14137,74 @@ "apiKey": [] } ] - }, + } + }, + "/moderation/rules": { "post": { "tags": [ - "Notifications" + "Moderation" ], - "summary": "Save Custom Provider for Email Notifications", - "description": "Saves the custom provider for Email Notifications for a given app.", - "operationId": "notifications-save-email-custom-provider", + "summary": "Add Rule", + "description": "Create a new moderation rule to specify actions and conditions for detecting and handling inappropriate content.", + "operationId": "chat-api-create-rule", "requestBody": { "required": true, "content": { "application/json": { "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/CustomEmailProviderConfig" - }, - { - "required": [ - "isEnabled", - "useStoredEmailID", - "webhookURL", - "basicAuthUsername", - "basicAuthPassword", - "useBasicAuth" - ] - } - ] + "$ref": "#/components/schemas/ModerationRequestBody" } } } }, "responses": { "200": { - "description": "Save the push notification's SMS custom provider", + "description": "Created Rule", "content": { "application/json": { "schema": { + "properties": { + "data": { + "properties": { + "": { + "$ref": "#/components/schemas/ModerationData" + } + }, + "type": "object" + } + }, "type": "object" }, "example": { "data": { - "basicAuthUsername": "user889", - "basicAuthPassword": "pass122", - "isEnabled": true, - "useBasicAuth": true, - "useStoredEmailID": false, - "webhookURL": "https://trigger-email.example.com/cometchat" + "id": "moderation-test", + "name": "Video Moderation", + "description": "AI-powered video moderation to detect unsafe content.", + "enabled": true, + "conditions": [ + { + "id": 1, + "isKeywordsReferencePresent": false, + "isMediaPresent": true, + "entity": "message", + "operand": "image", + "category": "word", + "operator": "contains", + "value": [ + "violence_greaterThan_30" + ], + "message": [ + "Image contains violence with confidence greater than 30" + ] + } + ], + "action": [ + "blockMessage" + ], + "active": true, + "createdAt": 1720003247, + "updatedAt": 1720003247, + "revisionId": "253179cf5f665257_moderation-test_1" } } } @@ -12992,68 +14217,301 @@ } ] }, - "put": { + "get": { "tags": [ - "Notifications" + "Moderation" ], - "summary": "Update Custom Provider for Email Notifications", - "description": "Updates the custom provider for Email Notifications for a given app.", - "operationId": "notifications-update-email-custom-provider", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/CustomEmailProviderConfig" - } - } - } - }, - "responses": { - "200": { - "description": "Update the push notification's Email custom provider", - "content": { - "application/json": { - "schema": { - "type": "object" - }, - "example": { - "data": { - "basicAuthUsername": "user889", - "basicAuthPassword": "pass122", - "isEnabled": true, - "useBasicAuth": true, - "useStoredEmailID": false, - "webhookURL": "https://trigger-email.example.com/cometchat" - } - } - } - } - } - }, - "security": [ + "summary": "List Rules", + "description": "Retrieve a list of all moderation rules.", + "operationId": "chat-api-list-rules", + "parameters": [ { - "apiKey": [] + "name": "limit", + "in": "query", + "description": "The number of records to fetch.", + "schema": { + "type": "string" + } } - ] - }, - "delete": { - "tags": [ - "Notifications" ], - "summary": "Delete the Custom Provider for Email Notifications", - "description": "Deletes the custom provider for Email Notifications for a given app.", - "operationId": "notifications-delete-email-custom-provider", "responses": { "200": { - "description": "Delete push notification's Email custom provider", + "description": "List Rule", "content": { "application/json": { "schema": { + "properties": { + "data": { + "properties": { + "": { + "$ref": "#/components/schemas/webhookSchema" + } + }, + "type": "object" + } + }, "type": "object" }, "example": { - "data": { - "success": true + "data": [ + { + "id": "moderation-test", + "name": "Video Moderation", + "description": "AI-powered video moderation to detect unsafe content.", + "enabled": true, + "conditions": [ + { + "id": 1, + "isKeywordsReferencePresent": false, + "isMediaPresent": true, + "entity": "message", + "operand": "image", + "category": "word", + "operator": "contains", + "value": [ + "violence_greaterThan_30" + ], + "message": [ + "Image contains violence with confidence greater than 30" + ] + } + ], + "action": [ + "blockMessage" + ], + "active": true, + "createdAt": 1720003247, + "updatedAt": 1720003247, + "revisionId": "253179cf5f665257_moderation-test_1" + }, + { + "id": "video-moderation1", + "name": "Video Moderation", + "description": "AI-powered video moderation to detect unsafe content.", + "enabled": true, + "conditions": [ + { + "id": 1, + "isKeywordsReferencePresent": false, + "isMediaPresent": true, + "entity": "message", + "operand": "image", + "category": "word", + "operator": "contains", + "value": [ + "violence_greaterThan_30" + ], + "message": [ + "Image contains violence with confidence greater than 30" + ] + } + ], + "action": [ + "blockMessage" + ], + "active": true, + "createdAt": 1720000488, + "updatedAt": 1720000488, + "revisionId": "253179cf5f665257_video-moderation1_1" + }, + { + "id": "text-profanity-filter", + "name": "Text Profanity filter", + "description": "Detect and censor profanity in text messages.", + "enabled": true, + "conditions": [ + { + "id": 1, + "isKeywordsReferencePresent": true, + "isMediaPresent": false, + "entity": "message", + "operand": "text", + "category": "word", + "operator": "contains", + "value": [ + "profanity-list" + ] + } + ], + "action": [ + "blockMessage" + ], + "active": true, + "createdAt": 1718355386, + "updatedAt": 1720006272, + "revisionId": "253157108b5294c4_profanity-filter_25", + "default": true + }, + { + "id": "image-moderation", + "name": "AI Image Moderation", + "description": "AI-powered image moderation to detect unsafe content.", + "enabled": false, + "conditions": [ + { + "id": 1, + "isKeywordsReferencePresent": false, + "isMediaPresent": true, + "entity": "message", + "operand": "image", + "category": "word", + "operator": "contains", + "value": [ + "AnyOf_greaterThan_30" + ] + } + ], + "action": [ + "blockMessage" + ], + "active": true, + "createdAt": 1718350200, + "updatedAt": 1719932600, + "revisionId": "253157108b5294c4_image-moderation_11", + "default": true + }, + { + "id": "video-moderation", + "name": "AI Video Moderation", + "description": "AI-powered video moderation to detect unsafe content.", + "enabled": false, + "conditions": [ + { + "id": 1, + "isKeywordsReferencePresent": false, + "isMediaPresent": true, + "entity": "message", + "operand": "video", + "category": "word", + "operator": "contains", + "value": [ + "AnyOf_greaterThan_30" + ] + } + ], + "action": [ + "dropMessage" + ], + "active": true, + "createdAt": 1718350199, + "updatedAt": 1720006008, + "revisionId": "253157108b5294c4_video-moderation_10", + "default": true + }, + { + "id": "custom-profanity-filter", + "name": "Custom Profanity filter", + "description": "Detect and censor profanity in custom messages.", + "enabled": false, + "conditions": [ + { + "id": 1, + "isListReferencePresent": true, + "isMediaPresent": false, + "entity": "message", + "operand": "custom", + "category": "word", + "operator": "contains", + "value": [ + "profanity-list" + ] + } + ], + "action": [ + "dropMessage" + ], + "active": true, + "createdAt": 1718341200, + "updatedAt": 1719819136, + "revisionId": "253157108b5294c4_profanity-filter_8", + "default": true + }, + { + "id": "contact_details_filter", + "name": "Contact details filter", + "description": "Identifies and removes phone numbers from text", + "enabled": false, + "conditions": [ + { + "id": 1, + "isKeywordsReferencePresent": false, + "isMediaPresent": false, + "entity": "message", + "operand": "text", + "category": "pattern", + "operator": "contains", + "value": [ + "\\\\+?(\\\\d{1,3})?{-.\\\\s}?\\\\(?\\\\d{1,4}?\\\\)?{-.\\\\s}?\\\\d{1,4}{-.\\\\s}?\\\\d{1,4}{-.\\\\s}?\\\\d{1,9}" + ] + }, + { + "id": 2, + "isKeywordsReferencePresent": false, + "isMediaPresent": false, + "entity": "message", + "operand": "custom", + "category": "pattern", + "operator": "contains", + "value": [ + "\\\\+?(\\\\d{1,3})?{-.\\\\s}?\\\\(?\\\\d{1,4}?\\\\)?{-.\\\\s}?\\\\d{1,4}{-.\\\\s}?\\\\d{1,4}{-.\\\\s}?\\\\d{1,9}" + ] + } + ], + "action": [ + "blockMessage" + ], + "active": true, + "createdAt": 1718186338, + "updatedAt": 1719836048, + "revisionId": "2531882e5e289115_contact_details_filter_3", + "default": true + }, + { + "id": "email_filter", + "name": "Email filter", + "description": "Identify and remove email address from messages", + "enabled": false, + "conditions": [ + { + "id": 1, + "isKeywordsReferencePresent": false, + "isMediaPresent": false, + "entity": "message", + "operand": "text", + "category": "pattern", + "operator": "contains", + "value": [ + "^{a-zA-Z0-9._%+-}+@{a-zA-Z0-9.-}+\\\\.{a-zA-Z}{2,}$" + ] + }, + { + "id": 2, + "isKeywordsReferencePresent": false, + "isMediaPresent": false, + "entity": "message", + "operand": "custom", + "category": "pattern", + "operator": "contains", + "value": [ + "^{a-zA-Z0-9._%+-}+@{a-zA-Z0-9.-}+\\\\.{a-zA-Z}{2,}$" + ] + } + ], + "action": [ + "blockMessage" + ], + "active": true, + "createdAt": 1718099938, + "updatedAt": 1719836049, + "revisionId": "2531882e5e289115_contact_email_filter_5", + "default": true + } + ], + "meta": { + "current": { + "limit": 50, + "count": 8 + } } } } @@ -13067,336 +14525,83 @@ ] } }, - "/notifications/v1/logs": { + "/moderation/rules/{ruleId}": { "get": { - "tags": [ - "Notifications" - ], - "summary": "Notifications logs", - "description": "Paginated API to fetch logs for notifications", - "operationId": "notifications-logs", - "parameters": [ - { - "name": "messageId", - "in": "query", - "description": "To filter based on the ID of message or reply.", - "required": false, - "schema": { - "type": "integer" - } - }, - { - "name": "reactionId", - "in": "query", - "description": "To filter based on the ID of the reaction added.", - "required": false, - "schema": { - "type": "integer" - } - }, - { - "name": "from", - "in": "query", - "description": "To get the logs for messages that are sent after the mentioned timestamp in milliseconds.", - "required": false, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "to", - "in": "query", - "description": "To get the logs for messages that are sent after the mentioned timestamp in milliseconds.", - "required": false, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "messageCategory", - "in": "query", - "description": "To filter logs based on the category of the message or reply. Values can be message, interactive.", - "required": false, - "schema": { - "type": "string", - "enum": [ - "message", - "interactive" - ] - } - }, - { - "name": "messageType", - "in": "query", - "description": "To filter logs based on the type of the message or reply. Values are based on the message category.", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "trigger", - "in": "query", - "description": "To filter based on the trigger value of the event that is responsible for triggering the notification.\nFor a message or a reply, the value of this field is after_message.\nFor message actions, the values are message_deleted or message_edited or message_reaction_added.\nFor default calling feature, the values are initiated, rejected, cancelled, unanswered.\nFor group events, the values are: after_group_joined, after_group_left, after_group_members_added, after_group_members_kicked, after_group_members_banned, after_group_members_unbanned, after_scope_changed.", - "required": false, - "schema": { - "type": "string", - "enum": [ - "after_message", - "message_deleted", - "message_edited", - "message_reaction_added", - "initiated", - "rejected", - "cancelled", - "unanswered", - "after_group_joined", - "after_group_left", - "after_group_members_added", - "after_group_members_kicked", - "after_group_members_banned", - "after_group_members_unbanned", - "after_scope_changed" - ] - } - }, - { - "name": "sender", - "in": "query", - "description": "To filter based on the sender of the message. This has to be uid.", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "reactionSender", - "in": "query", - "description": "To filter based on the user who reacted on a message.", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "receiver", - "in": "query", - "description": "To filter based on the receiver of a message. This can be uid or guid based on the receiverType.", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "receiverType", - "in": "query", - "description": "To filter based on the receiver's type. The value of this field can be user or group.", - "required": false, - "schema": { - "type": "string", - "enum": [ - "user", - "group" - ] - } - }, - { - "name": "reactionReceiver", - "in": "query", - "description": "To filter based on the user who is notified when a reaction is added.", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "member", - "in": "query", - "description": "To filter based on the user who is notified in a given group. This is only present when the receiverType is group.", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "channel", - "in": "query", - "description": "To filter based on whether the user was notified using push, email or sms notification.", - "required": false, - "schema": { - "type": "string", - "enum": [ - "push", - "email", - "sms" - ] - } - }, - { - "name": "provider", - "in": "query", - "description": "To filter based on the provider.\nFor channel as push, the value of this field can be fcm, apns, custom.\nFor channel as email, the value of this field can be sendgrid or custom.\nFor channel as sms, the value of this field can be twilio or custom.", - "required": false, - "schema": { - "type": "string", - "enum": [ - "fcm", - "apns", - "sendgrid", - "twilio", - "custom" - ] - } - }, - { - "name": "notificationTriggered", - "in": "query", - "description": "The value is true when the notification provider is triggered. If false, the notification was not triggered due to some preference that is mentioned in the reason field.", - "required": false, - "schema": { - "type": "boolean" - } - }, - { - "name": "reason", - "in": "query", - "description": "Available only when the value of notificationTriggered is false.\nThis contains the reason for not triggering the notification provider.\n\nTo filter logs using reason, use the following values: MESSAGES_PREFERENCE, REPLIES_PREFERENCE, MESSAGE_ACTIONS_PREFERENCE, REACTIONS_PREFERENCE, GROUP_ACTIONS_PREFERENCE, DND_PREFERENCE, MUTE_PREFERENCE, SCHEDULE_PREFERENCE, CALL_PREFERENCE, QUOTA_PREFERENCE, MISSING_EMAIL, MISSING_PHNO, INVALID_PUSH_PROVIDER_ID, TIMED_OUT, NOT_FOUND, TWILIO_CREATE_ERROR.", - "required": false, - "schema": { - "type": "string", - "enum": [ - "MESSAGES_PREFERENCE", - "REPLIES_PREFERENCE", - "MESSAGE_ACTIONS_PREFERENCE", - "REACTIONS_PREFERENCE", - "GROUP_ACTIONS_PREFERENCE", - "DND_PREFERENCE", - "MUTE_PREFERENCE", - "SCHEDULE_PREFERENCE", - "CALL_PREFERENCE", - "QUOTA_PREFERENCE", - "MISSING_EMAIL", - "MISSING_PHNO", - "INVALID_PUSH_PROVIDER_ID", - "TIMED_OUT", - "NOT_FOUND", - "TWILIO_CREATE_ERROR" - ] - } - }, - { - "name": "success", - "in": "query", - "description": "Available only when the value of notificationTriggered is true.\n\nTo filter based on whether the HTTP request to the provider was successful or not, true indicating that the provider returned success while false indicating that the provider returned an error.", - "required": false, - "schema": { - "type": "boolean" - } - }, - { - "name": "affix", - "in": "query", - "description": "To paginate over logs use the value of affix as prepend or append.", - "required": false, - "schema": { - "type": "string", - "enum": [ - "prepend", - "append" - ] - } - }, + "tags": [ + "Moderation" + ], + "summary": "Get Rule", + "description": "Retrieve details of a specific moderation rule by its ID.", + "operationId": "chat-api-get-rule", + "parameters": [ { - "name": "logId", - "in": "query", - "description": "To be used with affix for pagination.", - "required": false, - "schema": { - "type": "string" - } + "$ref": "#/components/parameters/ruleId" } ], "responses": { "200": { - "description": "A list of push notification's email custom provider", + "description": "Get Rule", "content": { "application/json": { "schema": { + "properties": { + "data": { + "properties": { + "": { + "$ref": "#/components/schemas/webhookSchema" + } + }, + "type": "object" + } + }, "type": "object" }, "example": { - "data": [ - { - "_id": "67e3c56babf90e20e2652edb", - "processingStartedAtMS": 1742980459696, - "processingEndedAtMS": 1742980459738, - "totalProcessingTimeInMS": 42, - "component": "notifications-core", - "channel": "push", - "provider": "apns", - "messageId": 3939, - "reactionId": 69, - "trigger": "message_reaction_added", - "messageSentAtMS": 1742980459000, - "sender": "cometchat-uid-4", - "reactionSender": "cometchat-uid-1", - "receiver": "cometchat-guid-1", - "reactionReceiver": "g-muted-yes", - "receiverType": "group", - "member": "g-muted-yes", - "tokenType": "apns_ios_device", - "pushToken": "pushtoken123", - "providerId": "apns-provider", - "payload": { - "payload": { - "title": "cometchat-uid-1", - "body": "Reacted to your message: 😂", - "tag": "69", - "sender": "cometchat-uid-1", - "senderName": "cometchat-uid-1", - "receiver": "cometchat-guid-1", - "receiverName": "cometchat-guid-1", - "receiverType": "group", - "conversationId": "group_cometchat-guid-1", - "type": "chat", - "sessionId": null, - "callAction": null, - "callType": null, - "sentAt": null - }, - "contentAvailable": 1, - "mutableContent": 1, - "topic": "com.example.com", - "alert": { - "title": "cometchat-uid-1", - "body": "Reacted to your message: 😂" - }, - "priority": 10, - "pushType": "alert", - "sound": "default", - "collapseId": "69", - "expiry": 1742984059, - "type": "apns" - }, - "notificationTriggered": false, - "reason": "MUTE_PREFERENCE" - } - ], - "meta": { - "previous": { - "affix": "prepend", - "messageId": 3939 - }, - "current": { - "limit": 20, - "count": 20 - }, - "next": { - "affix": "append", - "messageId": 3939 - } + "data": { + "id": "profanity-list", + "name": "Profane Words", + "category": "word", + "isCSV": false, + "searchTerms": [ + "fuck", + "damn", + "shit", + "cunt", + "nigga", + "nigger", + "wanker", + "cunt", + "fag", + "shithead", + "jizz", + "hellbitch", + "retard", + "cocksucker", + "cock", + "kill", + "kike", + "twat", + "bastard", + "death", + "asshole", + "wop", + "scumbag", + "penis", + "murder", + "dick", + "gook", + "vagina", + "rape", + "bastard", + "spic", + "spunk", + "beat" + ], + "createdAt": 1718354412, + "updatedAt": 1718354412, + "revisionId": "253157108b5294c4_profanity-list_1", + "active": true, + "default": true } } } @@ -13408,16 +14613,19 @@ "apiKey": [] } ] - } - }, - "/moderation/rules": { - "post": { + }, + "put": { "tags": [ "Moderation" ], - "summary": "Add Rule", - "description": "Create a new moderation rule to specify actions and conditions for detecting and handling inappropriate content.", - "operationId": "chat-api-create-rule", + "summary": "Update Rule", + "description": "Update an existing moderation rule with new actions or conditions.", + "operationId": "chat-api-update-rule", + "parameters": [ + { + "$ref": "#/components/parameters/ruleId" + } + ], "requestBody": { "required": true, "content": { @@ -13430,7 +14638,7 @@ }, "responses": { "200": { - "description": "Created Rule", + "description": "Update Rule", "content": { "application/json": { "schema": { @@ -13438,7 +14646,7 @@ "data": { "properties": { "": { - "$ref": "#/components/schemas/ModerationData" + "$ref": "#/components/schemas/webhookSchema" } }, "type": "object" @@ -13472,10 +14680,120 @@ "action": [ "blockMessage" ], - "active": true, - "createdAt": 1720003247, - "updatedAt": 1720003247, - "revisionId": "253179cf5f665257_moderation-test_1" + "active": true, + "createdAt": 1720003247, + "updatedAt": 1720003247, + "revisionId": "253179cf5f665257_moderation-test_1" + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "delete": { + "tags": [ + "Moderation" + ], + "summary": "Remove rule", + "description": "Delete a specific moderation rule by its ID.", + "operationId": "chat-api-delete-rule", + "parameters": [ + { + "$ref": "#/components/parameters/ruleId" + } + ], + "responses": { + "200": { + "description": "Delete Rule", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "properties": { + "": { + "$ref": "#/components/schemas/webhookSchema" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "success": true, + "message": "Rule with id moderation-test has been deleted successfully." + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + } + }, + "/moderation/keywords": { + "post": { + "tags": [ + "Moderation" + ], + "summary": "Add Keywords", + "description": "Create a new keyword list for moderation.", + "operationId": "chat-api-create-rule-keyword", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/KeywordList" + } + } + } + }, + "responses": { + "200": { + "description": "Created Keyword", + "content": { + "application/json": { + "schema": { + "properties": { + "data": { + "properties": { + "": { + "$ref": "#/components/schemas/webhookSchema" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": { + "id": "profane-word-list-1", + "name": "profane word list", + "description": "Profane word list", + "category": "word", + "isCSV": true, + "searchTerms": [ + "\"a\"", + "\"b\"", + "\"c\"" + ], + "createdAt": 1720023805, + "updatedAt": 1720023805, + "revisionId": "253179cf5f665257_profane-word-list-1_1", + "active": true } } } @@ -13492,296 +14810,103 @@ "tags": [ "Moderation" ], - "summary": "List Rules", - "description": "Retrieve a list of all moderation rules.", - "operationId": "chat-api-list-rules", - "parameters": [ - { - "name": "limit", - "in": "query", - "description": "The number of records to fetch.", - "schema": { - "type": "string" - } - } - ], + "summary": "List keywords", + "description": "Fetches all the keywords.", + "operationId": "chat-api-list-rule-keywords", "responses": { "200": { - "description": "List Rule", + "description": "List Keywords", "content": { "application/json": { "schema": { "properties": { "data": { - "properties": { - "": { - "$ref": "#/components/schemas/webhookSchema" - } - }, - "type": "object" - } - }, - "type": "object" - }, - "example": { - "data": [ - { - "id": "moderation-test", - "name": "Video Moderation", - "description": "AI-powered video moderation to detect unsafe content.", - "enabled": true, - "conditions": [ - { - "id": 1, - "isKeywordsReferencePresent": false, - "isMediaPresent": true, - "entity": "message", - "operand": "image", - "category": "word", - "operator": "contains", - "value": [ - "violence_greaterThan_30" - ], - "message": [ - "Image contains violence with confidence greater than 30" - ] - } - ], - "action": [ - "blockMessage" - ], - "active": true, - "createdAt": 1720003247, - "updatedAt": 1720003247, - "revisionId": "253179cf5f665257_moderation-test_1" - }, - { - "id": "video-moderation1", - "name": "Video Moderation", - "description": "AI-powered video moderation to detect unsafe content.", - "enabled": true, - "conditions": [ - { - "id": 1, - "isKeywordsReferencePresent": false, - "isMediaPresent": true, - "entity": "message", - "operand": "image", - "category": "word", - "operator": "contains", - "value": [ - "violence_greaterThan_30" - ], - "message": [ - "Image contains violence with confidence greater than 30" - ] - } - ], - "action": [ - "blockMessage" - ], - "active": true, - "createdAt": 1720000488, - "updatedAt": 1720000488, - "revisionId": "253179cf5f665257_video-moderation1_1" - }, - { - "id": "text-profanity-filter", - "name": "Text Profanity filter", - "description": "Detect and censor profanity in text messages.", - "enabled": true, - "conditions": [ - { - "id": 1, - "isKeywordsReferencePresent": true, - "isMediaPresent": false, - "entity": "message", - "operand": "text", - "category": "word", - "operator": "contains", - "value": [ - "profanity-list" - ] - } - ], - "action": [ - "blockMessage" - ], - "active": true, - "createdAt": 1718355386, - "updatedAt": 1720006272, - "revisionId": "253157108b5294c4_profanity-filter_25", - "default": true - }, - { - "id": "image-moderation", - "name": "AI Image Moderation", - "description": "AI-powered image moderation to detect unsafe content.", - "enabled": false, - "conditions": [ - { - "id": 1, - "isKeywordsReferencePresent": false, - "isMediaPresent": true, - "entity": "message", - "operand": "image", - "category": "word", - "operator": "contains", - "value": [ - "AnyOf_greaterThan_30" - ] - } - ], - "action": [ - "blockMessage" - ], - "active": true, - "createdAt": 1718350200, - "updatedAt": 1719932600, - "revisionId": "253157108b5294c4_image-moderation_11", - "default": true - }, - { - "id": "video-moderation", - "name": "AI Video Moderation", - "description": "AI-powered video moderation to detect unsafe content.", - "enabled": false, - "conditions": [ - { - "id": 1, - "isKeywordsReferencePresent": false, - "isMediaPresent": true, - "entity": "message", - "operand": "video", - "category": "word", - "operator": "contains", - "value": [ - "AnyOf_greaterThan_30" - ] - } - ], - "action": [ - "dropMessage" - ], - "active": true, - "createdAt": 1718350199, - "updatedAt": 1720006008, - "revisionId": "253157108b5294c4_video-moderation_10", - "default": true - }, - { - "id": "custom-profanity-filter", - "name": "Custom Profanity filter", - "description": "Detect and censor profanity in custom messages.", - "enabled": false, - "conditions": [ - { - "id": 1, - "isListReferencePresent": true, - "isMediaPresent": false, - "entity": "message", - "operand": "custom", - "category": "word", - "operator": "contains", - "value": [ - "profanity-list" - ] - } - ], - "action": [ - "dropMessage" - ], - "active": true, - "createdAt": 1718341200, - "updatedAt": 1719819136, - "revisionId": "253157108b5294c4_profanity-filter_8", - "default": true - }, - { - "id": "contact_details_filter", - "name": "Contact details filter", - "description": "Identifies and removes phone numbers from text", - "enabled": false, - "conditions": [ - { - "id": 1, - "isKeywordsReferencePresent": false, - "isMediaPresent": false, - "entity": "message", - "operand": "text", - "category": "pattern", - "operator": "contains", - "value": [ - "\\\\+?(\\\\d{1,3})?{-.\\\\s}?\\\\(?\\\\d{1,4}?\\\\)?{-.\\\\s}?\\\\d{1,4}{-.\\\\s}?\\\\d{1,4}{-.\\\\s}?\\\\d{1,9}" - ] - }, - { - "id": 2, - "isKeywordsReferencePresent": false, - "isMediaPresent": false, - "entity": "message", - "operand": "custom", - "category": "pattern", - "operator": "contains", - "value": [ - "\\\\+?(\\\\d{1,3})?{-.\\\\s}?\\\\(?\\\\d{1,4}?\\\\)?{-.\\\\s}?\\\\d{1,4}{-.\\\\s}?\\\\d{1,4}{-.\\\\s}?\\\\d{1,9}" - ] + "properties": { + "": { + "$ref": "#/components/schemas/webhookSchema" } + }, + "type": "object" + } + }, + "type": "object" + }, + "example": { + "data": [ + { + "_id": "66857afdb4bf371ddfba853b", + "id": "profane-word-list-1", + "appId": "253179cf5f665257", + "name": "profane word list", + "description": "Profane word list", + "category": "word", + "isCSV": true, + "searchTerms": [ + "\"a\"", + "\"b\"", + "\"c\"" ], - "action": [ - "blockMessage" - ], + "createdAt": 1720023805, + "updatedAt": 1720023805, + "revisionId": "253179cf5f665257_profane-word-list-1_1", "active": true, - "createdAt": 1718186338, - "updatedAt": 1719836048, - "revisionId": "2531882e5e289115_contact_details_filter_3", - "default": true + "__v": 0 }, { - "id": "email_filter", - "name": "Email filter", - "description": "Identify and remove email address from messages", - "enabled": false, - "conditions": [ - { - "id": 1, - "isKeywordsReferencePresent": false, - "isMediaPresent": false, - "entity": "message", - "operand": "text", - "category": "pattern", - "operator": "contains", - "value": [ - "^{a-zA-Z0-9._%+-}+@{a-zA-Z0-9.-}+\\\\.{a-zA-Z}{2,}$" - ] - }, - { - "id": 2, - "isKeywordsReferencePresent": false, - "isMediaPresent": false, - "entity": "message", - "operand": "custom", - "category": "pattern", - "operator": "contains", - "value": [ - "^{a-zA-Z0-9._%+-}+@{a-zA-Z0-9.-}+\\\\.{a-zA-Z}{2,}$" - ] - } - ], - "action": [ - "blockMessage" + "_id": "666c01eccfe97336757fb611", + "id": "profanity-list", + "name": "Profane Words", + "category": "word", + "isCSV": false, + "searchTerms": [ + "fuck", + "nigger", + "fuck", + "nigger", + "wanker", + "cunt", + "damn", + "shit", + "fag", + "shithead", + "jizz", + "hellbitch", + "retard", + "cocksucker", + "cock", + "kill", + "cunt", + "kike", + "twat", + "bastard", + "death", + "asshole", + "wop", + "scumbag", + "penis", + "murder", + "dick", + "gook", + "vagina", + "rape", + "bastard", + "spic", + "spunk", + "beat" ], + "createdAt": 1718354412, + "updatedAt": 1718354412, + "revisionId": "253157108b5294c4_profanity-list_1", "active": true, - "createdAt": 1718099938, - "updatedAt": 1719836049, - "revisionId": "2531882e5e289115_contact_email_filter_5", - "default": true + "__v": 0, + "default": true, + "appId": "default" } ], "meta": { "current": { - "limit": 50, - "count": 8 + "limit": 10, + "count": 2 } } } @@ -13796,22 +14921,22 @@ ] } }, - "/moderation/rules/{ruleId}": { + "/moderation/keywords/{keywordId}": { "get": { "tags": [ "Moderation" ], - "summary": "Get Rule", - "description": "Retrieve details of a specific moderation rule by its ID.", - "operationId": "chat-api-get-rule", + "summary": "Get keyword", + "description": "Retrieve details of a specific keyword list by its ID.", + "operationId": "chat-api-get-rule-keyword", "parameters": [ { - "$ref": "#/components/parameters/ruleId" + "$ref": "#/components/parameters/keywordId" } ], "responses": { "200": { - "description": "Get Rule", + "description": "Get Keyword", "content": { "application/json": { "schema": { @@ -13835,13 +14960,13 @@ "isCSV": false, "searchTerms": [ "fuck", - "damn", - "shit", - "cunt", - "nigga", + "nigger", + "fuck", "nigger", "wanker", "cunt", + "damn", + "shit", "fag", "shithead", "jizz", @@ -13850,6 +14975,7 @@ "cocksucker", "cock", "kill", + "cunt", "kike", "twat", "bastard", @@ -13889,27 +15015,26 @@ "tags": [ "Moderation" ], - "summary": "Update Rule", - "description": "Update an existing moderation rule with new actions or conditions.", - "operationId": "chat-api-update-rule", + "summary": "Update keyword", + "description": "Update an existing keyword list.", + "operationId": "chat-api-update-rule-keyword", "parameters": [ { - "$ref": "#/components/parameters/ruleId" + "$ref": "#/components/parameters/keywordId" } ], "requestBody": { - "required": true, "content": { - "application/json": { + "multipart/form-data": { "schema": { - "$ref": "#/components/schemas/ModerationRequestBody" + "$ref": "#/components/schemas/KeywordList" } } } }, "responses": { "200": { - "description": "Update Rule", + "description": "Update Keyword", "content": { "application/json": { "schema": { @@ -13927,34 +15052,51 @@ }, "example": { "data": { - "id": "moderation-test", - "name": "Video Moderation", - "description": "AI-powered video moderation to detect unsafe content.", - "enabled": true, - "conditions": [ - { - "id": 1, - "isKeywordsReferencePresent": false, - "isMediaPresent": true, - "entity": "message", - "operand": "image", - "category": "word", - "operator": "contains", - "value": [ - "violence_greaterThan_30" - ], - "message": [ - "Image contains violence with confidence greater than 30" - ] - } - ], - "action": [ - "blockMessage" + "id": "profanity-list", + "name": "Profane Words", + "category": "word", + "isCSV": false, + "searchTerms": [ + "fuck", + "nigger", + "fuck", + "nigger", + "wanker", + "cunt", + "damn", + "shit", + "fag", + "shithead", + "jizz", + "hellbitch", + "retard", + "cocksucker", + "cock", + "kill", + "cunt", + "kike", + "twat", + "bastard", + "death", + "asshole", + "wop", + "scumbag", + "penis", + "murder", + "dick", + "gook", + "vagina", + "rape", + "bastard", + "spic", + "spunk", + "beat" ], + "createdAt": 1718354412, + "updatedAt": 1718354412, + "revisionId": "253157108b5294c4_profanity-list_1", "active": true, - "createdAt": 1720003247, - "updatedAt": 1720003247, - "revisionId": "253179cf5f665257_moderation-test_1" + "default": true } } } @@ -13971,17 +15113,17 @@ "tags": [ "Moderation" ], - "summary": "Remove rule", - "description": "Delete a specific moderation rule by its ID.", - "operationId": "chat-api-delete-rule", + "summary": "Remove keyword", + "description": "Delete a keyword list by its ID.", + "operationId": "chat-api-delete-rule-keyword", "parameters": [ { - "$ref": "#/components/parameters/ruleId" + "$ref": "#/components/parameters/keywordId" } ], "responses": { "200": { - "description": "Delete Rule", + "description": "Delete Keyword", "content": { "application/json": { "schema": { @@ -14000,7 +15142,7 @@ "example": { "data": { "success": true, - "message": "Rule with id moderation-test has been deleted successfully." + "message": "Keyword with id profanity-list has been deleted successfully." } } } @@ -14011,29 +15153,25 @@ { "apiKey": [] } - ] - } - }, - "/moderation/keywords": { - "post": { - "tags": [ - "Moderation" - ], - "summary": "Add Keywords", - "description": "Create a new keyword list for moderation.", - "operationId": "chat-api-create-rule-keyword", - "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "$ref": "#/components/schemas/KeywordList" - } - } - } - }, + ] + } + }, + "/moderation/rules/{ruleId}/revisions": { + "get": { + "tags": [ + "Moderation" + ], + "summary": "Get Rule Revisions", + "description": "Fetches a rule's revisions.", + "operationId": "chat-api-list-rule-revisions", + "parameters": [ + { + "$ref": "#/components/parameters/ruleId" + } + ], "responses": { "200": { - "description": "Created Keyword", + "description": "List Rule revisions", "content": { "application/json": { "schema": { @@ -14050,21 +15188,70 @@ "type": "object" }, "example": { - "data": { - "id": "profane-word-list-1", - "name": "profane word list", - "description": "Profane word list", - "category": "word", - "isCSV": true, - "searchTerms": [ - "\"a\"", - "\"b\"", - "\"c\"" - ], - "createdAt": 1720023805, - "updatedAt": 1720023805, - "revisionId": "253179cf5f665257_profane-word-list-1_1", - "active": true + "data": [ + { + "id": "moderation-test", + "name": "Video Moderation", + "description": "AI-powered video moderation to detect unsafe content.", + "enabled": true, + "conditions": [ + { + "id": 1, + "isKeywordsReferencePresent": false, + "isMediaPresent": false, + "entity": "message", + "operand": "text", + "category": "word", + "operator": "equals", + "value": [ + "paris" + ] + } + ], + "action": [ + "blockMessage" + ], + "active": true, + "createdAt": 1720011899, + "updatedAt": 1720011905, + "revisionId": "253179cf5f665257_moderation-test_2" + }, + { + "id": "moderation-test", + "name": "Video Moderation", + "description": "AI-powered video moderation to detect unsafe content.", + "enabled": true, + "conditions": [ + { + "id": 1, + "isKeywordsReferencePresent": false, + "isMediaPresent": true, + "entity": "message", + "operand": "image", + "category": "word", + "operator": "contains", + "value": [ + "violence_greaterThan_30" + ], + "message": [ + "Image contains violence with confidence greater than 30" + ] + } + ], + "action": [ + "blockMessage" + ], + "active": false, + "createdAt": 1720011899, + "updatedAt": 1720011899, + "revisionId": "253179cf5f665257_moderation-test_1" + } + ], + "meta": { + "current": { + "limit": 10, + "count": 2 + } } } } @@ -14076,17 +15263,19 @@ "apiKey": [] } ] - }, + } + }, + "/moderation/blocked-messages": { "get": { "tags": [ "Moderation" ], - "summary": "List keywords", - "description": "Fetches all the keywords.", - "operationId": "chat-api-list-rule-keywords", + "summary": "List Blocked Messages", + "description": "Lists the messages blocked by the moderation service.", + "operationId": "chat-api-list-moderation-blocked-messages", "responses": { "200": { - "description": "List Keywords", + "description": "List Blocked Messages", "content": { "application/json": { "schema": { @@ -14105,79 +15294,90 @@ "example": { "data": [ { - "_id": "66857afdb4bf371ddfba853b", - "id": "profane-word-list-1", - "appId": "253179cf5f665257", - "name": "profane word list", - "description": "Profane word list", - "category": "word", - "isCSV": true, - "searchTerms": [ - "\"a\"", - "\"b\"", - "\"c\"" - ], - "createdAt": 1720023805, - "updatedAt": 1720023805, - "revisionId": "253179cf5f665257_profane-word-list-1_1", - "active": true, - "__v": 0 - }, - { - "_id": "666c01eccfe97336757fb611", - "id": "profanity-list", - "name": "Profane Words", - "category": "word", - "isCSV": false, - "searchTerms": [ - "fuck", - "nigger", - "fuck", - "nigger", - "wanker", - "cunt", - "damn", - "shit", - "fag", - "shithead", - "jizz", - "hellbitch", - "retard", - "cocksucker", - "cock", - "kill", - "cunt", - "kike", - "twat", - "bastard", - "death", - "asshole", - "wop", - "scumbag", - "penis", - "murder", - "dick", - "gook", - "vagina", - "rape", - "bastard", - "spic", - "spunk", - "beat" + "ruleId": "image-moderation", + "ruleName": "AI Image Moderation", + "revisionId": "253156be20433c97_image-moderation_4", + "condition": { + "id": 1, + "isKeywordsReferencePresent": false, + "isMediaPresent": true, + "entity": "message", + "operand": "image", + "category": "word", + "operator": "contains", + "value": [ + "Any unsafe content_greaterThan_70" + ], + "message": [ + "Image contains Any unsafe content with confidence greater than 70" + ], + "weight": 1 + }, + "message": { + "id": "65", + "muid": "_5zytzmceo", + "conversationId": "superhero1_user_superhero2", + "sender": "superhero1", + "receiverType": "user", + "receiver": "superhero2", + "category": "message", + "type": "image", + "data": { + "metadata": { + "file": [] + }, + "resource": "WEB-4_0_3-ffa565b2-476e-493d-aeb5-4c750aae3ab1-1719925738505", + "url": "https://data-eu.cometchat.io/2601293c931567f7/media/1719993037_336554568_9e044ea0ed5817381b189680f392bafe.jpeg", + "attachments": [ + { + "name": "download.jpeg", + "extension": "jpeg", + "size": 4761, + "mimeType": "image/jpeg", + "url": "https://data-eu.cometchat.io/2601293c931567f7/media/1719993037_336554568_9e044ea0ed5817381b189680f392bafe.jpeg" + } + ], + "entities": { + "sender": { + "entity": { + "uid": "superhero1", + "name": "Iron Man", + "avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png", + "status": "offline", + "role": "default" + }, + "entityType": "user" + }, + "receiver": { + "entity": { + "uid": "superhero2", + "name": "Captain America", + "avatar": "https://data-eu.cometchat.io/assets/images/avatars/captainamerica.png", + "status": "offline", + "role": "default", + "conversationId": "superhero1_user_superhero2" + }, + "entityType": "user" + } + }, + "moderation": { + "status": "pending" + } + }, + "sentAt": 1719993037, + "updatedAt": 1719993037 + }, + "action": [ + "blockMessage" ], - "createdAt": 1718354412, - "updatedAt": 1718354412, - "revisionId": "253157108b5294c4_profanity-list_1", - "active": true, - "__v": 0, - "default": true, - "appId": "default" + "createdAt": 1719993038, + "updatedAt": 1719993038 } ], "meta": { - "current": { - "limit": 10, - "count": 2 + "current": { + "limit": 50, + "count": 20 } } } @@ -14192,120 +15392,41 @@ ] } }, - "/moderation/keywords/{keywordId}": { - "get": { - "tags": [ - "Moderation" - ], - "summary": "Get keyword", - "description": "Retrieve details of a specific keyword list by its ID.", - "operationId": "chat-api-get-rule-keyword", - "parameters": [ - { - "$ref": "#/components/parameters/keywordId" - } - ], - "responses": { - "200": { - "description": "Get Keyword", - "content": { - "application/json": { - "schema": { - "properties": { - "data": { - "properties": { - "": { - "$ref": "#/components/schemas/webhookSchema" - } - }, - "type": "object" - } - }, - "type": "object" - }, - "example": { - "data": { - "id": "profanity-list", - "name": "Profane Words", - "category": "word", - "isCSV": false, - "searchTerms": [ - "fuck", - "nigger", - "fuck", - "nigger", - "wanker", - "cunt", - "damn", - "shit", - "fag", - "shithead", - "jizz", - "hellbitch", - "retard", - "cocksucker", - "cock", - "kill", - "cunt", - "kike", - "twat", - "bastard", - "death", - "asshole", - "wop", - "scumbag", - "penis", - "murder", - "dick", - "gook", - "vagina", - "rape", - "bastard", - "spic", - "spunk", - "beat" - ], - "createdAt": 1718354412, - "updatedAt": 1718354412, - "revisionId": "253157108b5294c4_profanity-list_1", - "active": true, - "default": true - } - } - } - } - } - }, - "security": [ - { - "apiKey": [] - } - ] - }, - "put": { + "/moderation/blocked-messages/{messageId}": { + "patch": { "tags": [ "Moderation" ], - "summary": "Update keyword", - "description": "Update an existing keyword list.", - "operationId": "chat-api-update-rule-keyword", + "summary": "Approve Blocked Messages", + "description": "Approves the messages blocked by the moderation service.", + "operationId": "chat-api-approve-moderation-blocked-messages", "parameters": [ { - "$ref": "#/components/parameters/keywordId" + "$ref": "#/components/parameters/messageId" } ], "requestBody": { "content": { - "multipart/form-data": { + "application/json": { "schema": { - "$ref": "#/components/schemas/KeywordList" + "required": [ + "status" + ], + "properties": { + "status": { + "description": "Moderation status of the message.", + "type": "string", + "example": "approved" + } + }, + "type": "object" } } } }, "responses": { "200": { - "description": "Update Keyword", + "description": "Approve Blocked Messages", "content": { "application/json": { "schema": { @@ -14323,51 +15444,8 @@ }, "example": { "data": { - "id": "profanity-list", - "name": "Profane Words", - "category": "word", - "isCSV": false, - "searchTerms": [ - "fuck", - "nigger", - "fuck", - "nigger", - "wanker", - "cunt", - "damn", - "shit", - "fag", - "shithead", - "jizz", - "hellbitch", - "retard", - "cocksucker", - "cock", - "kill", - "cunt", - "kike", - "twat", - "bastard", - "death", - "asshole", - "wop", - "scumbag", - "penis", - "murder", - "dick", - "gook", - "vagina", - "rape", - "bastard", - "spic", - "spunk", - "beat" - ], - "createdAt": 1718354412, - "updatedAt": 1718354412, - "revisionId": "253157108b5294c4_profanity-list_1", - "active": true, - "default": true + "success": true, + "message": "Message with ID 268 has been approved." } } } @@ -14379,150 +15457,183 @@ "apiKey": [] } ] - }, - "delete": { + } + }, + "/moderation/messages": { + "post": { "tags": [ "Moderation" ], - "summary": "Remove keyword", - "description": "Delete a keyword list by its ID.", - "operationId": "chat-api-delete-rule-keyword", - "parameters": [ - { - "$ref": "#/components/parameters/keywordId" - } - ], - "responses": { - "200": { - "description": "Delete Keyword", - "content": { - "application/json": { - "schema": { - "properties": { - "data": { - "properties": { - "": { - "$ref": "#/components/schemas/webhookSchema" - } - }, - "type": "object" - } + "summary": "Send message", + "description": "This endpoint is used to submit a message for moderation before it is delivered to the recipient. The message is scanned against the moderation rules configured for the app.", + "operationId": "chat-api-send-message-moderation", + "requestBody": { + "content": { + "application/json": { + "schema": { + "required": [ + "sender", + "receiver", + "receiverType" + ], + "properties": { + "muid": { + "description": "The unique identifier for the message", + "type": "string" + }, + "category": { + "description": "Category of the message. The available category is message", + "type": "string", + "enum": [ + "message" + ] + }, + "type": { + "description": "Defines the type of the message based on the selected category.\nWhen `category` is `message`, the allowed values for `type` are:\n\n`text` — Plain text message\n\n`image` — Image message\n\n`audio` — Audio message\n\n`video` — Video message\n\n`file` — File message\n\nWhen `category` is `custom`, any custom string can be used as the `type`. This allows developers to define and handle custom message types as needed in their UI implementation.", + "type": "string", + "enum": [ + "text", + "image", + "file", + "audio", + "video" + ] + }, + "sender": { + "description": "UID of the sender.", + "type": "string" + }, + "receiver": { + "description": "If the receiverType == “user” the UID of a user receiving the message. else GUID of the group.", + "type": "string" + }, + "receiverType": { + "description": "The receiverType of the message. either user or group", + "type": "string", + "enum": [ + "user", + "group" + ] }, - "type": "object" - }, - "example": { "data": { - "success": true, - "message": "Keyword with id profanity-list has been deleted successfully." + "$ref": "#/components/schemas/moderationMessageData" + }, + "senderUserDetails": { + "description": "This property contains information about the sender user. It is required only if the sender does not already exist in CometChat. If provided, the sender user will be created before the message is processed.", + "allOf": [ + { + "$ref": "#/components/schemas/userSenderDetails" + } + ] + }, + "receiverUserDetails": { + "description": "This property contains information about the receiver user (in case of one-to-one messages). It is required only if the receiver user does not already exist in CometChat. If provided, the user will be created before the message is sent.", + "allOf": [ + { + "$ref": "#/components/schemas/userSenderDetails" + } + ] + }, + "receiverGroupDetails": { + "description": "This property contains information about the group receiving the message.\nIt is required only if the group does not already exist in CometChat. If provided, the group will be created before the message is sent.", + "allOf": [ + { + "$ref": "#/components/schemas/groupReceiverDetails" + } + ] + }, + "tags": { + "description": "String array containing developer defined tags.", + "type": "array", + "items": { + "type": "string" + } + }, + "sentAt": { + "description": "10 digit unix timestamp at which the message would be sent. If left blank, the current timestamp would be used.", + "type": "integer" + } + }, + "type": "object" + }, + "examples": { + "Send Moderation Message": { + "summary": "Send Moderation Message", + "value": { + "category": "message", + "type": "text", + "data": { + "text": "Hey there! Welcome aboard." + }, + "sender": "cometchat-test-user-1", + "receiver": "cometchat-test-user-2", + "senderUserDetails": { + "uid": "cometchat-test-user-1", + "name": "Test User 1" + }, + "receiverUserDetails": { + "uid": "cometchat-test-user-2", + "name": "Test User 2" + }, + "receiverType": "user" } } } } } }, - "security": [ - { - "apiKey": [] - } - ] - } - }, - "/moderation/rules/{ruleId}/revisions": { - "get": { - "tags": [ - "Moderation" - ], - "summary": "Get Rule Revisions", - "description": "Fetches a rule's revisions.", - "operationId": "chat-api-list-rule-revisions", - "parameters": [ - { - "$ref": "#/components/parameters/ruleId" - } - ], "responses": { "200": { - "description": "List Rule revisions", + "description": "Import Message(s)", "content": { "application/json": { "schema": { - "properties": { - "data": { - "properties": { - "": { - "$ref": "#/components/schemas/webhookSchema" - } - }, - "type": "object" - } - }, "type": "object" }, "example": { - "data": [ - { - "id": "moderation-test", - "name": "Video Moderation", - "description": "AI-powered video moderation to detect unsafe content.", - "enabled": true, - "conditions": [ - { - "id": 1, - "isKeywordsReferencePresent": false, - "isMediaPresent": false, - "entity": "message", - "operand": "text", - "category": "word", - "operator": "equals", - "value": [ - "paris" - ] + "data": { + "id": "1", + "conversationId": "cometchat-uid-1_user_cometchat-uid-2", + "sender": "cometchat-uid-2", + "receiverType": "user", + "receiver": "cometchat-uid-1", + "category": "message", + "type": "text", + "data": { + "text": "Hi new user", + "entities": { + "sender": { + "entity": { + "uid": "cometchat-uid-2", + "name": "George Alan", + "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp", + "status": "offline", + "role": "default", + "lastActiveAt": 1751644824, + "createdAt": 1751644824, + "conversationId": "cometchat-uid-1_user_cometchat-uid-2" + }, + "entityType": "user" + }, + "receiver": { + "entity": { + "uid": "cometchat-uid-1", + "name": "Andrew Joseph", + "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp", + "status": "offline", + "role": "default", + "lastActiveAt": 1751644824, + "createdAt": 1751644824 + }, + "entityType": "user" } - ], - "action": [ - "blockMessage" - ], - "active": true, - "createdAt": 1720011899, - "updatedAt": 1720011905, - "revisionId": "253179cf5f665257_moderation-test_2" + }, + "moderation": { + "status": "pending" + } }, - { - "id": "moderation-test", - "name": "Video Moderation", - "description": "AI-powered video moderation to detect unsafe content.", - "enabled": true, - "conditions": [ - { - "id": 1, - "isKeywordsReferencePresent": false, - "isMediaPresent": true, - "entity": "message", - "operand": "image", - "category": "word", - "operator": "contains", - "value": [ - "violence_greaterThan_30" - ], - "message": [ - "Image contains violence with confidence greater than 30" - ] - } - ], - "action": [ - "blockMessage" - ], - "active": false, - "createdAt": 1720011899, - "updatedAt": 1720011899, - "revisionId": "253179cf5f665257_moderation-test_1" - } - ], - "meta": { - "current": { - "limit": 10, - "count": 2 - } + "sentAt": 1750335220, + "updatedAt": 1751644906 } } } @@ -14534,121 +15645,136 @@ "apiKey": [] } ] - } - }, - "/moderation/blocked-messages": { + }, "get": { "tags": [ "Moderation" ], - "summary": "List Blocked Messages", - "description": "Lists the messages blocked by the moderation service.", - "operationId": "chat-api-list-moderation-blocked-messages", + "summary": "List messages", + "description": "This endpoint is used to retrieve a list of messages that were submitted for moderation. Each message includes its current moderation status based on the rules configured for the app.", + "operationId": "chat-api-list-message-moderation", + "parameters": [ + { + "name": "sender", + "in": "query", + "description": "Filters messages by the sender’s uid.", + "schema": { + "type": "string" + } + }, + { + "name": "receiverUID", + "in": "query", + "description": "Filters messages by the receiver's uid.", + "schema": { + "type": "string" + } + }, + { + "name": "receiverGUID", + "in": "query", + "description": "Filters messages by the receiver's guid in case of group", + "schema": { + "type": "string" + } + }, + { + "name": "category", + "in": "query", + "description": "Filters messages by category. Possible values: message and custom.", + "schema": { + "type": "string", + "enum": [ + "message", + "custom" + ] + } + }, + { + "name": "type", + "in": "query", + "description": "Filters messages by type.", + "schema": { + "type": "string" + } + }, + { + "name": "moderationStatus", + "in": "query", + "description": "Filters messages by moderation status.", + "schema": { + "type": "string", + "enum": [ + "disapproved", + "pending" + ] + } + } + ], "responses": { "200": { - "description": "List Blocked Messages", + "description": "Get Message(s)", "content": { "application/json": { - "schema": { - "properties": { - "data": { - "properties": { - "": { - "$ref": "#/components/schemas/webhookSchema" - } - }, - "type": "object" - } - }, - "type": "object" - }, - "example": { - "data": [ - { - "ruleId": "image-moderation", - "ruleName": "AI Image Moderation", - "revisionId": "253156be20433c97_image-moderation_4", - "condition": { - "id": 1, - "isKeywordsReferencePresent": false, - "isMediaPresent": true, - "entity": "message", - "operand": "image", - "category": "word", - "operator": "contains", - "value": [ - "Any unsafe content_greaterThan_70" - ], - "message": [ - "Image contains Any unsafe content with confidence greater than 70" - ], - "weight": 1 - }, - "message": { - "id": "65", - "muid": "_5zytzmceo", - "conversationId": "superhero1_user_superhero2", - "sender": "superhero1", - "receiverType": "user", - "receiver": "superhero2", - "category": "message", - "type": "image", - "data": { - "metadata": { - "file": [] - }, - "resource": "WEB-4_0_3-ffa565b2-476e-493d-aeb5-4c750aae3ab1-1719925738505", - "url": "https://data-eu.cometchat.io/2601293c931567f7/media/1719993037_336554568_9e044ea0ed5817381b189680f392bafe.jpeg", - "attachments": [ - { - "name": "download.jpeg", - "extension": "jpeg", - "size": 4761, - "mimeType": "image/jpeg", - "url": "https://data-eu.cometchat.io/2601293c931567f7/media/1719993037_336554568_9e044ea0ed5817381b189680f392bafe.jpeg" - } - ], - "entities": { - "sender": { - "entity": { - "uid": "superhero1", - "name": "Iron Man", - "avatar": "https://data-eu.cometchat.io/assets/images/avatars/ironman.png", - "status": "offline", - "role": "default" - }, - "entityType": "user" + "schema": { + "type": "object" + }, + "example": { + "data": [ + { + "id": "1", + "conversationId": "cometchat-uid-1_user_cometchat-uid-2", + "sender": "cometchat-uid-2", + "receiverType": "user", + "receiver": "cometchat-uid-1", + "category": "message", + "type": "text", + "data": { + "entities": { + "receiver": { + "entity": { + "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp", + "createdAt": 1751644824, + "lastActiveAt": 1751644824, + "name": "Andrew Joseph", + "role": "default", + "status": "offline", + "uid": "cometchat-uid-1" }, - "receiver": { - "entity": { - "uid": "superhero2", - "name": "Captain America", - "avatar": "https://data-eu.cometchat.io/assets/images/avatars/captainamerica.png", - "status": "offline", - "role": "default", - "conversationId": "superhero1_user_superhero2" - }, - "entityType": "user" - } + "entityType": "user" }, - "moderation": { - "status": "pending" + "sender": { + "entity": { + "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp", + "conversationId": "cometchat-uid-1_user_cometchat-uid-2", + "createdAt": 1751644824, + "lastActiveAt": 1751644824, + "name": "George Alan", + "role": "default", + "status": "offline", + "uid": "cometchat-uid-2" + }, + "entityType": "user" } }, - "sentAt": 1719993037, - "updatedAt": 1719993037 + "moderation": { + "status": "approved" + }, + "text": "Hi new user" }, - "action": [ - "blockMessage" - ], - "createdAt": 1719993038, - "updatedAt": 1719993038 + "sentAt": 1750335220, + "updatedAt": 1751644906 } ], "meta": { "current": { - "limit": 50, - "count": 20 + "limit": 100, + "count": 1 + }, + "next": { + "affix": "append", + "sentAt": 1750335220, + "id": "1" } } } @@ -14663,60 +15789,245 @@ ] } }, - "/moderation/blocked-messages/{messageId}": { - "patch": { + "/moderation/messages/{id}": { + "get": { "tags": [ "Moderation" ], - "summary": "Approve Blocked Messages", - "description": "Approves the messages blocked by the moderation service.", - "operationId": "chat-api-approve-moderation-blocked-messages", + "summary": "Get message", + "description": "This endpoint is used to retrieve the details of a message that was submitted for moderation. The message is fetched along with its current moderation status based on the app's configured rules.", + "operationId": "chat-api-get-message-moderation", "parameters": [ { - "$ref": "#/components/parameters/messageId" + "name": "id", + "in": "path", + "description": "Id of the message whose details are to be fetched.", + "required": true, + "schema": { + "type": "string" + }, + "examples": { + "string": { + "summary": "Message ID", + "value": "" + } + } + } + ], + "responses": { + "200": { + "description": "Get Message(s)", + "content": { + "application/json": { + "schema": { + "type": "object" + }, + "example": { + "data": { + "id": "1", + "conversationId": "cometchat-uid-1_user_cometchat-uid-2", + "sender": "cometchat-uid-2", + "receiverType": "user", + "receiver": "cometchat-uid-1", + "category": "message", + "type": "text", + "data": { + "entities": { + "receiver": { + "entity": { + "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp", + "createdAt": 1751644824, + "lastActiveAt": 1751644824, + "name": "Andrew Joseph", + "role": "default", + "status": "offline", + "uid": "cometchat-uid-1" + }, + "entityType": "user" + }, + "sender": { + "entity": { + "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp", + "conversationId": "cometchat-uid-1_user_cometchat-uid-2", + "createdAt": 1751644824, + "lastActiveAt": 1751644824, + "name": "George Alan", + "role": "default", + "status": "offline", + "uid": "cometchat-uid-2" + }, + "entityType": "user" + } + }, + "moderation": { + "status": "approved" + }, + "text": "Hi new user" + }, + "sentAt": 1750335220, + "updatedAt": 1751644906 + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "put": { + "tags": [ + "Moderation" + ], + "summary": "Update message", + "description": "This endpoint is responsible for editing the message, The moderation status is recalculated based on the app's configured rules for the edited message.", + "operationId": "chat-api-update-message-moderation", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "Id of the message whose details are to be fetched.", + "required": true, + "schema": { + "type": "string" + }, + "examples": { + "string": { + "summary": "Message ID", + "value": "" + } + } } ], "requestBody": { "content": { "application/json": { "schema": { - "required": [ - "status" - ], "properties": { - "status": { - "description": "Moderation status of the message.", - "type": "string", - "example": "approved" + "data": { + "$ref": "#/components/schemas/moderationMessageData" } }, "type": "object" + }, + "examples": { + "Update Moderation Message": { + "summary": "Update Moderation Message", + "value": { + "data": { + "text": "This message has been updated." + } + } + } } } } }, "responses": { "200": { - "description": "Approve Blocked Messages", + "description": "Update Message(s)", "content": { "application/json": { "schema": { - "properties": { + "type": "object" + }, + "example": { + "data": { + "id": "1", + "conversationId": "cometchat-uid-1_user_cometchat-uid-2", + "sender": "cometchat-uid-2", + "receiverType": "user", + "receiver": "cometchat-uid-1", + "category": "message", + "type": "text", "data": { - "properties": { - "": { - "$ref": "#/components/schemas/webhookSchema" + "text": "heyaya, I'm updated", + "entities": { + "receiver": { + "entity": { + "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-1.webp", + "createdAt": 1751644824, + "lastActiveAt": 1751644824, + "name": "Andrew Joseph", + "role": "default", + "status": "offline", + "uid": "cometchat-uid-1" + }, + "entityType": "user" + }, + "sender": { + "entity": { + "avatar": "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp", + "conversationId": "cometchat-uid-1_user_cometchat-uid-2", + "createdAt": 1751644824, + "lastActiveAt": 1751644824, + "name": "George Alan", + "role": "default", + "status": "offline", + "uid": "cometchat-uid-2" + }, + "entityType": "user" } }, - "type": "object" - } - }, + "moderation": { + "status": "approved" + } + }, + "sentAt": 1750335220, + "editedAt": 1751645607, + "editedBy": "cometchat-uid-1", + "updatedAt": 1751644906 + } + } + } + } + } + }, + "security": [ + { + "apiKey": [] + } + ] + }, + "delete": { + "tags": [ + "Moderation" + ], + "summary": "Delete message", + "description": "This endpoint deletes a previously submitted message. The message is removed along with its associated moderation data, as per the app's configured rules.", + "operationId": "chat-api-delete-message-moderation", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "Id of the message whose details are to be fetched.", + "required": true, + "schema": { + "type": "string" + }, + "examples": { + "string": { + "summary": "Message ID", + "value": "" + } + } + } + ], + "responses": { + "200": { + "description": "Delete Message(s)", + "content": { + "application/json": { + "schema": { "type": "object" }, "example": { "data": { "success": true, - "message": "Message with ID 268 has been approved." + "message": "Message with id 20011 has been deleted successfully." } } } @@ -17346,6 +18657,14 @@ }, "conversationWith": { "type": "object" + }, + "pinnedBy": { + "description": "UID of the user who pinned the conversation, or app_system for a global pin. Left out of the response when the conversation is not pinned.", + "type": "string" + }, + "pinnedAt": { + "description": "When the conversation was pinned, in seconds. Left out of the response when the conversation is not pinned.", + "type": "integer" } }, "type": "object" @@ -17431,6 +18750,7 @@ "type": "object" }, "customCategorySchema": { + "title": "Custom", "properties": { "receiver": { "description": "The receiver of the message.", @@ -17448,21 +18768,9 @@ "group" ] }, - "category": { - "description": "Category of the message. The available categories is custom.", - "type": "string", - "default": "custom", - "enum": [ - "custom" - ] - }, "quotedMessageId": { "description": "ID of the message being quoted.\nIf provided, the send message response will include a `quotedMessage` node\nin the response containing the referenced message object.", - "type": "string", - "default": "message", - "enum": [ - "message" - ] + "type": "string" }, "type": { "description": "Type of the message.", @@ -18458,6 +19766,7 @@ "type": "object" }, "messageCategorySchema": { + "title": "Message", "properties": { "receiver": { "description": "The receiver of the message.", @@ -18475,14 +19784,6 @@ "group" ] }, - "category": { - "description": "Category of the message. The available categories are message and custom.", - "type": "string", - "default": "message", - "enum": [ - "message" - ] - }, "quotedMessageId": { "description": "ID of the message being quoted.\nIf provided, the send message response will include a `quotedMessage` node\nin the response containing the referenced message object.", "type": "string" @@ -18845,6 +20146,18 @@ }, "updatedAt": { "type": "integer" + }, + "pinnedBy": { + "description": "UID of the user who pinned the message, or app_system when the app pinned it. Left out of the response when the message is not pinned.", + "type": "string" + }, + "pinnedAt": { + "description": "When the message was pinned, in seconds. Left out of the response when the message is not pinned.", + "type": "integer" + }, + "savedAt": { + "description": "When the message was saved, in seconds. Only present for the user who saved it, and left out of the response when they have not saved it.", + "type": "integer" } }, "type": "object" diff --git a/data-import-apis.json b/data-import-apis.json index 2678590ca..440228ad7 100644 --- a/data-import-apis.json +++ b/data-import-apis.json @@ -2928,6 +2928,14 @@ }, "conversationWith": { "type": "object" + }, + "pinnedBy": { + "description": "UID of the user who pinned the conversation, or app_system for a global pin. Left out of the response when the conversation is not pinned.", + "type": "string" + }, + "pinnedAt": { + "description": "When the conversation was pinned, in seconds. Left out of the response when the conversation is not pinned.", + "type": "integer" } }, "type": "object" @@ -3013,6 +3021,7 @@ "type": "object" }, "customCategorySchema": { + "title": "Custom", "properties": { "receiver": { "description": "The receiver of the message.", @@ -3030,21 +3039,9 @@ "group" ] }, - "category": { - "description": "Category of the message. The available categories is custom.", - "type": "string", - "default": "custom", - "enum": [ - "custom" - ] - }, "quotedMessageId": { "description": "ID of the message being quoted.\nIf provided, the send message response will include a `quotedMessage` node\nin the response containing the referenced message object.", - "type": "string", - "default": "message", - "enum": [ - "message" - ] + "type": "string" }, "type": { "description": "Type of the message.", @@ -4040,6 +4037,7 @@ "type": "object" }, "messageCategorySchema": { + "title": "Message", "properties": { "receiver": { "description": "The receiver of the message.", @@ -4057,14 +4055,6 @@ "group" ] }, - "category": { - "description": "Category of the message. The available categories are message and custom.", - "type": "string", - "default": "message", - "enum": [ - "message" - ] - }, "quotedMessageId": { "description": "ID of the message being quoted.\nIf provided, the send message response will include a `quotedMessage` node\nin the response containing the referenced message object.", "type": "string" @@ -4427,6 +4417,18 @@ }, "updatedAt": { "type": "integer" + }, + "pinnedBy": { + "description": "UID of the user who pinned the message, or app_system when the app pinned it. Left out of the response when the message is not pinned.", + "type": "string" + }, + "pinnedAt": { + "description": "When the message was pinned, in seconds. Left out of the response when the message is not pinned.", + "type": "integer" + }, + "savedAt": { + "description": "When the message was saved, in seconds. Only present for the user who saved it, and left out of the response when they have not saved it.", + "type": "integer" } }, "type": "object" diff --git a/docs.json b/docs.json index 86152f233..d16c37cd3 100644 --- a/docs.json +++ b/docs.json @@ -5048,6 +5048,11 @@ "rest-api/messages/get-message", "rest-api/messages/update-message", "rest-api/messages/delete-message", + "rest-api/messages/pin-message", + "rest-api/messages/unpin-message", + "rest-api/messages/save-message", + "rest-api/messages/unsave-message", + "rest-api/messages/mark-message-as-interacted", "rest-api/messages/list-all-reactions", "rest-api/messages/list-reactions-with-a-specific-emoji-unicode", "rest-api/messages/add-reaction", @@ -5069,18 +5074,24 @@ "rest-api/conversations/list-conversations", "rest-api/conversations/get-conversation", "rest-api/conversations/delete-conversation", + "rest-api/conversations/list-global-pinned-conversations", + "rest-api/conversations/replace-global-pinned-conversations", "rest-api/conversations/get-user-conversation", "rest-api/conversations/update-user-conversation", "rest-api/conversations/reset-user-conversation", "rest-api/conversations/mark-user-conversation-as-delivered", "rest-api/conversations/mark-user-conversation-as-read", "rest-api/conversations/mark-conversation-messages-as-unread", + "rest-api/conversations/pin-user-conversation", + "rest-api/conversations/unpin-user-conversation", "rest-api/conversations/get-group-conversation", "rest-api/conversations/update-group-conversation", "rest-api/conversations/reset-group-conversation", "rest-api/conversations/mark-group-conversation-as-delivered", "rest-api/conversations/mark-group-conversation-as-read", - "rest-api/conversations/mark-group-conversation-as-unread" + "rest-api/conversations/mark-group-conversation-as-unread", + "rest-api/conversations/pin-group-conversation", + "rest-api/conversations/unpin-group-conversation" ] } ] diff --git a/rest-api/conversations/list-global-pinned-conversations.mdx b/rest-api/conversations/list-global-pinned-conversations.mdx new file mode 100644 index 000000000..1d7b4b876 --- /dev/null +++ b/rest-api/conversations/list-global-pinned-conversations.mdx @@ -0,0 +1,6 @@ +--- +openapi: get /conversations/pinned +description: "List the CometChat global pinned conversations with REST API - the conversations pinned at the top for every end user, in display order." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide). diff --git a/rest-api/conversations/pin-group-conversation.mdx b/rest-api/conversations/pin-group-conversation.mdx new file mode 100644 index 000000000..d26caa2ad --- /dev/null +++ b/rest-api/conversations/pin-group-conversation.mdx @@ -0,0 +1,6 @@ +--- +openapi: post /groups/{guid}/conversation/pin +description: "Pin a CometChat group conversation for a user with REST API so it appears at the top of their conversation list." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide). diff --git a/rest-api/conversations/pin-user-conversation.mdx b/rest-api/conversations/pin-user-conversation.mdx new file mode 100644 index 000000000..7313fd14a --- /dev/null +++ b/rest-api/conversations/pin-user-conversation.mdx @@ -0,0 +1,6 @@ +--- +openapi: post /users/{uid}/conversation/pin +description: "Pin a CometChat one-on-one conversation for a user with REST API so it appears at the top of their conversation list." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide). diff --git a/rest-api/conversations/replace-global-pinned-conversations.mdx b/rest-api/conversations/replace-global-pinned-conversations.mdx new file mode 100644 index 000000000..a92aaf94d --- /dev/null +++ b/rest-api/conversations/replace-global-pinned-conversations.mdx @@ -0,0 +1,6 @@ +--- +openapi: put /conversations/pinned +description: "Replace the full CometChat global pinned conversation list with REST API - the conversations pinned at the top for every end user." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide). diff --git a/rest-api/conversations/unpin-group-conversation.mdx b/rest-api/conversations/unpin-group-conversation.mdx new file mode 100644 index 000000000..0f17fd6d3 --- /dev/null +++ b/rest-api/conversations/unpin-group-conversation.mdx @@ -0,0 +1,6 @@ +--- +openapi: delete /groups/{guid}/conversation/pin +description: "Unpin a CometChat group conversation for a user with REST API, removing that user's own pin." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide). diff --git a/rest-api/conversations/unpin-user-conversation.mdx b/rest-api/conversations/unpin-user-conversation.mdx new file mode 100644 index 000000000..1347b1b52 --- /dev/null +++ b/rest-api/conversations/unpin-user-conversation.mdx @@ -0,0 +1,6 @@ +--- +openapi: delete /users/{uid}/conversation/pin +description: "Unpin a CometChat one-on-one conversation for a user with REST API, removing that user's own pin." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide). diff --git a/rest-api/messages/mark-message-as-interacted.mdx b/rest-api/messages/mark-message-as-interacted.mdx new file mode 100644 index 000000000..1702a12a0 --- /dev/null +++ b/rest-api/messages/mark-message-as-interacted.mdx @@ -0,0 +1,6 @@ +--- +openapi: patch /messages/{id}/interacted +description: "Mark a CometChat message as interacted with REST API on behalf of a user." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide). diff --git a/rest-api/messages/pin-message.mdx b/rest-api/messages/pin-message.mdx new file mode 100644 index 000000000..07ac55da3 --- /dev/null +++ b/rest-api/messages/pin-message.mdx @@ -0,0 +1,6 @@ +--- +openapi: post /messages/{id}/pin +description: "Pin a CometChat message in a one-on-one or group conversation with REST API, as the app or on behalf of a user." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide). diff --git a/rest-api/messages/save-message.mdx b/rest-api/messages/save-message.mdx new file mode 100644 index 000000000..ead01b419 --- /dev/null +++ b/rest-api/messages/save-message.mdx @@ -0,0 +1,6 @@ +--- +openapi: post /messages/{id}/save +description: "Save a CometChat message to a user's private saved list with REST API on behalf of that user." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide). diff --git a/rest-api/messages/unpin-message.mdx b/rest-api/messages/unpin-message.mdx new file mode 100644 index 000000000..dec2fe974 --- /dev/null +++ b/rest-api/messages/unpin-message.mdx @@ -0,0 +1,6 @@ +--- +openapi: delete /messages/{id}/pin +description: "Unpin a pinned CometChat message with REST API. Any user with unpin permission can unpin, not only the user who pinned it." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide). diff --git a/rest-api/messages/unsave-message.mdx b/rest-api/messages/unsave-message.mdx new file mode 100644 index 000000000..7e407d6e1 --- /dev/null +++ b/rest-api/messages/unsave-message.mdx @@ -0,0 +1,6 @@ +--- +openapi: delete /messages/{id}/save +description: "Remove a CometChat message from a user's saved list with REST API on behalf of that user." +--- + +For the complete error reference, see [Error Guide](/articles/error-guide).