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

# Silenciar chat

> Silencia notificações de um chat por um período definido ou indefinido

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

## Descrição

Silencia (`mute: true`) ou desativa o silenciamento (`mute: false`) de um chat. O parâmetro `duration` aceita vários formatos legíveis para configurar a janela.

## Exemplos

### Silenciar 8h

Silencia o chat por uma janela de 8 horas com `duration: "8h"`. Ao fim do período, as notificações voltam automaticamente sem necessidade de outra chamada.

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

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

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

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

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

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

  func main() {
      body := strings.NewReader(`{
          "number":   "5511999999999",
          "mute":     true,
          "duration": "8h"
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/chat/mute/"+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>

### Silenciar permanente

Com `duration: "always"` (aceita `"forever"` e `"permanent"` também), o chat fica silenciado indefinidamente, até que você envie outra chamada com `mute: false`.

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

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

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

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

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

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

  func main() {
      body := strings.NewReader(`{
          "number":   "5511999999999",
          "mute":     true,
          "duration": "always"
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/chat/mute/"+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>

### Desativar

Com `mute: false`, remove qualquer silenciamento ativo no chat e volta a entregar notificações normalmente. O campo `duration` é ignorado nesta variante.

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

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

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

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

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

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

  func main() {
      body := strings.NewReader(`{
          "number": "5511999999999",
          "mute":   false
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/chat/mute/"+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

`muted` indica o estado final e `duration` vem em segundos (`28800` = 8h, `604800` = 1 semana, `0` = permanente ou desativado). A `message` muda conforme a operação: `"Chat muted permanently"`, `"Chat muted for 8 hours"`, `"Chat muted for 1 week"` ou `"Chat notifications unmuted successfully"`.

```json 200 OK theme={null}
{
  "success": true,
  "message": "Chat muted for 8 hours",
  "chat_jid": "5511999999999@s.whatsapp.net",
  "muted": true,
  "duration": 28800
}
```

## 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="mute" type="boolean" required>
  `true` silencia, `false` desfaz.
</ParamField>

<ParamField body="duration" type="string">
  Tempo de silenciamento. Aceita os formatos da tabela abaixo. Ignorado quando `mute=false`.
</ParamField>

### Valores aceitos para `duration`

| Valor                                  | Significado   |
| -------------------------------------- | ------------- |
| `"8h"` ou `"8 hours"`                  | 8 horas       |
| `"1w"`, `"7d"` ou `"1 week"`           | 1 semana      |
| `"always"`, `"forever"`, `"permanent"` | Sem expiração |
| (vazio)                                | Sem expiração |

## Respostas de erro

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

```json Erro 400 theme={null}
{
  "success": false,
  "error": { "message": "Invalid duration: 5y" }
}
```

## Relacionados

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

  <Card title="Bloquear contato" href="/pt/api/chat/block">
    `POST /api/chat/block/:instance`
  </Card>
</CardGroup>
