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

# Unirse al grupo

> Únete a un grupo mediante código o enlace de invitación

**Auth:** `TokenAccount` o `TokenInstance` • **Rate-limit:** `Global` (100/min) • **Idempotente:** parcial (las llamadas repetidas en un grupo abierto devuelven el mismo `groupJid`)

## Descripción

Une al cliente a un grupo a partir de un **código** de invitación (`ABC123XYZ`) o de un **enlace** completo (`https://chat.whatsapp.com/ABC123XYZ`). Si el grupo tiene `requireAdminApproval=true`, la unión queda en cola y devuelve `requiresApproval: true`.

<Warning>
  A diferencia de las otras rutas, `/join` **no acepta un JID** como identifier, solo un código o enlace.
</Warning>

## Ejemplos

### Por enlace

Se une al grupo pasando el enlace completo (`https://chat.whatsapp.com/ABC123XYZ`) en `identifier`. El servicio extrae el código automáticamente e intenta la unión.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/group/join/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "identifier": "https://chat.whatsapp.com/ABC123XYZ"
    }'
  ```

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

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

  requests.post(
      f"https://ryzeapi.cloud/api/group/join/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "identifier": "https://chat.whatsapp.com/ABC123XYZ"
      }
  )
  ```

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

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

  func main() {
      body := strings.NewReader(`{
          "identifier": "https://chat.whatsapp.com/ABC123XYZ"
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/group/join/"+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>

### Por código

Se une al grupo pasando solo el código bruto (`ABC123XYZ`) en `identifier`. Útil cuando ya extrajiste el código del enlace en otro flujo.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/group/join/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "identifier": "ABC123XYZ"
    }'
  ```

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

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

  requests.post(
      f"https://ryzeapi.cloud/api/group/join/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "identifier": "ABC123XYZ"
      }
  )
  ```

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

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

  func main() {
      body := strings.NewReader(`{
          "identifier": "ABC123XYZ"
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/group/join/"+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

El `groupJid` identifica el grupo al que la instancia se unió (o intentó unirse). Cuando `requiresApproval: true`, la unión **aún no** se efectivizó, está esperando aprobación manual de un administrador; revisa la cola de pendientes con [`/requests`](/es/api/groups/requests). Cuando es `false`, la instancia ya es miembro y puede enviar/recibir mensajes.

```json 200 OK theme={null}
{
  "success": true,
  "message": "Successfully joined the group",
  "groupJid": "120363406289005073@g.us",
  "requiresApproval": false
}
```

```json 200 OK (con aprobación manual) theme={null}
{
  "success": true,
  "message": "Join request sent successfully. Waiting for admin approval.",
  "groupJid": "120363406289005073@g.us",
  "requiresApproval": true
}
```

## Parámetros de ruta

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

## Cabeceras

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

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

## Cuerpo de la solicitud

<ParamField body="identifier" type="string" required>
  Código de invitación (`ABC123XYZ`) o enlace completo (`https://chat.whatsapp.com/ABC123XYZ`).
</ParamField>

## Notas

<Note>
  * `requiresApproval: true` significa que **aún no** te uniste, tu solicitud está en la cola listada por [`/requests`](/es/api/groups/requests) hasta que un administrador la apruebe.
  * Cuando el enlace ha sido revocado por un administrador (mediante [`/resetLink`](/es/api/groups/reset-link)), el código antiguo deja de funcionar inmediatamente.
  * Para previsualizar el grupo sin unirte, usa [`GET /info`](/es/api/groups/info) con el enlace como `identifier`.
</Note>

## Errores

| HTTP | Mensaje                                   |
| ---- | ----------------------------------------- |
| 400  | `Invalid invite link or code`             |
| 400  | `Invite link has been revoked or expired` |
| 403  | `Not allowed to join this group`          |
| 404  | `Group not found`                         |

Envoltorio:

```json theme={null}
{
  "success": false,
  "error": { "message": "Invite link has been revoked or expired" }
}
```
