please select
  • UIKit
  • SDK
  • Server APIs
Chat/
SDK/
Web/
Conversation/
SDK
  • Install Chat SDK
  • Initialize Chat SDK
  • Login and Logout
  • Client APIs
  • Changelog
  • Message
    • Overview
    • Send a Message
    • Receive a Message
    • Historical Message
    • Forward Messages
    • Modify a Message
    • Delete Messages
    • Clear History Message
    • Recall a Message
    • Send an Online Message
    • Message Read Receipt
    • Query Messages
    • Targeted Group Message
    • Do not Notify
    • Key-Value Extensions
    • Translation
  • Conversation
    • Overview
    • Conversation List
    • Get Conversations
    • Unread Count
    • Pin Conversations
    • Delete Conversations
    • Mark
    • Conversation Group
  • Group
    • Overview
    • Group Management
    • Group Profile
    • Group Member Management
    • Group Member Profile
    • Custom Group Attribute
    • Group Counter
  • Community Topic
    • Community Management
  • User Profile and Relationship Chain
    • User Profile
    • User Status
    • Friend Management
    • Friend Group
    • Block List
  • Guideline for Beginners
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes

Delete Conversations

Feature Description

If a user doesn't want to view the historical one-to-one or group messages after deleting a friend or leaving a group, the user can choose to delete the conversation.

Deleting a Conversation

Note
1. Multi-client sync is disabled for conversation deletion by default. To enable it, log in to the Chat Console, select Application Configuration > Feature Configuration > Login and Message > Multi-client Synchronization Settings, and enable Sync Conversation Deletion Across Clients.
2. It supports for bulk deletion of conversations (up to 100 conversations at a time), with the option to choose whether to clear the history messages.
API
chat.deleteConversation(options);
Parameter
Name
Type
Description
options
String | Object
If the options parameter is of the String type, it's valid values as blow:
C2C${userID} (for a one-to-one chat)
GROUP{groupID} (for a group chat)
@TIM#SYSTEM (for a system notification conversation)
Returned value
Promise
Sample
// delete the specified conversation and clear chat history
let promise = chat.deleteConversation('C2CExample');
promise.then(function(imResponse) {
// Deleted the conversation successfully
const { conversationID } = imResponse.data;// ID of the deleted conversation
}).catch(function(imError) {
console.warn('deleteConversation error:', imError); // Failed to delete the conversation
});
// delete the specified conversation and not clear chat history
let promise = chat.deleteConversation({conversationIDList: ['C2CExample'], clearHistoryMessage: false});
promise.then(function(imResponse) {
// Deleted the conversation successfully
const { conversationIDList } = imResponse.data; // ID of the deleted conversation
}).catch(function(imError) {
console.warn('deleteConversation error:', imError); // Failed to delete the conversation
});
// delete multiple conversations and clear chat history
let promise = chat.deleteConversation({conversationIDList: ['C2CExample', 'GROUPExample']});
promise.then(function(imResponse) {
const { conversationIDList } = imResponse.data; // ID list of the deleted conversations
}).catch(function(imError) {
console.warn('deleteConversation error:', imError); // Failed to delete the conversation
});
// delete multiple conversations and clear chat history
let promise = chat.deleteConversation({
conversationIDList: ['C2CExample', 'GROUPExample'],
clearHistoryMessage: false
});
promise.then(function(imResponse) {
const { conversationIDList } = imResponse.data; // ID list of the deleted conversations
}).catch(function(imError) {
console.warn('deleteConversation error:', imError); // Failed to delete the conversation
});