Push SMS Webhook
This webhook allows you to send messages to our server. These requests should be sent automatically when your number with an active operation receives a message. The URL of the Onlinesim server is provided by the Onlinesim partner support specialists. Please note that the URL in the example below is a placeholder.
Endpoint
POST https://api.veritel.io/push_sms
Headers
Content-Type: application/json; charset=utf-8Authorization: Bearer {apiKey}
Request Body
Your server must send this request once an event is triggered (when the ordered number has received a message).
Schema
{
"operation_id": 355,
"phone_from": "Google",
"phone": "+447518396720",
"text": "G-786824 is your Google verification code.",
"key": "your_api_key_here"
}
Properties
| Field | Type | Required | Description |
|---|---|---|---|
| operation_id | Integer | yes | Operation ID (assigned by your server) |
| phone_from | String | yes | Name or phone number of the sender |
| phone | String | yes | Phone number with active operation |
| text | String | yes | Message text |
| key | String | yes | Your API key |
Responses
Success
- 200 OK: The request was successful. Example response:
{
"status": "SUCCESS"
}
Possible Errors
- 404 NO_OPERATION / NO_OP: This error occurs when you try to push SMS for a number that has no active operation.
- 429 TOO_MANY_ATTEMPTS: This error occurs when you send too many requests in a short period.
- BAD_SERVICE: This error occurs when you try to push SMS from a service that is banned by our server (banks, payment systems, etc.).
- IGNORED: This error occurs when you try to push SMS from a service that differs from the one the client has ordered (only appears when filtration is done on our side).
- SERVICE_BAN: This error occurs when you try to push SMS from a service you've blacklisted.
Example Code
Below is an example of how to send a PUSH_SMS request using modern JavaScript (Fetch API):
async function sendPushSMS(apiUrl, token, smsData) {
try {
const url = `${apiUrl}/push_sms`;
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Authorization': `Bearer ${token}`
},
body: JSON.stringify(smsData)
});
if (response.ok) {
const data = await response.json();
console.log('Response:', data);
return data;
} else {
const errorData = await response.json();
throw new Error(`Error: ${errorData.error_msg}`);
}
} catch (error) {
console.error('Error:', error.message);
throw error;
}
}
// Example usage
const apiUrl = 'https://api.veritel.io';
const token = 'your_api_key_here';
const smsData = {
"operation_id": 355,
"phone_from": "Google",
"phone": "+447518396720",
"text": "G-786824 is your Google verification code.",
"key": token
};
sendPushSMS(apiUrl, token, smsData)
.then(data => console.log('SMS successfully pushed:', data))
.catch(error => console.error('Failed to push SMS:', error.message));
Important Notes
- Encoding Scheme: The request header must have the UTF-8 encoding scheme in the
Content-Type. - Retry Logic: If the response status is not 200, resend the request every 10 seconds until a successful response is received, unless the error is
NO_OPERATIONorBAD_SERVICE.