> For the complete documentation index, see [llms.txt](https://docs.bizmagnets.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bizmagnets.ai/whatsapp-otp/otp-authentication.md).

# OTP Authentication

The WhatsApp OTP (One-Time Password) functionality in BizMagnets enables businesses to send OTPs via WhatsApp as part of user authentication, secure logins, or verification processes.

This guide will walk you through using the API to send OTPs efficiently through WhatsApp, leveraging BizMagnets platform and Meta's WhatsApp Business API.

## Send OTP

<mark style="color:green;">`POST`</mark> `https://api.bizmagnets.ai/otp/{{otp_config_uid}}/sendOTP`

[`X-API-KEY`](https://app.bizmagnets.ai/ApiKey) - You can find the API keys under the settings.&#x20;

This unique ID `"5a706684-851f-3a27-b0d1-284155d8f862"` is used for OTP tracking. You'll need this for the OTP verification step.

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| X-API-KEY    | `{{api_key}}`      |

**Body**

<table><thead><tr><th width="199">Name</th><th width="119">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td>string</td><td>The name of the recipient.</td></tr><tr><td><code>mobileNumber</code></td><td>string</td><td>The recipient's mobile number (without country code).</td></tr><tr><td><code>countryCode</code></td><td>string</td><td>The country code for the recipient's mobile number.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="201" %}

```json
{
  "id": "5a706684-851f-3a27-b0d1-284155d8f862",
  "message": "success"
}
```

{% endtab %}
{% endtabs %}

## Verify OTP

<mark style="color:green;">`POST`</mark> `https://api.bizmagnets.ai/otp/{{otp_uid}}/verifyOTP`

To verify the OTP entered by the user, you must use the same `otp_uid` returned in the response from the **Send OTP** request. This ensures that the OTP being verified matches the one generated for that specific request.

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |
| X-API-KEY    | `{{api_key}}`      |

**Body**

<table><thead><tr><th width="199">Name</th><th width="119">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>otp</code></td><td>string</td><td>The OTP entered by the user for verification.</td></tr><tr><td><code>mobileNumber</code></td><td>string</td><td>The recipient's mobile number (without country code).</td></tr><tr><td><code>countryCode</code></td><td>string</td><td>The country code for the recipient's mobile number.</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "id": "5a706684-851f-3a27-b0d1-284155d8f862",
  "message": "success"
}
```

{% endtab %}

{% tab title="410" %}

```json
{
    "timestamp": "2024-10-22T11:28:35.911Z",
    "status": 403,
    "error": "Forbidden",
    "path": "/api/otp/y23823/verifyOtp"
}

```

{% endtab %}
{% endtabs %}
