# Send Phone OTP

***

## <mark style="color:blue;">Send OTP</mark>

<mark style="color:green;">`POST`</mark> `https://valifystage.com/api/v1/otp/send/`

#### Headers

| Name          | Type   | Description            |
| ------------- | ------ | ---------------------- |
| Content-Type  | string | application/json       |
| Authorization | string | Bearer \<access-token> |

#### Request Body

| Name | Type   | Description                                                                                                                                                                                            |
| ---- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| data | object | <p>Object containing the parameters below:<br><code>{</code> <br>  <code>phone\_number: \<str>,</code><br>  <code>bundle\_key: \<str>,</code><br>  <code>lang: \<str></code><br><code>}</code><br></p> |

#### Status Codes

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

```python
{
    'result': {
        'success': true
    }, 
    'transaction_id': '<string>',
    'trials_remaining': '<int>'
}
```

{% endtab %}

{% tab title="400 Missing input data" %}

```python
{
    "message": "Bad Request – invalid request received (e.g. missing Bundle key, required parameters or invalid json) | Make sure all the required parameters are included"
}
```

{% endtab %}

{% tab title="401 Invalid bundle key" %}

```python
{
    "message": "Unauthorized – your Bundle key is invalid"
}
```

{% endtab %}

{% tab title="403 Access token error" %}

```python
{
    "message": "Forbidden – specified access_token could not be found"
}
```

{% endtab %}

{% tab title="404 Check the endpoint" %}

```python
{
    "message": "Not Found"
}
```

{% endtab %}

{% tab title="415 The format should be base64" %}

```python
{
    "message": "Unsupported Media Type"
}
```

{% endtab %}

{% tab title="422 Check Valify error codes" %}

```python
{
    "message": "<error-description>",
    "error_code": <valify-error-code>
}
```

{% endtab %}

{% tab title="500 Contact us" %}

```python
{
    "message": "Internal Server Error"
}
```

{% endtab %}
{% endtabs %}

## Code Snippets

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

```python
import requests
import base64

token = '<token>' # Place your token here
data = {
    'bundle_key': '<bundle key>', # Place your bundle key here
    'phone_number': '<egyptian phone number>', # Place the phone number here
    'lang': '<str>' # optional, default: en
}

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

{% endtab %}
{% endtabs %}
