> ## 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.

# Arquivar chat

> Arquiva ou desarquiva um chat no WhatsApp

**Auth:** `TokenAccount` ou `TokenInstance` • **Rate-limit:** `Global` (100/min) • **Idempotente:** sim

## Descrição

Arquiva (`archive: true`) ou desarquiva (`archive: false`) um chat. A operação é propagada para o WhatsApp via app state, pode levar segundos até refletir nos demais dispositivos vinculados.

## Exemplos

### Arquivar

Move o chat para a pasta de arquivados (`archive: true`), removendo-o da lista principal sem apagar o histórico. Sincroniza com os demais dispositivos vinculados 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>

### Desarquivar

Tira o chat da pasta de arquivados (`archive: false`) e o traz de volta para a lista principal. A operação é propagada para todos os dispositivos vinculados.

<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>

## Resposta de sucesso

A resposta confirma a operação com `chat_jid` (JID resolvido a partir do `number`) e `archived` refletindo o estado final. A `message` muda conforme o valor de `archive`: `"Chat archived successfully"` ou `"Chat unarchived successfully"`.

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

## Parâmetros de rota

<ParamField path="instance" type="string" required>
  Nome da instância.
</ParamField>

## Headers

| Nome           | Obrigatório              | Exemplo            | Descrição                      |
| -------------- | ------------------------ | ------------------ | ------------------------------ |
| `Content-Type` | sim                      | `application/json` | ,                              |
| `token`        | sim (ou `Authorization`) | `a1b2c3d4-...`     | TokenAccount ou TokenInstance. |

## Request body

<ParamField body="number" type="string" required>
  Telefone, JID privado (`...@s.whatsapp.net` ou `...@lid`), JID de grupo (`...@g.us`) ou newsletter.
</ParamField>

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

## Respostas de erro

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

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

## Relacionados

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

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