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

> Send a one-time password to a WhatsApp number

Send a numeric OTP to a customer over WhatsApp using one of your approved authentication templates.

## Endpoint

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

### Request body

<ParamField body="to" type="string" required>
  Recipient's phone number in E.164 format, e.g. `+919876543210`.
</ParamField>

<ParamField body="length" default="6" type="integer">
  Number of digits in the generated code. Accepts 4–8.
</ParamField>

<ParamField body="expiry_seconds" default="300" type="integer">
  How long the code stays valid.
</ParamField>

<ParamField body="template" type="string">
  Name of the approved authentication template to use. If omitted, Tanvik uses the most recently approved authentication-category template on your account — if you don't have one yet, the request fails with `no_default_otp_template`.
</ParamField>

### Response

<ResponseField name="otp_id" type="string">
  Unique identifier for this OTP request (a UUID) — pass this to the verify endpoint.
</ResponseField>

<ResponseField name="status" type="string">
  `sent` once accepted by WhatsApp.
</ResponseField>

<ResponseField name="expires_at" type="string">
  ISO 8601 timestamp when the code stops being valid.
</ResponseField>

<CodeGroup>
  ```bash cURL theme={null}
  curl https://xwialxkobwygraiddimj.supabase.co/functions/v1/public-api/v1/otp/send \
    -H "Authorization: Bearer tvk_live_xxxxxxxxxxxxxxxx" \
    -H "Content-Type: application/json" \
    -d '{ "to": "+919876543210", "length": 6, "expiry_seconds": 300 }'
  ```

  ```javascript Node.js theme={null}
  const res = await fetch('https://xwialxkobwygraiddimj.supabase.co/functions/v1/public-api/v1/otp/send', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer tvk_live_xxxxxxxxxxxxxxxx',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ to: '+919876543210', length: 6, expiry_seconds: 300 })
  });
  const data = await res.json();
  ```

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

  res = requests.post(
    "https://xwialxkobwygraiddimj.supabase.co/functions/v1/public-api/v1/otp/send",
    headers={"Authorization": "Bearer tvk_live_xxxxxxxxxxxxxxxx"},
    json={"to": "+919876543210", "length": 6, "expiry_seconds": 300}
  )
  ```
</CodeGroup>

```json Response theme={null}
{
  "otp_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "status": "sent",
  "expires_at": "2026-07-14T18:35:00Z"
}
```

<Note>
  OTP messages use WhatsApp authentication-category templates, which have separate approval and pricing from marketing/utility templates. See [Create Templates](/whatsapp/create-templates).
</Note>
