# How to Use the Clear Chat API

Every conversation in DoubleTick stores a running history of messages exchanged between your team and a customer. There are times when you may want to wipe that history clean, whether to protect sensitive information, reset a conversation before a new interaction, or keep your inbox organised. DoubleTick lets you do this in three ways, and this article walks you through all of them.

#### <mark style="color:$primary;">**Clearing a Chat Manually**</mark>

<figure><img src="/files/VKlIWqtd0bXGSJ3eVQUp" alt=""><figcaption></figcaption></figure>

If you want to clear messages from a single conversation, you can do it directly from the chat window.&#x20;

* Open the conversation you want to clear.
* Click the **three-dot menu** at the top right.
* Select the **Clear Chat** option. This removes all messages from that conversation immediately.

This method works well when you are handling one conversation at a time. However, it does not support clearing **multiple chats at once**, and it **cannot be triggered automatically** as part of a workflow or bot.

***

#### <mark style="color:$primary;">**What the Clear Chat API Does**</mark>

For teams that need more flexibility, DoubleTick provides a **Clear Chat API**. This is a tool meant for technical use cases, such as clearing chat histories **in bulk**, triggering a chat clear automatically when a certain condition is met inside a bot, or building the action into a backend workflow your team manages.

In simple terms, the API sends an instruction to DoubleTick saying: clear all messages from this specific conversation. DoubleTick then processes that request and removes the chat history.

#### <mark style="color:$primary;">**How to Use the Clear Chat API**</mark>

<figure><img src="/files/KvHebDLBko1RkoyEkmPo" alt=""><figcaption></figcaption></figure>

The full API reference is available at the DoubleTick documentation portal. You can access it here: <https://docs.doubletick.io/reference/clear-chat-messages-v2>

To make the API work, you need to provide **two phone numbers** and one **API key**.

* Enter the **customer's phone number** — the number of the person whose conversation you want to clear.
* Enter your **WhatsApp API number** — the DoubleTick-connected number on which that conversation exists.
* To find your **API key**, go to **Settings** inside DoubleTick, open the **Developer Documentation** section, and copy the key displayed there. Paste it into the **header field** in the API call.
* Once all values are filled in, click the **Try It** button on the documentation page to test the call.
* If the request is successful, you will see a **200 Success** response confirming the chat has been added to the deletion queue. After a few moments, the conversation history will be cleared.

***

#### <mark style="color:$primary;">**Adding Clear Chat API to a Bot or Workflow**</mark>

<figure><img src="/files/hGm05o1bftmX64HNdzYp" alt=""><figcaption></figcaption></figure>

If you want the chat to clear automatically at a certain point in a conversation, you can add the Clear Chat API as an action inside DoubleTick's **Bot Studio**.

* On the API documentation page, generate the **cURL** for your API call and copy it.
* Open the bot in **Bot Studio** where you want to add this step.
* Add a new action component and select **Call API** from the list.
* Connect this component to whichever step should trigger the chat clear.
* In the Call API component, click the API dropdown and select **Create New API**.
* Choose **Import from cURL**, paste the cURL you copied, and give the API a name such as **Clear Chat**.
* **Save** the API.

Once saved, the component will show all the headers and body parameters already filled in from your cURL. From this point, whenever the bot reaches that step during a live conversation, it will automatically call the Clear Chat API and wipe the chat history.

***

#### <mark style="color:$primary;">**Confirming the Chat Has Been Cleared**</mark>

<figure><img src="/files/3Ml23tnFe846v72rQ6Rh" alt=""><figcaption></figcaption></figure>

After the API is called, you can verify that it worked by opening the relevant conversation in DoubleTick. If the request was successful, the chat window will show no previous messages, confirming that the history has been deleted.

***

#### <mark style="color:$primary;">**Summary**</mark>

The Clear Chat API gives your team precise control over conversation data, whether you are clearing chats one at a time, in bulk, or as part of an automated workflow. If you run into any issues while setting this up, reach out to the DoubleTick support team for assistance.


---

# 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://learn.doubletick.io/developer-documentation/how-to-use-the-clear-chat-api.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.
