# Agendar mensagem para horário específico

`POST /scheduler/schedule`

Pasta: **Scheduler**

## Autenticação

```http
token: {{token}}
```

## Descrição

# Agendar mensagem para horário específico

Agenda o envio de uma mensagem em um instante absoluto (RFC3339). Use para lembretes e campanhas com data/hora fixa.

## Endpoint

`POST {{baseUrl}}/scheduler/schedule`

## Autenticação

Envie o token da instância no header `token: {{token}}`.

## Corpo da requisição

| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| `jid` | string | Sim | Destinatário (ex.: `5511...@s.whatsapp.net` ou grupo `@g.us`). |
| `content_type` | string | Sim | Tipo do conteúdo: `text`, `media`, `location`, `contact` ou `interactive`. |
| `content` | object | Sim | Payload do conteúdo (ex.: `{ "text": "..." }` para texto). |
| `scheduled_at` | string | Sim | Data/hora em RFC3339 (ex.: `2026-07-20T14:30:00Z`). |
| `timezone` | string | Não | Fuso horário informativo (ex.: `America/Sao_Paulo`). |

## Exemplo de Requisição

```bash
curl --request POST '{{baseUrl}}/scheduler/schedule' \
  --header 'token: {{token}}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "jid": "5511999999999@s.whatsapp.net",
  "content_type": "text",
  "content": {
    "text": "Lembrete: sua consulta é amanhã às 10h."
  },
  "scheduled_at": "2026-07-20T14:30:00Z",
  "timezone": "America/Sao_Paulo"
}'
```

## Resposta de Sucesso

```json
{
  "success": true,
  "message": {
    "id": "01HSCHEDMSGIDEXAMPLE00001",
    "instance_id": "01HINSTANCEIDEXAMPLE00001",
    "jid": "5511999999999@s.whatsapp.net",
    "content_type": "text",
    "content": {"text": "Lembrete: sua consulta é amanhã às 10h."},
    "scheduled_at": "2026-07-20T14:30:00Z",
    "timezone": "America/Sao_Paulo",
    "status": "pending",
    "error": "",
    "message_id": "",
    "sent_at": null
  }
}
```

## Erros comuns

- `401 Unauthorized`: o header `token` não foi enviado ou é inválido.
- `400 Bad Request`: JSON inválido ou `scheduled_at` fora do formato RFC3339.
- `500 Internal Server Error`: fila cheia (`scheduled message queue is full`) ou falha ao agendar.

## Observações

- O horário é normalizado para UTC no armazenamento.
- Esta rota **não** exige modo mobile.

## Corpo (exemplo)

```json
{
  "jid": "5511999999999@s.whatsapp.net",
  "content_type": "text",
  "content": {
    "text": "Lembrete: sua consulta é amanhã às 10h."
  },
  "scheduled_at": "2026-07-20T14:30:00Z",
  "timezone": "America/Sao_Paulo"
}
```

## cURL

```bash
curl -X POST "{{baseUrl}}/scheduler/schedule" \
  -H "token: {{token}}" \
  -H "Content-Type: application/json" \
  -d '{
  "jid": "5511999999999@s.whatsapp.net",
  "content_type": "text",
  "content": {
    "text": "Lembrete: sua consulta é amanhã às 10h."
  },
  "scheduled_at": "2026-07-20T14:30:00Z",
  "timezone": "America/Sao_Paulo"
}'
```

---

[Índice da pasta](./index.md) · [Índice geral](../index.md) · [UI](https://gozap.dev/docs?op=scheduler/agendar-mensagem-para-horario-especifico)
