# OTP (One Time Password)

&#x20;       One-Time Passwords help growing startups and agile enterprises enhance customer experience and realize new business outcomes at scale. With the most comprehensive suite of communication channels, a global platform, and expert support, you can abstract the complexity of communications and innovate faster.

## Request OTP

&#x20;      It is part of ANTS account security offerings, the OTP API makes it simple to add user verification to various application and use cases. It supports codes sent via SMS.

### Sequence Diagram

![Sequence Diagram (API RequestOTP)](/files/-M27YpJU1Wj8J9xDr0tA)

{% tabs %}
{% tab title="Request" %}
**You can start creating HTTP request as this following:**

| Name               | Description                                                                                                |
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
| HTTP Request (URL) | <https://api-service.ants.co.th/otp/requestOTP>                                                            |
| HTTP Headers       | <p>Content-Type: application/json</p><p>Authorization: (Basic Auth) Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</p> |
| HTTP Methods       | POST                                                                                                       |

**Request body should be indicated with these following parameters**

| **Parameters**                                     | type   | **description**                                                                                                                                                                                                                                             |
| -------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| otcId                                              | String | OTP to verify log in and view OTP application configuration                                                                                                                                                                                                 |
| mobile                                             | String | The destination phone number for your SMS message                                                                                                                                                                                                           |
| <p>notifyUrl</p><p><em>(optional)</em></p>         | String | <p>Defending  URL on callback server to get Delivery report according to <a href="/pages/-M1dmGmrI7GQBcR_K6Tn"><em><strong>Send Callback</strong></em></a> link </p><p><code>Example: notifyUrl=https//[www.example.com](http://www.example.com)</code></p> |
| <p>notifyContentType</p><p><em>(optional)</em></p> | String | <p>Preferred Delivery report content type of delivery report to <code>application/json</code> <br><code>Example: notifyContentType=application/json</code></p>                                                                                              |
| <p>callbackData</p><p><em>(optional)</em></p>      | String | Specifies the value to return. When specified, notifyUrl will also return this callbackData.                                                                                                                                                                |

**Request JSON**

```
{
 	"otcId": "0DC8E7AD-0168-440C-AF10-BF556B164D83",
 	"mobile": "66123456789",
  "notifyUrl": "https://testSendOTP",
  "notifyContentType": "application/json",
  "callbackData":"OTP Data"
}
```

{% endtab %}

{% tab title="Response" %}
**OTP Response**

| Parameters    | type   | description                                                                                                                                |
| ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| otcId         | String | OTP to verify log in and view OTP application configuration                                                                                |
| otpId         | String | The ID that uniquely identifies the sent OTP message.                                                                                      |
| referenceCode | String | The reference Code                                                                                                                         |
| status        | Object | Indicates whether the message is successfully sent, not sent, delivered, not delivered, waiting for delivery or any other possible status. |
| message       | String | Name of response status                                                                                                                    |
| description   | String | Description of response status                                                                                                             |

**The response will look like:**

```
{
    	"otcId": "0DC8E7AD-0168-440C-AF10-BF556B164D83",
    	"otpId": "0c342e74-a9c7-4bbd-8da4-b36a49bbc0d6",
    	"referenceCode": "IpA6k",    	
    	"success": {
        		"message": "success",
        		"description": ""
    	}
}
```

{% endtab %}
{% endtabs %}

## ResendOTP

&#x20;           It is part of ANTS account security offerings, the OTP API makes it simple to add user verification to various application and use cases. It supports codes sent via SMS again.

### Sequence Diagram

![](/files/-MHK2QfSOiVPIkS8tND9)

{% tabs %}
{% tab title="Request" %}
**You can start creating HTTP request as this following:**

| Name               | Description                                                                                                |
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
| HTTP Request (URL) | <https://api-service.ants.co.th/otp/resendOTP>                                                             |
| HTTP Headers       | <p>Content-Type: application/json</p><p>Authorization: (Basic Auth) Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</p> |
| HTTP Methods       | POST                                                                                                       |

**Request body should be indicated with these following parameters**

| **Parameters** | type   | **description**                                             |
| -------------- | ------ | ----------------------------------------------------------- |
| otcId          | String | OTP to verify log in and view OTP application configuration |

> **Request JSON**
>
> ```
> {
>  	"otcId": "0DC8E7AD-0168-440C-AF10-BF556B164D83",
> }
> ```

{% endtab %}

{% tab title="Response" %}
**Response**

