> ## Documentation Index
> Fetch the complete documentation index at: https://developers.tanvik.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Templates

> Send an approved template to one or many recipients

Send an approved template message to a single recipient, or to a small batch at once.

## Endpoint

```text theme={null}
POST https://xwialxkobwygraiddimj.supabase.co/functions/v1/public-api/v1/messages
```

### Request body

<ParamField body="to" type="string | string[]" required>
  A single E.164 number, or an array of **up to 100** numbers.
</ParamField>

<ParamField body="type" type="string" required>
  Must be `template` for this use case.
</ParamField>

<ParamField body="template" type="object" required>
  <Expandable title="properties" />
</ParamField>

### Response

A single recipient returns one message object. Multiple recipients return a batch summary **plus a per-recipient results array** — there's no separate polling endpoint; the `message_id` in each result is what you look up via `GET /v1/messages/{message_id}`.

<CodeGroup>
  ```bash Single send theme={null}
  curl https://xwialxkobwygraiddimj.supabase.co/functions/v1/public-api/v1/messages \
    -H "Authorization: Bearer tvk_live_xxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "to": "+919876543210",
      "type": "template",
      "template": {
        "name": "order_shipped",
        "language": "en",
        "variables": ["Priya", "#4821", "July 16"]
      }
    }'
  ```

  ```bash Small batch theme={null}
  curl https://xwialxkobwygraiddimj.supabase.co/functions/v1/public-api/v1/messages \
    -H "Authorization: Bearer tvk_live_xxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{
      "to": ["+919876543210", "+919812345678"],
      "type": "template",
      "template": { "name": "festive_offer", "language": "en", "variables": ["Priya"] }
    }'
  ```
</CodeGroup>

```json Response (single) theme={null}
{
  "message_id": "5a9e6f1c-9e2f-4b1c-8a5c-7e8f9a0b1c2d",
  "status": "accepted"
}
```

```json Response (batch) theme={null}
{
  "batch_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "recipient_count": 2,
  "failed_count": 0,
  "status": "queued",
  "results": [
    { "to": "+919876543210", "ok": true, "message_id": "5a9e6f1c-9e2f-4b1c-8a5c-7e8f9a0b1c2d" },
    { "to": "+919812345678", "ok": true, "message_id": "8b2d4e5f-1a3b-4c5d-9e6f-7a8b9c0d1e2f" }
  ]
}
```

<Warning>
  This endpoint sends recipients concurrently, not through the wave-throttled broadcast engine the dashboard uses. It's built for small, immediate sends (confirmations, alerts) — **for anything larger than 100 recipients, use the dashboard's broadcast tool**, which paces sends properly for large audiences.
</Warning>

<Note>
  There's no `batch_id` lookup endpoint yet — track individual sends via the `results` array's `message_id`s, or via the `message.status` webhook.
</Note>
