> For the complete documentation index, see [llms.txt](https://valify.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://valify.gitbook.io/documentation/apis/otp.md).

# OTP

***

The OTP service enables you to send & verify a 6-digit one-time password (OTP) to an Egyptian Mobile Phone number via SMS. Please note that this services does not include non-Egyptian number.

The format of the phone number should be an 11-digit string that begins with "01", as follows: 01xxxxxxxxx.

***

There are 2 API endpoints provided for this service:

1. Send OTP: sends the one-time password to the provided phone number via SMS
2. Verify OTP: receives the user-entered OTP and verifies that it is the one sent to them.

An OTP attempt expires after 10 minutes. After that, you'll need to send another OTP to verify, since you cannot verify expired OTPs.&#x20;

## Code Snippets

{% tabs %}
{% tab title="Python 3" %}

```python
import requests
import base64

token = '<token>'
data = {
    'otp': '<6-digit otp>',
    'transaction_id': '<transaction id from Send OTP step>',
    'bundle_key': '<bundle key>',
    'lang': '<str>' # optional, default: en
}

r = requests.post("https://<base-url>/api/v1/otp/verify/",
        json=data,
        headers={'Authorization': 'Bearer %s' % token}
    )
                      
print(r.json())
```

{% endtab %}
{% endtabs %}

## Postman Collection

{% file src="/files/-MjLSWnMjv2-4ECI8dRY" %}
OTP (v1)
{% endfile %}
