> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.vlenseg.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.vlenseg.com/_mcp/server.

# Send or validate phone OTP

POST https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone
Content-Type: application/json

This single endpoint handles both sending and validating the phone OTP depending on which fields you provide.

**Send OTP** (first call): Provide `phoneNumber` and optionally `smsProviders`. Save the `phoneNumberOtpRequestId` from the response.

**Validate OTP** (second call): Provide `phoneNumber`, `phoneNumberOtpRequestId`, and `phoneNumberOtp`.


Reference: https://docs.vlenseg.com/api-reference/vlens-api/registration/register-step-verify-phone

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: example-openapi
  version: 1.0.0
paths:
  /api/DigitalIdentity/Register/StepVerifyPhone:
    post:
      operationId: register-step-verify-phone
      summary: Send or validate phone OTP
      description: >
        This single endpoint handles both sending and validating the phone OTP
        depending on which fields you provide.


        **Send OTP** (first call): Provide `phoneNumber` and optionally
        `smsProviders`. Save the `phoneNumberOtpRequestId` from the response.


        **Validate OTP** (second call): Provide `phoneNumber`,
        `phoneNumberOtpRequestId`, and `phoneNumberOtp`.
      tags:
        - subpackage_registration
      parameters:
        - name: ApiKey
          in: header
          description: >-
            Static API key issued to your tenant. Obtain from the Vlens
            dashboard.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: >-
            OTP sent or validated. On send, save `phoneNumberOtpRequestId` for
            the next call.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiOutputRegister'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StepVerifyPhoneInput'
servers:
  - url: https://api.vlenseg.com
    description: Production
components:
  schemas:
    StepVerifyPhoneInput:
      type: object
      properties:
        phoneNumber:
          type: string
        smsProviders:
          type:
            - integer
            - 'null'
          description: |
            SMS gateway to use for OTP delivery (omit to use tenant default):
            - `1` — Infobip
            - `2` — Vodafone
            - `3` — Cequens
            - `4` — Victory Link
            - `5` — BroadNet
            - `6` — Ezagel
            - `7` — Orange
        phoneNumberOtpRequestId:
          type:
            - string
            - 'null'
          format: uuid
          description: >-
            Required on the **validate** call. Value returned by the **send**
            call.
        phoneNumberOtp:
          type:
            - string
            - 'null'
          description: The OTP code entered by the user. Required on the validate call.
      required:
        - phoneNumber
      title: StepVerifyPhoneInput
    UserBasicInfo:
      type: object
      properties:
        id:
          type: integer
          format: int64
        name:
          type:
            - string
            - 'null'
        surname:
          type:
            - string
            - 'null'
        fullName:
          type:
            - string
            - 'null'
        userName:
          type:
            - string
            - 'null'
        emailAddress:
          type:
            - string
            - 'null'
          format: email
        phoneNumber:
          type:
            - string
            - 'null'
        idNumber:
          type:
            - string
            - 'null'
          description: Egyptian national ID number.
        address:
          type:
            - string
            - 'null'
      description: Core profile information for a registered user.
      title: UserBasicInfo
    RegisterOutput:
      type: object
      properties:
        isEmailConfirmationRequired:
          type: boolean
        isEmailConfirmed:
          type: boolean
        isPhoneNumberConfirmationRequired:
          type: boolean
        isPhoneNumberConfirmed:
          type: boolean
        phoneNumberOtp:
          type:
            - string
            - 'null'
        phoneNumberOtpRequestId:
          type:
            - string
            - 'null'
          format: uuid
        isDigitalIdentityVerified:
          type: boolean
        accessToken:
          type:
            - string
            - 'null'
          description: >-
            User access token. Store securely and pass as `Authorization: Bearer
            <token>` for subsequent user-scoped requests.
        encryptedAccessToken:
          type:
            - string
            - 'null'
        expireInSeconds:
          type: integer
        userName:
          type:
            - string
            - 'null'
        userFullName:
          type:
            - string
            - 'null'
        user:
          $ref: '#/components/schemas/UserBasicInfo'
      title: RegisterOutput
    ApiOutputRegister:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/RegisterOutput'
        error_code:
          type:
            - integer
            - 'null'
        error_message:
          type:
            - string
            - 'null'
        error_descriptions:
          oneOf:
            - description: Any type
            - type: 'null'
      title: ApiOutputRegister
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: ApiKey
      description: Static API key issued to your tenant. Obtain from the Vlens dashboard.

```

## Examples

### Send OTP



**Request**

```json
{
  "phoneNumber": "+201234567890",
  "smsProviders": 0
}
```

**Response**

```json
{
  "data": {
    "isEmailConfirmationRequired": true,
    "isEmailConfirmed": true,
    "isPhoneNumberConfirmationRequired": true,
    "isPhoneNumberConfirmed": true,
    "phoneNumberOtp": "string",
    "phoneNumberOtpRequestId": "string",
    "isDigitalIdentityVerified": true,
    "accessToken": "string",
    "encryptedAccessToken": "string",
    "expireInSeconds": 1,
    "userName": "string",
    "userFullName": "string",
    "user": {
      "id": 1,
      "name": "string",
      "surname": "string",
      "fullName": "string",
      "userName": "string",
      "emailAddress": "string",
      "phoneNumber": "string",
      "idNumber": "string",
      "address": "string"
    }
  },
  "error_code": 1,
  "error_message": "string",
  "error_descriptions": null
}
```

**SDK Code**

```python Send OTP
import requests

