Skip to content

Verify OTP

To verify the One Time Password or Verification Token sent to the recipient's phone number.

Endpoint

POST
/verify/v1/verify-otp


POSTMAN

Authentication

AUTHORIZATION: Bearer Token

Body

Object

   {
      "otp_id"  : "86b24910-2d1e-4257-b6d4-e6b829e50e84",
      "otp_code":"689237"
   }

Body parameters

Parameter Value / Pattern
otp_id The otp_id which was returned as a response parameter from send OTP endpoint
otp_code The OTP which is received on the recipient's number

Response

When the request is validated the status will be returned.

200 - Success
{
    "status": "APPROVED"
}
400 - Invalid OTP code
{
    "detail": {
        "code": "INVALID_OTP_CODE",
        "message": "Invalid OTP code or OTP code expired"
    }
}
422 - Validation Error
{
    "detail": [
        {
            "loc": [
                "string",
                0
            ],
            "msg": "string",
            "type": "string"
        }
    ]
}

Response Parameters

Parameter Type Value
status String The verification status for the provided OTP. Possible status are APPROVED (User has entered correct OTP), FAILED (Incorrect OTP), EXPIRED (OTP has been expired) and ALREADY_VERIFIED (This OTP has already been verified)

Programming Examples

1
2
3
4
5
6
7
curl --location --request POST 'https://api.d7networks.com/verify/v1/otp/verify-otp' \
--header 'Authorization: Bearer {{api_access_token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "otp_id":"{{otp_id}}",
    "otp_code":"{{otp}}"
}'
npm i direct7
1
2
3
4
const Client = require('direct7')
const client = new Client(apiToken="Your API token")
const response = await client.verify.verifyOTP({otp_id: "b4c3ac5d-df5f-4df7-85b9-aba64c5da228", otp_code: "749679"});
console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

client = Client(api_token="Your API token")

client.verify.verify_otp(otp_id="0012c7f5-2ba5-49db-8901-4ee9be6dc8d1", otp_code="1425")

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
1
2
3
4
5
6
7
8
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$client = new Client(api_token="Your API token")

$response = $direct7->verify->verifyOtp(otpId:'31b89954-d37c-426f-8113-ac718afc5d4c', otpCode:'429766');
var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
1
2
3
4
5
6
7
8
9
import (
"github.com/d7networks/direct7-go-sdk/direct7"
)   
apiToken := "Your Api Token"
client := direct7.NewClient(apiToken)
verify := direct7.NewVerify(client)
otpID := "32549451-0eb6-4788-8e91-32b2eb9c4260"
otpCode := "803053"
response, err := verify.VerifyOTP(otpID, otpCode)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"otp_id\":\"{{otp_id}}\",\n    \"otp_code\":\"{{otp}}\"\n}");
Request request = new Request.Builder()
.url("https://api.d7networks.com/verify/v1/otp/verify-otp")
.method("POST", body)
.addHeader("Authorization", "Bearer {{api_access_token}}")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Authorization': 'Bearer {{api_access_token}}',
'Content-Type': 'application/json'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/verify/v1/otp/verify-otp'));
request.body = json.encode({
"otp_id": "{{otp_id}}",
"otp_code": "{{otp}}"
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
1
2
3
4
5
6
7
8
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer {{api_access_token}}")
$headers.Add("Content-Type", "application/json")

$body = "{`n    `"otp_id`":`"{{otp_id}}`",`n    `"otp_code`":`"{{otp}}`"`n}"

$response = Invoke-RestMethod 'https://api.d7networks.com/verify/v1/otp/verify-otp' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
gem install direct7
1
2
3
4
5
require 'direct7'

client = Direct7::Client.new('Your API token')

client.verify.verify_otp(otp_id="0012c7f5-2ba5-49db-8901-4ee9be6dc8d1", otp_code="1425")