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

# Consultar Websocket

> Retorna la configuración actual del WebSocket de la instancia

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

## Descripción

Retorna la configuración actual del WebSocket de la instancia. Retorna `404` cuando no hay fila en `websocket_configs` (la instancia nunca fue configurada vía `POST`), no existe una "configuración default implícita".

<Note>
  Atención a la ortografía: la ruta correcta es **`getWebsocket`** (con `w` minúscula en `socket`), diferente de `POST /websocket`. Esta inconsistencia es histórica, usa el literal exacto del registro.
</Note>

## Parámetros de ruta

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

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://ryzeapi.cloud/api/events/getWebsocket/$Instance_Name" \
    -H "token: $Token_Instance"
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/events/getWebsocket/${process.env.Instance_Name}`, {
    method: "GET",
    headers: {
      "token": process.env.Token_Instance
    }
  });
  ```

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

  requests.get(
      f"https://ryzeapi.cloud/api/events/getWebsocket/{os.environ['Instance_Name']}",
      headers={
          "token": os.environ["Token_Instance"]
      }
  )
  ```

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

  import (
      "net/http"
      "os"
  )

  func main() {
      req, _ := http.NewRequest("GET", "https://ryzeapi.cloud/api/events/getWebsocket/"+os.Getenv("Instance_Name"), nil)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

## Cabeceras

<ParamField header="token" type="string" required>
  `TokenAccount` o `TokenInstance`.
</ParamField>

## Respuesta exitosa

Retorna el objeto `websocket` con la configuración actual: `enabled`, `events` y `mediaBase64`. Nota: `404` significa "nunca configurado" (sin fila en `websocket_configs`), **diferente** de `enabled=false` (que retorna `200` con la fila persistida y los campos limpios). Maneja ambos casos en el cliente.

```json 200 OK theme={null}
{
  "success": true,
  "message": "WebSocket configuration retrieved",
  "websocket": {
    "enabled":     true,
    "events":      ["message.exchange"],
    "mediaBase64": false
  }
}
```

```json 200 OK (disabled) theme={null}
{
  "success": true,
  "message": "WebSocket configuration retrieved",
  "websocket": {
    "enabled":     false,
    "events":      [],
    "mediaBase64": false
  }
}
```

## Errores

| HTTP | `error.message`                              |
| ---- | -------------------------------------------- |
| 401  | `Invalid token`                              |
| 404  | `Instance not found`                         |
| 404  | `WebSocket not configured for this instance` |
| 429  | `Rate limit exceeded. Try again later.`      |
| 500  | `Failed to get instance`                     |
| 500  | `Failed to get websocket configuration`      |

Envoltorio:

```json theme={null}
{
  "success": false,
  "error": { "message": "WebSocket not configured for this instance" }
}
```

## Notas

<Note>
  * **`404` ≠ "deshabilitado"**: `404` significa "nunca se creó una fila"; un `enabled=false` retorna `200` normalmente con `"enabled": false`. Maneja ambos casos en el cliente.
  * **Sin alias `GET /websocket/:instance`**: a diferencia del webhook, **no existe** alias con la ortografía "regular", solo `getWebsocket` (minúscula).
</Note>

## Siguiente

<CardGroup cols={2}>
  <Card title="Configurar WebSocket" icon="plug" href="/es/api/events/websocket-configure">
    `POST /api/events/websocket/:instance`
  </Card>

  <Card title="Conectar vía WebSocket" icon="bolt" href="/es/api/websocket">
    `GET /ws/:instance`
  </Card>
</CardGroup>
