Our REST API was designed to be simple, robust, and secure. In 30 minutes or less, you will have your system sending SMS automatically—with no need for complex libraries or proprietary SDKs. Any programming language that supports HTTP requests can integrate with our API.
In this comprehensive tutorial, we will cover everything from basic authentication to advanced scenarios like webhooks, bulk sending, and error handling. If you are a developer, this is the guide you've been looking for.

Prerequisites
Before you start, make sure you have:
API Architecture
Our API follows RESTful standards and uses JSON for communication. Endpoints are intuitively organized:
Base URL: https://api.smsgratis.online
Authentication
All requests use a Bearer Token in the HTTP header:
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
The API Key is unique per account and must be kept secret. Never expose your API Key in frontend code, public repositories, or logs. Use environment variables to store it securely:
export SMS_API_KEY="your_key_here"
Sending an Individual SMS
The most basic and essential endpoint:
POST https://api.smsgratis.online/v1/send
{
"to": "5511999999999",
"message": "Your message here"
}
Success response (200):
{
"id": "sms_abc123",
"status": "queued",
"to": "5511999999999",
"credits_used": 1,
"created_at": "2026-02-06T10:30:00Z"
}
Optional parameters:

Sending Bulk SMS
For larger campaigns, use the bulk sending endpoint:
POST https://api.smsgratis.online/v1/send-bulk
{
"numbers": ["5511999999999", "5521888888888"],
"message": "Promotion for everyone!"
}
Success response (200):
{
"batch_id": "batch_xyz789",
"total": 2,
"queued": 2,
"credits_used": 2,
"created_at": "2026-02-06T10:30:00Z"
}
Personalized bulk sending: If you want to customize each message, send an array of objects:
POST https://api.smsgratis.online/v1/send-bulk
{
"messages": [
{"to": "5511999999999", "message": "Hello Maria! 20% OFF for you"},
{"to": "5521888888888", "message": "Hello João! 20% OFF for you"}
]
}
Checking the Status of an SMS
Track the delivery status of each message:
GET https://api.smsgratis.online/v1/status/sms_abc123
Response:
{
"id": "sms_abc123",
"status": "delivered",
"delivered_at": "2026-02-06T10:30:03Z",
"to": "5511999999999"
}
Possible statuses:
Checking Balance
Check your available credits:
GET https://api.smsgratis.online/v1/balance
{
"credits": 4850,
"plan": "enterprise",
"expires_at": "2027-02-06"
}
Webhooks — Real-Time Notifications
Set up webhooks to receive automatic notifications about message delivery status. This eliminates the need to poll (make repetitive queries) to the status endpoint.
Configuration:
POST https://api.smsgratis.online/v1/webhooks
{
"url": "https://yourwebsite.com/sms-webhook",
"events": ["delivered", "failed"]
}
Payload received on your server:
{
"event": "delivered",
"sms_id": "sms_abc123",
"to": "5511999999999",
"timestamp": "2026-02-06T10:30:03Z"
}
Important: Your webhook endpoint must return a 200 status in under 5 seconds. If it fails, we will attempt to resend up to 3 times with increasing intervals.

Error Handling
The API returns standard HTTP status codes:
All error responses include a descriptive message:
{
"error": "insufficient_credits",
"message": "You do not have enough credits for this operation",
"credits_needed": 100,
"credits_available": 50
}
Integration Best Practices
1. Use retry with exponential backoff: If you receive a 429 or 500 error, wait and try again with increasing intervals (1s, 2s, 4s, 8s).
2. Validate numbers before sending: Use the E.164 format (e.g., 5511999999999). Remove spaces, hyphens, and parentheses.
3. Monitor your balance: Set up alerts when credits are running low to prevent service interruption.
4. Use internal references: The reference parameter allows linking each SMS to a record in your system (order, appointment, etc.).
5. Implement idempotency: Use unique IDs to avoid duplicate sends in case of timeout or network error.
API Limits
Examples in Multiple Languages
We have ready-made examples in Python, Node.js, PHP, Java, C#, and Ruby available in our full documentation. Contact us via WhatsApp to receive the documentation link with code examples.
Ready-to-use message templates to integrate into your system
Integrating the API into your workflow is much faster when you already have a standardized text structure. Here are common examples of ready-to-use notifications for your requests:
Common integration errors and how to avoid them
Even with simple endpoints, some pitfalls in the software layer can cause silent failures or unnecessary credit expenditure:
Metrics to monitor in your control panel
Monitoring API delivery performance ensures the health of the integration and budgetary control for the project:
Frequently asked questions about the API
What is the cost per send using the API endpoints?
The cost per message is the same as sending via the web panel, starting at R$ 0,06 per delivered SMS, varying according to the volume of credits purchased for your account.
Do credits expire if I do not use them all immediately?
No. Credits topped up on SMS Grátis Online do not have a short expiration date, remaining available in your account to be consumed as needed by your system.
What happens when the destination device has no signal or is turned off?
The message is held at the mobile carrier centers for a standard window (usually between 24 and 48 hours). If the device reconnects to the network during this period, the message is delivered; if the window expires, the status is updated to expired.
Can I schedule sends directly through the JSON payload?
Yes. Simply fill in the optional scheduled_at parameter with a future date and time in ISO 8601 format (for example: "2026-03-15T09:00:00-03:00"). Our system queues the request and automatically triggers the send at the exact moment.
Conclusion
Integrating with our API is simple and can be done in under 30 minutes. With clear endpoints, standardized responses, and webhook support, you have everything you need to automate SMS sending in your system. Start with the individual sending endpoint, test with your own number, and scale up to bulk sending once you're comfortable.