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

# Sending OTPs

> Send one-time codes with your authentication template.

Send a code with your approved **authentication** template. If you have only one, you can leave the template out.

```bash cURL theme={null}
curl https://api.getreply.in/v1/messages/otp \
  -H "Authorization: Bearer gr_live_…" \
  -H "Idempotency-Key: otp-login-7781" \
  -H "Content-Type: application/json" \
  -d '{"to": "+9198250*****", "code": "482913"}'
```

```javascript Node.js theme={null}
const res = await fetch("https://api.getreply.in/v1/messages/otp", {
  method: "POST",
  headers: {
    "Authorization": "Bearer gr_live_…",
    "Idempotency-Key": "otp-login-7781",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "to": "+9198250*****",
    "code": "482913"
  }),
});
console.log(await res.json());
```

```php PHP theme={null}
<?php
$ch = curl_init("https://api.getreply.in/v1/messages/otp");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer gr_live_…",
    "Idempotency-Key: otp-login-7781",
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => '{"to": "+9198250*****", "code": "482913"}',
]);
echo curl_exec($ch);
```

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

res = requests.post(
    "https://api.getreply.in/v1/messages/otp",
    headers={
        "Authorization": "Bearer gr_live_…",
        "Idempotency-Key": "otp-login-7781",
    },
    json={
        "to": "+9198250*****",
        "code": "482913"
    },
)
print(res.json())
```

* The code has no spaces. See [Limits](https://docs.getreply.in/guides/limits.md) for its length.
* OTP templates can only be sent one by one, never in a campaign (`otp_not_in_campaigns`).
* No authentication template yet? You get `otp_template_missing`. Make one in the app or with `POST /v1/templates`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.