Text Messaging API 3.0
The WebFones Text Messaging API allows you to send SMS messages from phone numbers registered to your account. This API is designed for integration with CRMs, web apps, and automation tools that need to send text messages on behalf of users or systems.
Base URL
https://api.webfones.com:2343
Authentication
All API endpoints require authentication using an API key. The API key must be included in the request headers.
Required Headers
http
x-api-key: YOUR_API_KEY
Alternative:
http
Authorization: Bearer YOUR_API_KEY
Rate Limiting
- /sms/send: 30 requests per minute per API key (or per IP if no key)
- Response Code: 429 when limit exceeded
json
{
"error": "Too many SMS requests for this API key, please try again in a minute."
}
(for /sms/send)
or
json
{
"error": "Too many requests for this API key, please try again later."
}
(for all other endpoints)
Endpoints
SMS
Send SMS
http
POST /sms/send
Send an SMS message from a phone number registered to your account.
Request Body
json
{
"from": "7274982200",
"to": "5807480127",
"message": "This is a test message."
}
| Field | Type | Required | Description |
|---|---|---|---|
| ————- | ———— | ————— | —————————————————————————————————— |
| from | string | Yes | The sender’s phone number (must belong to your account, 10/11 digits or E.164) |
| to | string | Yes | The recipient’s phone number (10/11 digits or E.164) |
| message | string | Yes | The SMS message body |
from number must be a phone number registered to your account. The API will reject requests if the number does not belong to your account.Response
json
{
"success": true,
"message_id": "1234567890"
}
If there is an error, you may receive:
json
{
"error": "The from number does not belong to your account."
}
Error Codes
- 400 Bad Request
json
{
"error": "Missing to, from, or message in request body"
}
json
{
"error": "Invalid to or from number format. Use 10 or 11 digit US numbers."
}
- 401 Unauthorized
json
{
"error": "Missing API key"
}
- 403 Forbidden
json
{
"error": "Invalid API key"
}
json
{
"error": "The from number does not belong to your account."
}
- 429 Too Many Requests
json
{
"error": "Too many requests from this IP, please try again later."
}
- 500 Internal Server Error
json
{
"error": "Internal server error",
"message": "An unexpected error occurred",
"timestamp": "2025-06-19T10:30:00.000Z"
}
Example Requests
Using curl
bash
curl -X POST \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"from": "7274982200", "to": "5807480127", "message": "This is a test message."}' \
https://api.webfones.com:2343/sms/send
Using PHP
php
$from,
'to' => $to,
'message' => $message
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP $httpCode\n";
echo "Response:\n$response\n";
Using JavaScript
javascript
const apiKey = 'YOUR_API_KEY';
const baseUrl = 'https://api.webfones.com:2343';
const body = {
from: '7274982200', // Must be a number on your account
to: '5807480127',
message: 'This is a test message.'
};
fetch($baseUrl/sms/send, {
method: 'POST',
headers: {
'x-api-key': apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
.then(res => res.json())
.then(data => console.log(data));
Using Python
python
import requests
API_KEY = ‘YOUR_API_KEY’
BASE_URL = ‘https://api.webfones.com:2343’
from_number = ‘7274982200’ # Must be a number on your account
to_number = ‘5807480127’
message = ‘This is a test message.’
url = f’{BASE_URL}/sms/send’
headers = {
‘x-api-key’: API_KEY,
‘Content-Type’: ‘application/json’
}
data = {
‘from’: from_number,
‘to’: to_number,
‘message’: message
}
response = requests.post(url, headers=headers, json=data)
print(‘HTTP’, response.status_code)
print(‘Response:’, response.text)
Support
For questions, API key requests, or troubleshooting, contact your WebFones administrator or support team.