# deleteMessage

## api.deleteMessage(options, threadId\[, type])

### Parameters

* dest `DeleteMessageDestination`
* onlyMe `boolean?`
  * mặc định `true` , chỉ xóa ở phía bản thân

### Return

`Promise<DeleteMessageResponse>`

### Types

```typescript
export type DeleteMessageResponse = {
    status: number;
};

export type DeleteMessageDestination = {
    data: {
        cliMsgId: string;
        msgId: string;
        uidFrom: string;
    };
    threadId: string;
    /**
     * mặc định ThreadType.User
     */
    type?: ThreadType;
};
```

### Examples

Xóa tin nhắn bản thân sau 5s

```typescript
// xóa tin nhắn của bản thân sau 5s nếu nội dung là "test"
api.listener.on("message", (message) => {
    const { content } = message.data;
    const isTextMessage = typeof content == "string";
    const shouldDelete = isTextMessage && content == "test";

    if (message.isSelf && shouldDelete) {
        setTimeout(() => {
            api.deleteMessage(
                {
                    data: {
                        cliMsgId: message.data.cliMsgId,
                        msgId: message.data.msgId,
                        uidFrom: message.data.uidFrom,
                    },
                    threadId: message.threadId,
                    type: message.type
                }
            )
                .then(console.log)
                .catch(console.error);
        }, 5_000);
    }
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tdung.gitbook.io/zca-js/api/deletemessage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
