curl -X POST \
-H "Authorization: Bearer YOUR_MERCHANT_KEY" \
-H "Content-Type: application/json" \
-d '{
"phone": "YOUR_PHONE_NUMBER",
"gateway_key": "YOUR_GATEWAY_KEY"
}' \
https://api.fazpass.com/v1/otp/request
function sendOTP($YOUR_PHONE_NUMBER) {
$data = json_encode([
"phone" => $YOUR_PHONE_NUMBER,
"gateway_key" => "YOUR_GATEWAY_KEY"
]);
$ch = curl_init('https://api.fazpass.com/v1/otp/request');
curl_setopt_array($ch, [
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_MERCHANT_KEY',
'Content-Type: application/json'
],
CURLOPT_RETURNTRANSFER => true
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
if ($result['status'] == true) {
return 'OTP sent successfully!';
} else {
return 'Error: ' . ($result['message'] ??
'Something went wrong while requesting OTP.');
}
}
// Example usage with phone number
$YOUR_PHONE_NUMBER = 'YOUR_PHONE_NUMBER';
$response = sendOTP($YOUR_PHONE_NUMBER);
echo $response;
const axios = require('axios');
async function sendOTP(YOUR_PHONE_NUMBER) {
const data = {
phone: YOUR_PHONE_NUMBER,
gateway_key: 'YOUR_GATEWAY_KEY'
};
try {
const response = await
axios.post('https://api.fazpass.com/v1/otp/request',
data, {
headers: {
'Authorization': 'Bearer YOUR_MERCHANT_KEY',
'Content-Type': 'application/json'
}
});
if (response.data.status == true) {
return 'OTP sent successfully!';
} else {
return 'Error: ' + (response.data.message ||
'Something went wrong while requesting OTP.');
}
} catch (error) {
return 'Error: ' + error.message;
}
}
// Example usage with phone number
const YOUR_PHONE_NUMBER = 'YOUR_PHONE_NUMBER';
sendOTP(YOUR_PHONE_NUMBER).then((response) =>
console.log(response)).catch((error) => console.error(error));
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class SendOTPJava {
public static void main(String[] args) {
String apiUrl = "https://api.fazpass.com/v1/otp/request";
String token = "YOUR_MERCHANT_KEY";
String phone = "YOUR_PHONE_NUMBER";
String gatewayKey = "YOUR_GATEWAY_KEY";
String jsonBody = "{ \"phone\": \"" + phone + "\",
\"gateway_key\": \"" + gatewayKey + "\" }";
try {
URL url = new URL(apiUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Set request method to POST
connection.setRequestMethod("POST");
// Set headers
connection.setRequestProperty("Authorization", "Bearer " + token);
connection.setRequestProperty("Content-Type", "application/json");
// Enable writing to the URL connection
connection.setDoOutput(true);
// Write data to the connection
try (DataOutputStream outputStream =
new DataOutputStream(connection.getOutputStream())) {
outputStream.writeBytes(jsonBody);
outputStream.flush();
}
// Get response code
int responseCode = connection.getResponseCode();
// Read response
try (BufferedReader reader =
new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
StringBuilder response = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
response.append(line);
}
if (responseCode == 200) {
System.out.println("OTP sent successfully!");
} else {
System.out.println("Error: " + response.toString());
}
}
// Close the connection
connection.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import requests
import json
def sendOTP(YOUR_PHONE_NUMBER):
data = {
"phone": YOUR_PHONE_NUMBER,
"gateway_key": "YOUR_GATEWAY_KEY"
}
headers = {
'Authorization': 'Bearer YOUR_MERCHANT_KEY',
'Content-Type': 'application/json'
}
try:
response = requests.post('https://api.fazpass.com/v1/otp/request',
data=json.dumps(data), headers=headers)
result = response.json()
if result['status'] == true:
return 'OTP sent successfully!'
else:
return 'Error: ' + (result['message'] if 'message' in result else 'Something went wrong while requesting OTP.')
except requests.exceptions.RequestException as e:
return 'Error: ' + str(e)
# Example usage with phone number
YOUR_PHONE_NUMBER = 'YOUR_PHONE_NUMBER'
response = sendOTP(YOUR_PHONE_NUMBER)
print(response)
require 'httparty'
require 'json'
def send_otp(YOUR_PHONE_NUMBER)
endpoint = 'https://api.fazpass.com/v1/otp/request'
headers = {
'Authorization' => 'Bearer YOUR_MERCHANT_KEY',
'Content-Type' => 'application/json'
}
data = {
phone: YOUR_PHONE_NUMBER,
gateway_key: 'YOUR_GATEWAY_KEY'
}.to_json
response = HTTParty.post(endpoint, headers: headers, body: data)
if response.code == 200 && response.parsed_response['status'] == true
'OTP sent successfully!'
else
"Error: #{response.parsed_response['message'] || 'Something went wrong while requesting OTP.'}"
end
end
# Example usage with phone number
YOUR_PHONE_NUMBER = 'YOUR_PHONE_NUMBER'
response = send_otp(YOUR_PHONE_NUMBER)
puts response
Fazpass offers the following APIs for OTP integration:
To get started with API integration, follow these steps: