🚀 Quick Start
You're 3 steps away from sending your first OTP. No SDK needed — it's just an HTTP request.
-
Get your credentials Log into your IndiaHost dashboard and copy your
user(email) andkey(API key). No account yet? Order OTP SMS → -
Generate an OTP on your server Create a 4–6 digit random number server-side before calling the API. Never let the client generate or see it before verification.
-
Fire a GET or POST request Pass
mobile,otp,user, andkeyto the endpoint below. That's it.
🔑 Credentials
Your API credentials are tied to your IndiaHost account and SMS balance.
user value and your secret API key is the key value.
| Credential | Example | Description |
|---|---|---|
| user | [email protected] | Your IndiaHost account email address |
| key | AAAABBBBCCCCDDDDEEEEFFFGG | Your secret API key from the dashboard |
📡 Endpoint
Single endpoint, supports both GET and POST methods.
https://otp.indiahost.org/send_otp.php
https://otp.indiahost.org/send_otp.php
Full GET URL Example
https://otp.indiahost.org/send_otp.php?mobile=+911234567890&otp=123456&user=demo%40gmail.com&key=AAAABBBBCCCCDDDDEEEEFFFGG
⚙️ Parameters
All four parameters are required. Pass them as query string (GET) or form body (POST).
| Parameter | Type | Required | Description |
|---|---|---|---|
| mobile | string | required | Recipient mobile number with country code. For India: +911234567890 |
| otp | integer | required | The OTP digits to deliver. Typically 4–6 digits. |
| user | string | required | Your IndiaHost account email address. |
| key | string | required | Your secret API key from the IndiaHost dashboard. |
📨 API Responses
The API returns a plain-text or JSON string indicating success or failure.
OTP was sent successfully to the mobile number.
The key or user parameter is incorrect.
Your SMS balance is insufficient. Recharge at indiahost.co.
Mobile number format is wrong. Ensure +91XXXXXXXXXX format.
One or more required parameters are missing from the request.
💻 Code Examples
Pick your language. Every example uses the same demo credentials — swap in yours and ship.
PHP — cURL
<?php// ── IndiaHost OTP API · PHP cURL ────────────────────── $user = "[email protected]"; $key = "AAAABBBBCCCCDDDDEEEEFFFGG"; $otp = 123456; // generate this dynamically in production $num = "1234567890"; // recipient's 10-digit number $url = "https://otp.indiahost.org/send_otp.php?" . http_build_query([ 'mobile' => "+91" . $num, 'otp' => $otp, 'user' => $user, 'key' => $key, ]); $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10, CURLOPT_SSL_VERIFYPEER => true, ]); $response = curl_exec($ch); $error = curl_error($ch); curl_close($ch); if ($error) { echo "cURL error: " . $error; } else { echo "API Response: " . $response; // "SUCCESS" on success }
PHP — POST (form data)
<?php// ── IndiaHost OTP API · PHP POST ───────────────────── $ch = curl_init("https://otp.indiahost.org/send_otp.php"); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => http_build_query([ 'mobile' => "+911234567890", 'otp' => 123456, 'user' => "[email protected]", 'key' => "AAAABBBBCCCCDDDDEEEEFFFGG", ]), ]); $response = curl_exec($ch); curl_close($ch); echo $response;
Python — requests
# pip install requests import requests user = "[email protected]" key = "AAAABBBBCCCCDDDDEEEEFFFGG" otp = 123456 num = "1234567890" params = { "mobile": f"+91{num}", "otp": otp, "user": user, "key": key, } resp = requests.get("https://otp.indiahost.org/send_otp.php", params=params, timeout=10) print(resp.text) # SUCCESS # ── or POST ────────────────────────────────────────── resp = requests.post("https://otp.indiahost.org/send_otp.php", data=params, timeout=10) print(resp.text)
Node.js — https / axios / fetch
// Works with Node 18+, Deno, Bun, and modern browsers const user = "[email protected]"; const key = "AAAABBBBCCCCDDDDEEEEFFFGG"; const otp = 123456; const num = "1234567890"; const params = new URLSearchParams({ mobile: `+91${num}`, otp: otp, user: user, key: key }); const url = `https://otp.indiahost.org/send_otp.php?${params}`; const res = await fetch(url); const text = await res.text(); console.log(text); // SUCCESS
Bash — cURL
# ── IndiaHost OTP via curl ──────────────────────────── USER="[email protected]" KEY="AAAABBBBCCCCDDDDEEEEFFFGG" OTP=123456 NUM=1234567890 curl -G "https://otp.indiahost.org/send_otp.php" \ --data-urlencode "mobile=+91${NUM}" \ --data-urlencode "otp=${OTP}" \ --data-urlencode "user=${USER}" \ --data-urlencode "key=${KEY}" # ── POST variant ────────────────────────────────────── curl -X POST "https://otp.indiahost.org/send_otp.php" \ -d "mobile=+91${NUM}&otp=${OTP}&user=${USER}&key=${KEY}"
Java — HttpClient
import java.net.URI; import java.net.http.*; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; public class IndiaHostOTP { public static void main(String[] args) throws Exception { String user = "[email protected]"; String key = "AAAABBBBCCCCDDDDEEEEFFFGG"; String otp = "123456"; String num = "1234567890"; String url = "https://otp.indiahost.org/send_otp.php?mobile=" + URLEncoder.encode("+91" + num, StandardCharsets.UTF_8) + "&otp=" + otp + "&user=" + URLEncoder.encode(user, StandardCharsets.UTF_8) + "&key=" + key; HttpClient client = HttpClient.newHttpClient(); HttpRequest req = HttpRequest.newBuilder() .uri(URI.create(url)) .GET().build(); HttpResponse<String> resp = client.send(req, HttpResponse.BodyHandlers.ofString()); System.out.println(resp.body()); // SUCCESS } }
Go
package main import ( "fmt" "io" "net/http" "net/url" ) func main() { params := url.Values{} params.Set("mobile", "+911234567890") params.Set("otp", "123456") params.Set("user", "[email protected]") params.Set("key", "AAAABBBBCCCCDDDDEEEEFFFGG") endpoint := "https://otp.indiahost.org/send_otp.php?" + params.Encode() resp, err := http.Get(endpoint) if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) fmt.Println(string(body)) // SUCCESS }
C# — HttpClient
using System.Net.Http; var client = new HttpClient(); var qs = System.Web.HttpUtility.ParseQueryString(string.Empty); qs["mobile"] = "+911234567890"; qs["otp"] = "123456"; qs["user"] = "[email protected]"; qs["key"] = "AAAABBBBCCCCDDDDEEEEFFFGG"; var url = "https://otp.indiahost.org/send_otp.php?" + qs.ToString(); var resp = await client.GetStringAsync(url); Console.WriteLine(resp); // SUCCESS
Ruby
require 'net/http' require 'uri' uri = URI('https://otp.indiahost.org/send_otp.php') uri.query = URI.encode_www_form( mobile: '+911234567890', otp: 123456, user: '[email protected]', key: 'AAAABBBBCCCCDDDDEEEEFFFGG' ) resp = Net::HTTP.get_response(uri) puts resp.body # SUCCESS
🎲 Auto-Generate & Verify OTP (PHP)
A complete, production-ready PHP snippet: generate, send, store in session, and verify.
<?php// ── IndiaHost OTP · Full Send + Verify Flow ───────────
session_start();
function sendOTP(string $mobile): array {
$user = "[email protected]"; // your credentials
$key = "AAAABBBBCCCCDDDDEEEEFFFGG";
$otp = random_int(100000, 999999); // 6-digit OTP
$_SESSION['otp'] = $otp;
$_SESSION['otp_exp'] = time() + 300; // 5 min expiry
$url = "https://otp.indiahost.org/send_otp.php?" . http_build_query([
'mobile' => "+91" . $mobile,
'otp' => $otp,
'user' => $user,
'key' => $key,
]);
$ch = curl_init($url);
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10]);
$result = curl_exec($ch);
curl_close($ch);
return ['status' => trim($result), 'otp' => $otp];
}
function verifyOTP(int $input): bool {
if (empty($_SESSION['otp']) || time() > $_SESSION['otp_exp']) {
return false; // expired or not set
}
return (int)$_SESSION['otp'] === $input;
}
// ── Usage ─────────────────────────────────────────────
$send = sendOTP("1234567890");
echo $send['status']; // SUCCESS
// Later, when user submits the form:
if (verifyOTP((int)$_POST['otp'])) {
echo "✓ Verified!";
} else {
echo "✗ Invalid or expired OTP.";
}
🛠️ Troubleshooting
Common issues and how to fix them fast.
| Response | Cause | Fix |
|---|---|---|
| INVALID KEY | Wrong user or key |
Copy credentials fresh from the dashboard |
| LOW BALANCE | SMS credits exhausted | Recharge at indiahost.co/OTP-SMS |
| INVALID MOBILE | Wrong number format | Use +91XXXXXXXXXX (10 digits after +91) |
| cURL error | SSL / network issue | Ensure curl and openssl are installed and up to date |
| Empty response | Timeout or server unreachable | Retry with a 10 s timeout; check server firewall for outbound HTTPS |