> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-ios-ui-kit-sdk-fixes.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete A Conversation

> Guide to deleting conversations using the CometChat iOS SDK deleteConversation method for user and group chats.

<Info>
  **Quick Reference for AI Agents & Developers**

  * **Delete conversation:** `CometChat.deleteConversation(conversationWith:conversationType:onSuccess:onError:)`
  * **Conversation types:** `.user`, `.group`
  * **Related:** [Retrieve Conversations](/sdk/ios/retrieve-conversations) · [Messaging Overview](/sdk/ios/messaging-overview)
</Info>

In case you want to delete a conversation, you can use the `deleteConversation()` method.

This method takes two parameters. The unique id (UID/GUID) of the conversation to be deleted & the type (user/group) of conversation to be deleted.

## Delete User Conversation

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CometChat.deleteConversation(conversationWith: "cometchat-uid-1", conversationType: .user, onSuccess: { (message) in
        print("Conversation deleted: \(message)")
    }, onError: { (error) in
        print("Error: \(error?.errorDescription)")
    })
    ```
  </Tab>
</Tabs>

<Accordion title="Sample Payloads - Delete User Conversation">
  <Tabs>
    <Tab title="Request">
      **Method:** `CometChat.deleteConversation(conversationWith:conversationType:)`

      | Parameter        | Type                         | Value               |
      | ---------------- | ---------------------------- | ------------------- |
      | conversationWith | `String`                     | `"cometchat-uid-1"` |
      | conversationType | `CometChat.ConversationType` | `.user`             |
    </Tab>

    <Tab title="Success Response">
      **Response:**

      | Parameter | Type     | Value                                  |
      | --------- | -------- | -------------------------------------- |
      | message   | `String` | `"Conversation deleted successfully."` |

      **After Deletion:**

      | Effect               | Description             |
      | -------------------- | ----------------------- |
      | Conversation removed | For logged-in user only |
      | Messages deleted     | For logged-in user only |
      | Other participants   | Still have access       |
    </Tab>

    <Tab title="Error Response">
      **Object Type:** CometChatException

      | Parameter        | Type     | Value                           |
      | ---------------- | -------- | ------------------------------- |
      | errorCode        | `String` | `"ERR_CONVERSATION_NOT_FOUND"`  |
      | errorDescription | `String` | `"Conversation does not exist"` |
    </Tab>
  </Tabs>
</Accordion>

## Delete Group Conversation

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CometChat.deleteConversation(conversationWith: "group-guid-1", conversationType: .group, onSuccess: { (message) in
        print("Conversation deleted: \(message)")
    }, onError: { (error) in
        print("Error: \(error?.errorDescription)")
    })
    ```
  </Tab>
</Tabs>

<Accordion title="Sample Payloads - Delete Group Conversation">
  <Tabs>
    <Tab title="Request">
      **Method:** `CometChat.deleteConversation(conversationWith:conversationType:)`

      | Parameter        | Type                         | Value            |
      | ---------------- | ---------------------------- | ---------------- |
      | conversationWith | `String`                     | `"group-guid-1"` |
      | conversationType | `CometChat.ConversationType` | `.group`         |
    </Tab>

    <Tab title="Success Response">
      **Response:**

      | Parameter | Type     | Value                                  |
      | --------- | -------- | -------------------------------------- |
      | message   | `String` | `"Conversation deleted successfully."` |

      **After Deletion:**

      | Effect               | Description             |
      | -------------------- | ----------------------- |
      | Conversation removed | For logged-in user only |
      | Messages deleted     | For logged-in user only |
      | Other participants   | Still have access       |
    </Tab>

    <Tab title="Error Response">
      **Object Type:** CometChatException

      | Parameter        | Type     | Value                    |
      | ---------------- | -------- | ------------------------ |
      | errorCode        | `String` | `"ERR_GROUP_NOT_FOUND"`  |
      | errorDescription | `String` | `"Group does not exist"` |
    </Tab>
  </Tabs>
</Accordion>

<Note>
  This method deletes the conversation only for the logged-in user. To delete a conversation for all the users of the conversation, please refer to our REST API documentation [here](https://api-explorer.cometchat.com/reference/deletes-conversation).
</Note>

***

## Method Parameters

The `deleteConversation()` method takes the following parameters:

| Parameter        | Type                            | Required | Description                  |
| ---------------- | ------------------------------- | -------- | ---------------------------- |
| conversationWith | `String`                        | YES      | UID of user or GUID of group |
| conversationType | `CometChat.ConversationType`    | YES      | `.user` or `.group`          |
| onSuccess        | `(String) -> Void`              | YES      | Success callback             |
| onError          | `(CometChatException?) -> Void` | YES      | Error callback               |

***

## Success & Failure Responses

### Delete Conversation Success Response

When a conversation is successfully deleted, the `onSuccess` callback returns a success message:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CometChat.deleteConversation(conversationWith: "cometchat-uid-1", conversationType: .user, onSuccess: { (message) in
        // message: String - Success confirmation message
        print("Response: \(message)")  // "Conversation deleted successfully."
        
        // After deletion:
        // - Conversation removed from logged-in user's conversation list
        // - Messages are deleted for the logged-in user only
        // - Other participants still have access to the conversation
    }, onError: { (error) in
        // Handle error
    })
    ```
  </Tab>
</Tabs>

### Delete Conversation Failure Response

When deletion fails, the `onError` callback returns a `CometChatException`:

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    CometChat.deleteConversation(conversationWith: "cometchat-uid-1", conversationType: .user, onSuccess: { (message) in
        // Success
    }, onError: { (error) in
        print("Error Code: \(error?.errorCode ?? "")")
        print("Error Description: \(error?.errorDescription ?? "")")
        
        // Handle specific errors
        switch error?.errorCode {
        case "ERR_CONVERSATION_NOT_FOUND":
            // Conversation does not exist
            break
        case "ERR_UID_NOT_FOUND":
            // User with specified UID does not exist
            break
        case "ERR_GROUP_NOT_FOUND":
            // Group with specified GUID does not exist
            break
        case "ERR_NOT_LOGGED_IN":
            // User is not logged in
            break
        default:
            break
        }
    })
    ```
  </Tab>
</Tabs>

***

## After Deletion

| Effect               | Description             |
| -------------------- | ----------------------- |
| Conversation removed | For logged-in user only |
| Messages deleted     | For logged-in user only |
| Other participants   | Still have access       |

***

## Common Error Codes

| Error Code                   | Description                | Resolution                 |
| ---------------------------- | -------------------------- | -------------------------- |
| `ERR_CONVERSATION_NOT_FOUND` | Conversation doesn't exist | Verify conversation exists |
| `ERR_UID_NOT_FOUND`          | User UID doesn't exist     | Verify user UID            |
| `ERR_GROUP_NOT_FOUND`        | Group GUID doesn't exist   | Verify group GUID          |
| `ERR_NOT_LOGGED_IN`          | User is not logged in      | Login first                |
