# Create Verification Code

<table data-header-hidden><thead><tr><th width="74.8046875" align="center"></th><th></th></tr></thead><tbody><tr><td align="center"><mark style="color:blue;"><strong>POST</strong></mark> </td><td>https://api.sfox.com/v1/enterprise/users/send-verification/:user_id</td></tr></tbody></table>

Create an email or sms verification code for your user.

***

Creating a verification code will send a 6-digit numerical OTP code directly to the end user via email or SMS, according to the specified `type`. Collect this code from the end user and verify it by executing a [Confirm Verification Code](/connect/rest-api/end-users/confirm-verification-code.md) request.

{% hint style="info" %}
Business accounts only need to verify email.&#x20;

Individual accounts are required to verify email and sms. Email **must** be verified before requesting an sms code.
{% endhint %}

## Request

### Path Parameters

<table><thead><tr><th width="227">Name</th><th>Description</th></tr></thead><tbody><tr><td><code>user_id</code> <br><mark style="color:red;">required</mark>, string</td><td>Unique ID defined by you for this user that will serve as the shared identifier for this account between you and sFOX</td></tr></tbody></table>

### Body Parameters

<table><thead><tr><th width="228">Name</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code> <br><mark style="color:red;">required</mark>, string</td><td>Verification method. <br><em>Possible values: <code>email</code> , <code>sms</code></em></td></tr></tbody></table>

### Example Requests

{% tabs %}
{% tab title="Shell" %}
{% code lineNumbers="true" %}

```shell
curl -X POST \
-H "Authorization: Bearer ${ENTERPRISE_API_KEY}" \
--data '{ "type": "email" }'  \
'https://api.sfox.com/v1/enterprise/users/send-verification/${user_id}'
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}

<pre class="language-javascript"><code class="lang-javascript">const axios = require('axios');

const user_id = "user_id"
const data = JSON.stringify({ type: 'email'})
const config = {
  method: 'post',
  url: `https://api.sfox.com/v1/enterprise/users/send-verification/${user_id}`,
  headers: {
    'Content-Type': 'application/json',
    Authorization: `Bearer ${process.env.ENTERPRISE_API_KEY}`
  },
  data: data
}
  
axios(config)
  .then((response) => {
  console.log(response.status)
  console.log(response.data)
  })
  .catch((err) => {
  console.error(err.response.status)
  console.error(err.response.data)
<strong>  });
</strong></code></pre>

{% endtab %}

{% tab title="Python" %}

```python
import requests
import os

data = requests.post(
  "https://api.sfox.com/v1/enterprise/users/send-verification/${user_id}",
  headers={
    "Authorization": f"Bearer {os.environ['ENTERPRISE_API_KEY']}"
  },
  json={
    "type": "email"
  }
)
print(data.status_code)
print(data.json())
```

{% endtab %}
{% endtabs %}

## Response

### Response Fields

<table><thead><tr><th width="191.47265625">Name</th><th>Description</th></tr></thead><tbody><tr><td><code>data</code><br>object</td><td>Verification code information.</td></tr><tr><td>    <code>user_id</code><br>    string</td><td>The ID of the end user the code was sent to.</td></tr><tr><td>    <code>type</code><br>    string</td><td>The verification method for the code. <br><em>Possible values: <code>email</code> , <code>sms</code></em></td></tr><tr><td>    <code>email</code><br>    string</td><td>The email address the verification code was sent to, if <code>type</code> = <code>email</code></td></tr><tr><td>    <code>phone_number</code><br>    string</td><td>The phone number the verification code was sent to, if <code>type</code> = <code>sms</code></td></tr></tbody></table>

### Responses

<details>

<summary><mark style="color:green;">200</mark>: OK</summary>

{% code title="Email verification code sent to email specified" lineNumbers="true" %}

```json
{
    "data": {
        "user_id": "client_account_1",
        "type": "email",
        "email": "sfox_connect@email.com"
    }
}
```

{% endcode %}

{% code title="SMS verification code sent to the phone number specified" lineNumbers="true" %}

```json
{
    "data": {
        "user_id": "client_account_1",
        "type": "sms",
        "phone_number": "+12223334444"
    }
}
```

{% endcode %}

</details>

<details>

<summary><mark style="color:red;">422</mark>: Unprocessable Entity</summary>

{% code title="Email has already been verified" lineNumbers="true" %}

```json
{
    "error": "Email already verified"
}
```

{% endcode %}

{% code title="Phone number has already been verified" lineNumbers="true" %}

```json
{
    "error": "Phone already verified"
}
```

{% endcode %}

</details>


---

# 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.sfox.com/connect/rest-api/end-users/create-verification-code.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.
