API Key Access via Phone
Endpointβ
https://api.verifik.co/v2/projects/phone-login
Methods used for logging in with an already generated account in Verifik. This procedure is important because all queries require an Access Token, which is only generated upon login to the Verifik page.
These services create an OTP (One Time Password) request necessary to validate that the phone or email belongs to a Verifik client.
Headersβ
| Name | Value |
|---|---|
| Content-Type | application/json |
Parametersβ
| Name | Type | Required | Description |
|---|---|---|---|
countryCode | string | Yes | Country code for the phone number |
phone | number | Yes | Phone number |
type | string | Yes | Type of request. Use "login" for authentication |
Requestβ
- JavaScript
- Python
- Swift
- PHP
import axios from 'axios';
const options = {
method: 'POST',
url: 'https://api.verifik.co/v2/projects/phone-login',
headers: {
'Content-Type': 'application/json'
},
data: {
countryCode: '+1',
phone: 1234566663,
type: 'login'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
import http.client
import json
conn = http.client.HTTPSConnection("api.verifik.co")
payload = json.dumps({
"countryCode": "+1",
"phone": 1234566663,
"type": "login"
})
headers = {
'Content-Type': 'application/json'
}
conn.request("POST", "/v2/projects/phone-login", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import Foundation
let headers = [
"Content-Type": "application/json"
]
let parameters = [
"countryCode": "+1",
"phone": 1234566663,
"type": "login"
] as [String : Any]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.verifik.co/v2/projects/phone-login")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData
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()
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.verifik.co/v2/projects/phone-login', [
'headers' => [
'Content-Type' => 'application/json',
],
'json' => [
'countryCode' => '+1',
'phone' => 1234566663,
'type' => 'login'
]
]);
echo $response->getBody();
Responseβ
- 200
- 400
- 409
{
"data": {
"client": "613375a1eab2fe08527f81e2",
"project": "6266193db77ccc8111730c90",
"projectFlow": "658ed28b0990f300134d7b78",
"status": "sent",
"countryCode": "+1",
"phone": "1234566663",
"phoneGateway": "whatsapp",
"otp": "$2a$10$fdoxDgtv6J7E4nnZoCORSOiUbpCGOOE5JWghrvAUNZIoX5h81zJLq",
"expiresAt": "2024-05-29T03:51:26.000Z",
"phoneData": {
"title": "Verifik Client"
},
"type": "login",
"redirectUrl": "https://verifik.co",
"requires2FA": false,
"language": "en",
"_id": "6656a3e6eb43abfd7146abb6",
"updatedAt": "2024-05-29T03:41:27.009Z",
"createdAt": "2024-05-29T03:41:27.009Z",
"__v": 0,
"new": true,
"providerConfirmation": {}
},
"signature": {
"dateTime": "May 29, 2024 3:41 AM",
"message": "Certified by Verifik.co"
},
"id": "Y0628"
}
{
"code": "BadRequest",
"message": "Invalid phone number format.",
"signature": {
"dateTime": "August 31, 2022 3:24 PM",
"message": "Certified by Verifik.co"
}
}
{
"code": "MissingParameter",
"message": "missing countryCode\n. missing phone\n. missing type\n"
}
OTP Confirmationβ
Endpointβ
https://api.verifik.co/v2/projects/phone-login/confirm
The OTP confirmation services aim to generate a "login" to the Verifik account by validating that the sent OTP matches the one sent to the phone. As a response, the access token is obtained, which the user can use for queries.
Parametersβ
| Name | Type | Required | Description |
|---|---|---|---|
countryCode | string | Yes | Country code for the phone number |
phone | number | Yes | Phone number |
otp | string | Yes | One Time Password received via phone |
Requestβ
- JavaScript
- Python
- Swift
- PHP
import axios from 'axios';
const options = {
method: 'POST',
url: 'https://api.verifik.co/v2/projects/phone-login/confirm',
headers: {
'Content-Type': 'application/json'
},
data: {
countryCode: '+1',
phone: 1234566663,
otp: '123456'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
import http.client
import json
conn = http.client.HTTPSConnection("api.verifik.co")
payload = json.dumps({
"countryCode": "+1",
"phone": 1234566663,
"otp": "123456"
})
headers = {
'Content-Type': 'application/json'
}
conn.request("POST", "/v2/projects/phone-login/confirm", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
import Foundation
let headers = [
"Content-Type": "application/json"
]
let parameters = [
"countryCode": "+1",
"phone": 1234566663,
"otp": "123456"
] as [String : Any]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.verifik.co/v2/projects/phone-login/confirm")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData
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()
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.verifik.co/v2/projects/phone-login/confirm', [
'headers' => [
'Content-Type' => 'application/json',
],
'json' => [
'countryCode' => '+1',
'phone' => 1234566663,
'otp' => '123456'
]
]);
echo $response->getBody();
Responseβ
- 200
- 400
- 409
{
"data": {
"accessToken": "eyJhbGcpXVCJ9.eyJjbGllbnR...JZCIYiUzNjEaIWxYShWeBaRs",
"tokenType": "bearer"
}
}
{
"code": "BadRequest",
"message": "Invalid OTP code.",
"signature": {
"dateTime": "August 31, 2022 3:24 PM",
"message": "Certified by Verifik.co"
}
}
{
"code": "MissingParameter",
"message": "missing countryCode\n. missing phone\n. missing otp\n"
}
Featuresβ
- Phone Authentication: Login using phone number with OTP verification
- OTP Generation: Secure one-time password sent via WhatsApp/SMS
- Token Generation: Access token valid for 30 days upon successful authentication
- Structured Response: Organized data format for easy integration
- Multiple Programming Languages: Support for JavaScript, Python, PHP, and Swift
- Error Handling: Comprehensive error responses for various scenarios
Note: A token generated by this means will be valid for 30 days from the time the successful response is received. Verifik is not responsible for handling the Access Token. It is recommended to be very careful in determining who or what uses it to avoid potential consumption issues.