# OTP Authentication

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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bizmagnets.ai/whatsapp-otp/otp-authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
