Send SMS API
Use this endpoint to send SMS messages programmatically.
POST
https://sms.affket.in/api/send-sms.php
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
api_key |
string | Yes | Your unique API key |
mobile |
string | Yes | 10-digit mobile number (or with 91 prefix) |
message |
string | Yes | DLT approved message template |
Code Examples
cURL
curl -X POST "https://sms.affket.in/api/send-sms.php" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "api_key=YOUR_API_KEY" \
-d "mobile=9876543210" \
-d "message=Your OTP is 123456. Valid for 10 minutes."
PHP
<?php
$url = "https://sms.affket.in/api/send-sms.php";
$data = [
'api_key' => 'YOUR_API_KEY',
'mobile' => '9876543210',
'message' => 'Your OTP is 123456. Valid for 10 minutes.'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
?>
Python
import requests
url = "https://sms.affket.in/api/send-sms.php"
data = {
"api_key": "YOUR_API_KEY",
"mobile": "9876543210",
"message": "Your OTP is 123456. Valid for 10 minutes."
}
response = requests.post(url, data=data)
result = response.json()
print(result)
Node.js
const axios = require('axios');
const data = new URLSearchParams();
data.append('api_key', 'YOUR_API_KEY');
data.append('mobile', '9876543210');
data.append('message', 'Your OTP is 123456. Valid for 10 minutes.');
axios.post('https://sms.affket.in/api/send-sms.php', data)
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
Response Format
✅ Success Response
{
"status": "success",
"message": "SMS sent successfully",
"data": {
"message_id": "MSG123456789",
"mobile": "919876543210",
"cost": 0.20,
"balance": 99.80
}
}
❌ Error Response
{
"status": "error",
"message": "Insufficient balance",
"error_code": "INSUFFICIENT_BALANCE"
}
Error Codes
| Error Code | Description |
|---|---|
INVALID_API_KEY |
The provided API key is invalid or missing |
ACCOUNT_BLOCKED |
Your account has been blocked |
INSUFFICIENT_BALANCE |
Not enough balance to send SMS |
INVALID_MOBILE |
Invalid mobile number format |
INVALID_MESSAGE |
Message is empty or too long |
RATE_LIMIT_EXCEEDED |
Too many requests, please slow down |
SMS_GATEWAY_ERROR |
Failed to send SMS via gateway |