curl --request POST \
--url https://api.otpbay.com/v1/verifications/{sid}/check \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "482913"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: '482913'})
};
fetch('https://api.otpbay.com/v1/verifications/{sid}/check', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.otpbay.com/v1/verifications/{sid}/check"
payload = { "code": "482913" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.otpbay.com/v1/verifications/{sid}/check",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '482913'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.otpbay.com/v1/verifications/{sid}/check"
payload := strings.NewReader("{\n \"code\": \"482913\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.otpbay.com/v1/verifications/{sid}/check")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"482913\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.otpbay.com/v1/verifications/{sid}/check")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"482913\"\n}"
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://api.otpbay.com/v1/verifications/{sid}/check");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"code\": \"482913\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
Check a code
Checks the code your user entered. A correct code approves the verification. Each wrong code uses one of checks_left; the last wrong code fails the verification. A wrong code still returns 200 with valid: false.
curl --request POST \
--url https://api.otpbay.com/v1/verifications/{sid}/check \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "482913"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: '482913'})
};
fetch('https://api.otpbay.com/v1/verifications/{sid}/check', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.otpbay.com/v1/verifications/{sid}/check"
payload = { "code": "482913" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.otpbay.com/v1/verifications/{sid}/check",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '482913'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.otpbay.com/v1/verifications/{sid}/check"
payload := strings.NewReader("{\n \"code\": \"482913\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.otpbay.com/v1/verifications/{sid}/check")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"482913\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.otpbay.com/v1/verifications/{sid}/check")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"482913\"\n}"
response = http.request(request)
puts response.read_bodyusing RestSharp;
var options = new RestClientOptions("https://api.otpbay.com/v1/verifications/{sid}/check");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("Authorization", "Bearer <token>");
request.AddJsonBody("{\n \"code\": \"482913\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
Authorizations
Your project API key, sent as Authorization: Bearer otp_live_.... Create keys on the API Keys page of the dashboard.
Path Parameters
The verification sid returned by Start a verification.
^VE[a-fA-F0-9]{24}$"VE6650c3a1b2c3d4e5f6a7b8c9"
Body
The code your user entered, 4–8 digits.
^\d{4,8}$"482913"
Response
The code was checked. Read valid to see whether it matched.
true when the code matched and the verification is now approved.
Unique verification ID.
^VE[a-f0-9]{24}$"VE6650c3a1b2c3d4e5f6a7b8c9"
pending until the user enters the right code (approved), the code expires (expired), or the code can't be sent or too many wrong codes are entered (failed).
pending, approved, expired, failed Destination phone number in international format. OTPBay normalizes it to E.164, so +1 (415) 555-2671 becomes +14155552671.
"+14155552671"
Channel the code was last sent on.
telegram, sms Why the code was re-sent by SMS, or null if it wasn't.
telegram_failed, timeout, null Every send of the code, oldest first.
Hide child attributes
Hide child attributes
Channel this attempt was sent on.
telegram, sms sid of the underlying message: TG… for Telegram, SM… for SMS.
"TG6650c3a1b2c3d4e5f6a7b8d0"
Delivery status of the message. Telegram: sending, sent, delivered, read, expired, revoked, failed. SMS: queued, processing, sent, failed, enqueue_failed.
"sent"
Amount in US dollars as a decimal string.
^\d+\.\d{2}$"0.02"
Wrong codes the user can still enter before the verification fails.
5
Amount in US dollars as a decimal string.
^\d+\.\d{2}$"0.02"
Verify fee plus what the channel sends currently cost. Refunded sends count as 0.00.
^\d+\.\d{2}$"0.04"
When the code stops being accepted.
When the right code was entered.
Why the verification failed. Only present when status is failed.
"Too many wrong codes."