url = "https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone"

payload = {
    "phoneNumber": "+201234567890",
    "smsProviders": 0
}
headers = {
    "ApiKey": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Send OTP
const url = 'https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone';
const options = {
  method: 'POST',
  headers: {ApiKey: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"phoneNumber":"+201234567890","smsProviders":0}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Send OTP
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone"

	payload := strings.NewReader("{\n  \"phoneNumber\": \"+201234567890\",\n  \"smsProviders\": 0\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("ApiKey", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Send OTP
require 'uri'
require 'net/http'

url = URI("https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["ApiKey"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"phoneNumber\": \"+201234567890\",\n  \"smsProviders\": 0\n}"

response = http.request(request)
puts response.read_body
```

```java Send OTP
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone")
  .header("ApiKey", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"phoneNumber\": \"+201234567890\",\n  \"smsProviders\": 0\n}")
  .asString();
```

```php Send OTP
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone', [
  'body' => '{
  "phoneNumber": "+201234567890",
  "smsProviders": 0
}',
  'headers' => [
    'ApiKey' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Send OTP
using RestSharp;

var client = new RestClient("https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone");
var request = new RestRequest(Method.POST);
request.AddHeader("ApiKey", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"phoneNumber\": \"+201234567890\",\n  \"smsProviders\": 0\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Send OTP
import Foundation

let headers = [
  "ApiKey": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "phoneNumber": "+201234567890",
  "smsProviders": 0
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Validate OTP



**Request**

```json
{
  "phoneNumber": "+201234567890",
  "phoneNumberOtpRequestId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "phoneNumberOtp": "123456"
}
```

**Response**

```json
{
  "data": {
    "isEmailConfirmationRequired": true,
    "isEmailConfirmed": true,
    "isPhoneNumberConfirmationRequired": true,
    "isPhoneNumberConfirmed": true,
    "phoneNumberOtp": "string",
    "phoneNumberOtpRequestId": "string",
    "isDigitalIdentityVerified": true,
    "accessToken": "string",
    "encryptedAccessToken": "string",
    "expireInSeconds": 1,
    "userName": "string",
    "userFullName": "string",
    "user": {
      "id": 1,
      "name": "string",
      "surname": "string",
      "fullName": "string",
      "userName": "string",
      "emailAddress": "string",
      "phoneNumber": "string",
      "idNumber": "string",
      "address": "string"
    }
  },
  "error_code": 1,
  "error_message": "string",
  "error_descriptions": null
}
```

**SDK Code**

```python Validate OTP
import requests

url = "https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone"

payload = {
    "phoneNumber": "+201234567890",
    "phoneNumberOtpRequestId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "phoneNumberOtp": "123456"
}
headers = {
    "ApiKey": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Validate OTP
const url = 'https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone';
const options = {
  method: 'POST',
  headers: {ApiKey: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"phoneNumber":"+201234567890","phoneNumberOtpRequestId":"3fa85f64-5717-4562-b3fc-2c963f66afa6","phoneNumberOtp":"123456"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Validate OTP
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone"

	payload := strings.NewReader("{\n  \"phoneNumber\": \"+201234567890\",\n  \"phoneNumberOtpRequestId\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n  \"phoneNumberOtp\": \"123456\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("ApiKey", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Validate OTP
require 'uri'
require 'net/http'

url = URI("https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["ApiKey"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"phoneNumber\": \"+201234567890\",\n  \"phoneNumberOtpRequestId\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n  \"phoneNumberOtp\": \"123456\"\n}"

response = http.request(request)
puts response.read_body
```

```java Validate OTP
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone")
  .header("ApiKey", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"phoneNumber\": \"+201234567890\",\n  \"phoneNumberOtpRequestId\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n  \"phoneNumberOtp\": \"123456\"\n}")
  .asString();
```

```php Validate OTP
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone', [
  'body' => '{
  "phoneNumber": "+201234567890",
  "phoneNumberOtpRequestId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "phoneNumberOtp": "123456"
}',
  'headers' => [
    'ApiKey' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Validate OTP
using RestSharp;

var client = new RestClient("https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone");
var request = new RestRequest(Method.POST);
request.AddHeader("ApiKey", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"phoneNumber\": \"+201234567890\",\n  \"phoneNumberOtpRequestId\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n  \"phoneNumberOtp\": \"123456\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Validate OTP
import Foundation

let headers = [
  "ApiKey": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "phoneNumber": "+201234567890",
  "phoneNumberOtpRequestId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "phoneNumberOtp": "123456"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.vlenseg.com/api/DigitalIdentity/Register/StepVerifyPhone")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```