> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ryzeapi.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Archive chat

> Archives or unarchives a WhatsApp chat

**Auth:** `TokenAccount` or `TokenInstance` • **Rate-limit:** `Global` (100/min) • **Idempotent:** yes

## Description

Archives (`archive: true`) or unarchives (`archive: false`) a chat. The operation is propagated to WhatsApp via app state, it may take seconds to reflect on the other linked devices.

## Examples

### Archive

Moves the chat to the archived folder (`archive: true`), removing it from the main list without deleting history. Syncs with the other linked devices via app state.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/chat/archive/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "number":  "5511999999999",
      "archive": true
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/chat/archive/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      number:  "5511999999999",
      archive: true
    })
  });
  ```

  ```python Python theme={null}
  import os, requests

  requests.post(
      f"https://ryzeapi.cloud/api/chat/archive/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "number":  "5511999999999",
          "archive": True
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{
          "number":  "5511999999999",
          "archive": true
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/chat/archive/"+os.Getenv("Instance_Name"), body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

### Unarchive

Takes the chat out of the archived folder (`archive: false`) and brings it back to the main list. The operation is propagated to all linked devices.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/chat/archive/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "number":  "5511999999999",
      "archive": false
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/chat/archive/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      number:  "5511999999999",
      archive: false
    })
  });
  ```

  ```python Python theme={null}
  import os, requests

  requests.post(
      f"https://ryzeapi.cloud/api/chat/archive/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "number":  "5511999999999",
          "archive": False
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
      "strings"
  )

  func main() {
      body := strings.NewReader(`{
          "number":  "5511999999999",
          "archive": false
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/chat/archive/"+os.Getenv("Instance_Name"), body)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      req.Header.Set("Content-Type", "application/json")
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

## Success response

The response confirms the operation with `chat_jid` (JID resolved from `number`) and `archived` reflecting the final state. The `message` changes depending on the value of `archive`: `"Chat archived successfully"` or `"Chat unarchived successfully"`.

```json 200 OK theme={null}
{
  "success": true,
  "message": "Chat archived successfully",
  "chat_jid": "5511999999999@s.whatsapp.net",
  "archived": true
}
```

## Path parameters

<ParamField path="instance" type="string" required>
  Instance name.
</ParamField>

## Headers

| Name           | Required                 | Example            | Description                    |
| -------------- | ------------------------ | ------------------ | ------------------------------ |
| `Content-Type` | yes                      | `application/json` | ,                              |
| `token`        | yes (or `Authorization`) | `a1b2c3d4-...`     | TokenAccount or TokenInstance. |

## Request body

<ParamField body="number" type="string" required>
  Phone number, private JID (`...@s.whatsapp.net` or `...@lid`), group JID (`...@g.us`), or newsletter.
</ParamField>

<ParamField body="archive" type="boolean" required>
  `true` archives, `false` unarchives.
</ParamField>

## Error responses

| HTTP | `error.message`                         | When it happens |
| ---- | --------------------------------------- | --------------- |
| 400  | `Instance name is required`             | ,               |
| 400  | `Invalid request body: <...>`           | Malformed JSON. |
| 400  | `Number is required`                    | ,               |
| 401  | `Invalid token`                         | ,               |
| 404  | `Instance not found`                    | ,               |
| 503  | `Instance is not connected to WhatsApp` | ,               |

```json Error 400 theme={null}
{
  "success": false,
  "error": { "message": "Number is required" }
}
```

## Related

<CardGroup cols={2}>
  <Card title="Pin chat" href="/en/api/chat/pinChat">
    `POST /api/chat/pinChat/:instance`
  </Card>

  <Card title="Mute chat" href="/en/api/chat/mute">
    `POST /api/chat/mute/:instance`
  </Card>
</CardGroup>