| Parameters    | type   | description                                                                                                                                |
| ------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------ |
| otcId         | String | OTP to verify log in and view OTP application configuration                                                                                |
| otpId         | String | The ID that uniquely identifies the sent OTP message.                                                                                      |
| referenceCode | String | The reference Code                                                                                                                         |
| status        | Object | Indicates whether the message is successfully sent, not sent, delivered, not delivered, waiting for delivery or any other possible status. |
| message       | String | Name of response status                                                                                                                    |
| description   | String | Description of response status                                                                                                             |

**The response will look like:**

```
{
    	"otcId": "0DC8E7AD-0168-440C-AF10-BF556B164D83",
    	"otpId": "0c342e74-a9c7-4bbd-8da4-b36a49bbc0d6",
    	"referenceCode": "IpA6k",    	
    	"success": {
        		"message": "success",
        		"description": ""
    	}
}
```

{% endtab %}
{% endtabs %}

## Verify OTP

&#x20;      Use to verify set of password and verify owner of the account.

### Sequence Diagram

![Sequence Diagram (API VerifyOTP)](/files/-M1z0HHxrnz3TwfNvSW5)

{% tabs %}
{% tab title="Request" %}
You can start using HTTP request as following details:&#x20;

| **Name**           | Description                                                                                                |
| ------------------ | ---------------------------------------------------------------------------------------------------------- |
| HTTP Request (URL) | <https://api-service.ants.co.th/otp/verifyOTP>                                                             |
| HTTP Headers       | <p>Content-Type: application/json</p><p>Authorization: (Basic Auth) Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==</p> |
| HTTP Methods       | POST                                                                                                       |

**Request body should be indicated with these following parameter**

| Parameters | type   | description                                      |
| ---------- | ------ | ------------------------------------------------ |
| otpId      | String | The OTP ID which uniquely identifies the request |
| otpCode    | String | OTP code                                         |

The request JSON will look like:

```
{
    "otpId": "0c342e74-a9c7-4bbd-8da4-b36a49bbc0d6",
   	"otpCode": "79895"
    "notifyUrl": "https://testSendOTP",
    "notifyContentType": "application/json",
    "callbackData":"OTP Data"
}
```

{% endtab %}

{% tab title="Response" %}
OTP Response

| Parameters   | type    | description                                           |
| ------------ | ------- | ----------------------------------------------------- |
| otpId        | String  | The ID which uniquely identifies the OTP request      |
| result       | Boolean | The result of OTP confirmation                        |
| isErrorCount | Boolean | The result of inputting the wrong OTP.                |
| isExprCode   | Boolean | The result of inputting the OTP when time is expired. |

**The response will look like:**

```
{
    	"otpId": "0c342e74-a9c7-4bbd-8da4-b36a49bbc0d6",
    	"result": true,
    	" isErrorCount": false,
    	"isExprCode": false
}
```

{% endtab %}
{% endtabs %}

## Response Status

&#x20;     While using our API you may encounter certain **status** and **error** codes that you need to understand or troubleshoot.       &#x20;

&#x20;      Each code with the descriptions will guild you to take action steps you need to take in case you are looking for a resolution of the problem.

### Status Code

&#x20;       Beside HTTP status code standard, there will be also API response status.

### The response status will look link

```
{
	  "error": {
		"message": "Invalid OTP Config",
		"description": ""
             }
}
```

### Status Code

| Code | Message EN            | Message TH                       |
| ---- | --------------------- | -------------------------------- |
| 0000 | Success               | สำเร็จ                           |
| 9999 | Exception             | ผิดพลาด                          |
| 9998 | Authentication failed | username or password ผิดพลาด     |
| 9996 | Bad Request           | คำสั่งไม่ถูกต้อง                 |
| 9995 | Credit not enough     | เครดิตหมด                        |
| 0301 | Invalid OTP Config    | ตั้งค่า OTP ไม่ถูกต้อง           |
| 0302 | Number Prefix Missing | ไม่มีคำนำหน้า                    |
| 0303 | No Data Available OTP | ไม่พบข้อมูล OTP                  |
| 0304 | Over Limit Usage      | กรอกข้อมูลเกินจำนวนครั้งที่กำหนด |
| 0305 | OTP Code Expired      | OTP Code หมดอายุ                 |
| 0306 | OTP Code Confirmed    | OTP Code ยืนยันตัวตนไปแล้ว       |
| 0307 | Invalid Number        | หมายเลขไม่ถูกต้อง                |


---

# 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://apidoc.ants.co.th/api-otp.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.
