Welcome to Airtexts! This comprehensive guide will help you get up and running with our SMS and OTP services in minutes. Whether you're building a simple notification system or a complex authentication flow, we've got you covered. ##
π Getting Started with Airtexts
Welcome to Airtexts! This guide helps you quickly integrate our SMS and OTP services.
What is Airtexts?
Airtexts is a cloud-based messaging platform for businesses to:
- Send SMS globally with high delivery.
- Implement OTP authentication for secure verification.
- Track message performance in real-time.
- Integrate easily with our REST API.
- Scale globally with reliable infrastructure.
Key Features
- 99.9% Uptime
- Global Coverage (200+ countries)
- Multiple Authentication methods (API Keys, JWT, Basic Auth)
- Real-time Delivery reports
- Bulk Messaging with smart rate limiting
- Developer-Friendly SDKs & docs
π― Quick Start (5 Minutes)
Step 1: Create Your Account
- Sign up at dashboard.airtexts.com
- Verify your email.
- Complete your profile.
- Add payment or claim free credits.
Step 2: Create Your API Keys
Important: API keys are created only via the dashboard.
- Login to your dashboard at dashboard.airtexts.com
π Detailed Guide: API Key Manager Documentation
Step 3: Send Your First SMS
curl -X POST "https://api.airtexts.com/sms/send" \
-H "X-API-Key: your_api_key" \
-H "X-API-Secret: your_api_secret" \
-H "Content-Type: application/json" \
-d '{
"to": "+5511999888777",
"from": "Airtexts",
"message": "Hello! This is your first SMS from Airtexts π"
}'
Step 4: Try OTP Authentication
# Send OTP
curl -X POST "https://api.airtexts.com/otp/send" \
-H "X-API-Key: your_api_key" \
-H "X-API-Secret: your_api_secret" \
-H "Content-Type: application/json" \
-d '{
"phone": "+5511999888777",
"template": "Your verification code is: {{code}}"
}'
# Verify OTP (use the code received)
curl -X POST "https://api.airtexts.com/otp/verify" \
-H "X-API-Key: your_api_key" \
-H "X-API-Secret: your_api_secret" \
-H "Content-Type: application/json" \
-d '{
"phone": "+5511999888777",
"code": "123456"
}'
π API Key Management
Creating API Keys (Dashboard Only)
API keys cannot be created programmatically; use the dashboard:
- Access Dashboard: my.airtexts.com
Managing Existing API Keys
Manage your existing API keys programmatically after creation. π Complete API Key Management: https://airtexts.readme.io/reference/api-key-manager
π Choose Your Integration Path
π° Beginner - REST API
Perfect for: Simple integrations, testing.
// Simple JavaScript example
async function sendSMS() {
const response = await fetch('https://api.airtexts.com/sms/send', {
method: 'POST',
headers: {
'X-API-Key': 'your_api_key',
'X-API-Secret': 'your_api_secret',
'Content-Type': 'application/json'
},
body: JSON.stringify({
to: '+5511999888777',
from: 'MyApp',
message: 'Welcome to our service!'
})
});
const result = await response.json();
console.log('SMS sent:', result);
}
π Intermediate - SDK Integration
Perfect for: Production applications, robust error handling.
PHP Integration
<?php
// Configure your API credentials from dashboard
define('AIRTEXTS_API_KEY', 'your_api_key_from_dashboard');
define('AIRTEXTS_API_SECRET', 'your_api_secret_from_dashboard');
class AirtextsAPI {
private $apiKey;
private $apiSecret;
private $baseUrl = 'https://api.airtexts.com';
public function __construct($apiKey, $apiSecret) {
$this->apiKey = $apiKey;
$this->apiSecret = $apiSecret;
}
// Send SMS
public function sendSMS($to, $from, $message) {
$data = [
'to' => $to,
'from' => $from,
'message' => $message
];
return $this->makeRequest('POST', '/sms/send', $data);
}
// Send OTP
public function sendOTP($phone, $template = null) {
$data = ['phone' => $phone];
if ($template) $data['template'] = $template;
return $this->makeRequest('POST', '/otp/send', $data);
}
// Verify OTP
public function verifyOTP($phone, $code) {
$data = [
'phone' => $phone,
'code' => $code
];
return $this->makeRequest('POST', '/otp/verify', $data);
}
private function makeRequest($method, $endpoint, $data = null) {
$ch = curl_init($this->baseUrl . $endpoint);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $this->apiKey,
'X-API-Secret: ' . $this->apiSecret,
'Content-Type: application/json'
]);
if ($data) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
}
$response = curl_exec($ch);
$result = json_decode($response, true);
curl_close($ch);
return $result;
}
}
// Usage Example
$airtexts = new AirtextsAPI(AIRTEXTS_API_KEY, AIRTEXTS_API_SECRET);
// Send SMS
$smsResult = $airtexts->sendSMS(
'+5511999888777',
'MyApp',
'Welcome to our service!'
);
// Send OTP
$otpResult = $airtexts->sendOTP(
'+5511999888777',
'Your verification code is: {{code}}'
);
echo "SMS sent: " . ($smsResult['status'] === 'success' ? 'Yes' : 'No') . "\n";
echo "OTP sent: " . ($otpResult['status'] === 'success' ? 'Yes' : 'No') . "\n";
?>
JavaScript Integration
class AirtextsAPI {
constructor(apiKey, apiSecret) {
this.apiKey = apiKey;
this.apiSecret = apiSecret;
this.baseUrl = 'https://api.airtexts.com';
}
async sendSMS(to, from, message) {
return await this.makeRequest('POST', '/sms/send', {
to, from, message
});
}
async sendOTP(phone, template = null) {
const data = { phone };
if (template) data.template = template;
return await this.makeRequest('POST', '/otp/send', data);
}
async verifyOTP(phone, code) {
return await this.makeRequest('POST', '/otp/verify', {
phone, code
});
}
async makeRequest(method, endpoint, data = null) {
const options = {
method,
headers: {
'X-API-Key': this.apiKey,
'X-API-Secret': this.apiSecret,
'Content-Type': 'application/json'
}
};
if (data) {
options.body = JSON.stringify(data);
}
try {
const response = await fetch(`${this.baseUrl}${endpoint}`, options);
const result = await response.json();
if (!response.ok) {
throw new Error(result.error || 'Request failed');
}
return result;
} catch (error) {
console.error('API request failed:', error);
throw error;
}
}
}