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

# Archivar chat

> Archiva o desarchiva un chat de WhatsApp

**Auth:** `TokenAccount` o `TokenInstance` • **Rate-limit:** `Global` (100/min) • **Idempotente:** sí

## Descripción

Archiva (`archive: true`) o desarchiva (`archive: false`) un chat. La operación se propaga a WhatsApp vía app state, puede tardar segundos en reflejarse en los demás dispositivos vinculados.

## Ejemplos

### Archivar

Mueve el chat a la carpeta de archivados (`archive: true`), quitándolo de la lista principal sin borrar el historial. Sincroniza con los demás dispositivos vinculados vía 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>

### Desarchivar

Saca el chat de la carpeta de archivados (`archive: false`) y lo regresa a la lista principal. La operación se propaga a todos los 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>

## Respuesta exitosa

La respuesta confirma la operación con `chat_jid` (JID resuelto desde `number`) y `archived` reflejando el estado final. El `message` cambia según el valor de `archive`: `"Chat archived successfully"` o `"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 ruta

<ParamField path="instance" type="string" required>
  Nombre de la instancia.
</ParamField>

## Cabeceras

| Nombre         | Requerido              | Ejemplo            | Descripción                   |
| -------------- | ---------------------- | ------------------ | ----------------------------- |
| `Content-Type` | sí                     | `application/json` | ,                             |
| `token`        | sí (o `Authorization`) | `a1b2c3d4-...`     | TokenAccount o TokenInstance. |

## Cuerpo de la solicitud

<ParamField body="number" type="string" required>
  Número de teléfono, JID privado (`...@s.whatsapp.net` o `...@lid`), JID de grupo (`...@g.us`) o newsletter.
</ParamField>

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

## Respuestas de error

| HTTP | `error.message`                         | Cuándo ocurre    |
| ---- | --------------------------------------- | ---------------- |
| 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 Error 400 theme={null}
{
  "success": false,
  "error": { "message": "Number is required" }
}
```

## Relacionados

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

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