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

# Programar Llamada

> Programa una llamada, creando un enlace y enviando una tarjeta de evento con el enlace, el título y la hora de inicio

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

## Descripción

Programa una **llamada de WhatsApp** para el futuro. Crea un enlace de llamada y envía, en el chat del número indicado, una tarjeta de evento de llamada programada que contiene ese enlace, el título (`name`) y la hora de inicio (`startTime`). El destinatario ve la tarjeta del evento y puede abrir el enlace para unirse cuando llegue la hora. Usa el campo `video` para elegir entre un enlace de audio (por defecto) o de video.

<Note>
  `startTime` (y `endTime`, cuando se indica) usan **timestamp Unix en segundos**, no en milisegundos, y `startTime` debe estar en el futuro.
</Note>

## Ejemplos

### Programación simple

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/call/schedule/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "number": "5511999999999",
      "name": "Reunión de equipo",
      "startTime": 1751500000
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/call/schedule/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      number: "5511999999999",
      name: "Reunión de equipo",
      startTime: 1751500000
    })
  });
  ```

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

  requests.post(
      f"https://ryzeapi.cloud/api/call/schedule/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "number": "5511999999999",
          "name": "Reunión de equipo",
          "startTime": 1751500000
      }
  )
  ```

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

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

  func main() {
      body := strings.NewReader(`{
          "number": "5511999999999",
          "name": "Reunión de equipo",
          "startTime": 1751500000
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/call/schedule/"+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>

### Con descripción, término y recordatorio

`description` agrega una agenda al evento, `endTime` marca la hora de término y `reminderOffsetSec` define cuántos segundos antes del inicio se muestra un recordatorio al destinatario.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://ryzeapi.cloud/api/call/schedule/$Instance_Name" \
    -H "token: $Token_Instance" \
    -H "Content-Type: application/json" \
    -d '{
      "number": "5511999999999",
      "name": "Reunión de equipo",
      "description": "Alineación semanal del equipo",
      "startTime": 1751500000,
      "endTime": 1751503600,
      "video": true,
      "reminderOffsetSec": 900
    }'
  ```

  ```javascript JavaScript theme={null}
  await fetch(`https://ryzeapi.cloud/api/call/schedule/${process.env.Instance_Name}`, {
    method: "POST",
    headers: {
      "token":        process.env.Token_Instance,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      number: "5511999999999",
      name: "Reunión de equipo",
      description: "Alineación semanal del equipo",
      startTime: 1751500000,
      endTime: 1751503600,
      video: true,
      reminderOffsetSec: 900
    })
  });
  ```

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

  requests.post(
      f"https://ryzeapi.cloud/api/call/schedule/{os.environ['Instance_Name']}",
      headers={
          "token":        os.environ["Token_Instance"],
          "Content-Type": "application/json"
      },
      json={
          "number": "5511999999999",
          "name": "Reunión de equipo",
          "description": "Alineación semanal del equipo",
          "startTime": 1751500000,
          "endTime": 1751503600,
          "video": True,
          "reminderOffsetSec": 900
      }
  )
  ```

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

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

  func main() {
      body := strings.NewReader(`{
          "number": "5511999999999",
          "name": "Reunión de equipo",
          "description": "Alineación semanal del equipo",
          "startTime": 1751500000,
          "endTime": 1751503600,
          "video": true,
          "reminderOffsetSec": 900
      }`)
      req, _ := http.NewRequest("POST", "https://ryzeapi.cloud/api/call/schedule/"+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

```json 200 OK theme={null}
{
  "success":   true,
  "messageId": "3EB08FCF27E532F1D3D3",
  "token":     "AbCdEfGhIjKlMnOp",
  "url":       "https://call.whatsapp.com/audio/AbCdEfGhIjKlMnOp",
  "startTime": 1751500000
}
```

<Note>
  `messageId` identifica el mensaje de evento enviado al destinatario. `token` y `url` corresponden al enlace de llamada ya creado, útil si es necesario reenviarlo manualmente. `startTime` confirma la hora de inicio registrada.
</Note>

## Parámetros de ruta

<ParamField path="instance" type="string" required>
  Nombre de la instancia (p. ej., `$Instance_Name`).
</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="number" type="string" required>
  Destino: teléfono (`5511999999999`) o JID (`5511999999999@s.whatsapp.net`).
</ParamField>

<ParamField body="name" type="string" required>
  Título del evento, mostrado en la tarjeta de la llamada programada.
</ParamField>

<ParamField body="startTime" type="integer" required>
  Fecha y hora de inicio de la llamada, como **timestamp Unix (segundos)**. Debe estar en el futuro.
</ParamField>

<ParamField body="description" type="string">
  Descripción o agenda del evento.
</ParamField>

<ParamField body="endTime" type="integer" default="0">
  Fecha y hora de término, como **timestamp Unix (segundos)**. Omitido o `0` indica que no hay término definido. Cuando se indica, debe ser mayor que `startTime`.
</ParamField>

<ParamField body="video" type="boolean" default="false">
  Cuando es `true`, genera un enlace de llamada de **video** en lugar de audio.
</ParamField>

<ParamField body="reminderOffsetSec" type="integer">
  Cuántos segundos antes del inicio se debe mostrar un recordatorio al destinatario.
</ParamField>

## Errores

| HTTP | Mensaje                                          |
| ---- | ------------------------------------------------ |
| 400  | `Instance name is required`                      |
| 400  | `Invalid request body: <detail>`                 |
| 400  | `Number is required`                             |
| 400  | `startTime must be in the future (Unix seconds)` |
| 400  | `endTime must be after startTime`                |
| 404  | `instance not found`                             |
| 500  | `<motivo del fallo>`                             |

Envoltorio de error:

```json theme={null}
{
  "success": false,
  "error": { "message": "startTime must be in the future (Unix seconds)" }
}
```
