# OTP API

OTP API can be used to generate and validate PINs in VAS campaigns, ensuring secure and efficient user authentication.

### **Common Parameters**

<table data-header-hidden><thead><tr><th width="150">Path</th><th width="150"> </th><th> </th></tr></thead><tbody><tr><td><strong>Query</strong></td><td><strong>Type</strong></td><td><strong>Description</strong></td></tr><tr><td>key</td><td>String</td><td>API Key</td></tr><tr><td>aid</td><td>Integer</td><td>Affiliate Id</td></tr><tr><td>mid</td><td>Integer</td><td>Your Advertiser MID</td></tr></tbody></table>

## Generate OTP

```
POST https://api.offer18.com/api/af/otp_gen
```

### Request Parameters

<table data-header-hidden><thead><tr><th width="212.5555419921875"></th><th width="191"></th><th></th></tr></thead><tbody><tr><td><strong>Body</strong></td><td><strong>Type</strong></td><td><strong>Description</strong>  </td></tr><tr><td>type</td><td>string</td><td>Type of request</td></tr><tr><td>userId</td><td>string</td><td>User ID (under Partner)</td></tr><tr><td>msisdn</td><td>string</td><td>Mobile number (numeric)</td></tr><tr><td>partner</td><td>string</td><td>Partner name</td></tr></tbody></table>

<pre data-overflow="wrap"><code><strong>https://api.offer18.com/api/af/otp_gen?key=000000000&#x26;aid=0000&#x26;mid=0000&#x26;msisdn=xxxxxxxx&#x26;partner=partnername&#x26;userId=xxxx
</strong></code></pre>

{% code title="Success" overflow="wrap" %}

```json
{
  "status": "200",
  "response": "otp_sent",
  "data": "6xxxxx00f3fa55axxxxxxxxxx567a" // data[requestId] key and value return when patner api return in response 
} 
```

{% endcode %}

{% code title="Failure" overflow="wrap" %}

```json
{     
  "status": "400",     
  "error": "invalid_user_credentials" 
}
```

{% endcode %}

***

## Verify OTP

```
POST https://api.offer18.com/api/af/otp_verify
```

### Request Parameters

<table data-header-hidden><thead><tr><th width="212.5555419921875"></th><th width="191"></th><th></th></tr></thead><tbody><tr><td><strong>Body</strong></td><td><strong>Type</strong></td><td><strong>Description</strong>  </td></tr><tr><td>userId</td><td>string</td><td>User ID</td></tr><tr><td>msisdn</td><td>string</td><td>Mobile number</td></tr><tr><td>otp</td><td>string</td><td>OTP received by the user</td></tr><tr><td>partner</td><td>string</td><td>Partner name</td></tr><tr><td>request_id</td><td>string</td><td>Request ID for tracking</td></tr></tbody></table>

{% code overflow="wrap" %}

```
https://api.offer18.com/api/af/otp_verify?key=000000000&aid=0000&mid=0000&msisdn=xxxxxxxx&partner=partnername&userId=xxxx&request_id=xxxxx&otp=xxxxx
```

{% endcode %}

### Example API Response

{% code title="Success" overflow="wrap" %}

```json
{     
  "status": "200",     
  "response": "otp_verified" 
} 
```

{% endcode %}

{% code title="Failure" overflow="wrap" %}

```json
{     
  "status": "400",     
  "error": "invalid_user_credentials" 
}
```

{% endcode %}

***

{% hint style="info" %}
**For secure interactions, always call the API from the server-side.**
{% endhint %}
