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

# Fijar chat

> Fija o desfija un chat en la parte superior de la lista

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

## Descripción

Marca un chat como fijado (`pin: true`) o quita el fijado (`pin: false`).

<Warning>
  WhatsApp limita a **3 chats fijados** simultáneamente. Intentar fijar un cuarto devuelve un error de WhatsMeow propagado a la respuesta.
</Warning>

## Ejemplos

### Fijar

Con `pin: true`, el chat se mueve al inicio de la lista. Recuerda que WhatsApp permite como máximo 3 chats fijados al mismo tiempo, intentar un cuarto devuelve un error.

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

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

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

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

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

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

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

### Desfijar

Con `pin: false`, quita el fijado y el chat regresa al orden normal por actividad. Libera un slot del límite de 3 chats fijados.

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

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

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

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

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

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

  func main() {
      body := strings.NewReader(`{
          "number": "5511999999999",
          "pin":    false
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/chat/pinChat/"+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 `pinned` reflejando el estado final. El `message` cambia según el valor de `pin`: `"Chat pinned successfully"` o `"Chat unpinned successfully"`.

```json 200 OK theme={null}
{
  "success": true,
  "message": "Chat pinned successfully",
  "chat_jid": "5511999999999@s.whatsapp.net",
  "pinned": 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="pin" type="boolean" required>
  `true` fija, `false` desfija.
</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="Archivar chat" href="/es/api/chat/archive">
    `POST /api/chat/archive/:instance`
  </Card>

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