Back to blog
    TUTORIAL16 min

    How to Integrate Our SMS API into Your System in 30 Minutes

    Technical tutorial for developers: integrate automated SMS sending into your system.

    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.

    How to Integrate Our SMS API into Your System in 30 Minutes — ilustração 1
    How to Integrate Our SMS API into Your System in 30 Minutes

    Prerequisites

    Before you start, make sure you have:

  1. **Active account on SMS Grátis Online**: If you don't have one yet, create it via WhatsApp (11) 91994-7177
  2. **API Key**: Request it via WhatsApp or in the control panel
  3. **Basic knowledge of HTTP requests**: GET, POST, and headers
  4. **Development environment**: Any code editor and terminal/Postman for testing
  5. API Architecture

    Our API follows RESTful standards and uses JSON for communication. Endpoints are intuitively organized:

  6. `/v1/send` — Individual SMS sending
  7. `/v1/send-bulk` — Bulk sending
  8. `/v1/status/{id}` — Status check
  9. `/v1/balance` — Balance check
  10. `/v1/contacts` — Contact management
  11. `/v1/campaigns` — Campaign management
  12. 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:

  13. `scheduled_at`: Schedule delivery for a specific date/time (ISO 8601 format)
  14. `callback_url`: URL to receive delivery notification
  15. `reference`: Your internal ID for tracking
  16. How to Integrate Our SMS API into Your System in 30 Minutes — ilustração 2
    How to Integrate Our SMS API into Your System in 30 Minutes

    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:

  17. `queued`: In the queue for sending
  18. `sent`: Sent to the carrier
  19. `delivered`: Delivered to the device
  20. `failed`: Delivery failure (invalid number, full inbox, etc.)
  21. `expired`: Expired without delivery confirmation
  22. 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.

    How to Integrate Our SMS API into Your System in 30 Minutes — ilustração 3
    How to Integrate Our SMS API into Your System in 30 Minutes

    Error Handling

    The API returns standard HTTP status codes:

  23. **200**: Success
  24. **400**: Invalid request (check parameters)
  25. **401**: Invalid or missing API Key
  26. **402**: Insufficient credits
  27. **429**: Rate limit exceeded (too many requests)
  28. **500**: Internal error (contact us)
  29. 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

  30. **100 requests per second** per API Key
  31. **10,000 numbers per request** for bulk sending
  32. **Messages up to 160 characters** (automatic concatenation for longer messages)
  33. **Webhook timeout**: 5 seconds for response
  34. **Log retention**: 90 days
  35. 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:

  36. **Two-factor authentication (2FA/OTP)**: "Your SMS Grátis Online security code is 482910. Valid for 5 minutes. Do not share this code with third parties."
  37. **E-commerce order confirmation**: "Hello, Mariana! Your order #4082 has been successfully approved and is already being prepared. Track the details in your account dashboard."
  38. **Appointment or scheduling reminder**: "Hello! This is a reminder of your appointment scheduled for tomorrow at 2:30 PM. Please confirm your attendance by replying YES to this number."
  39. **Billing alert or Pix payment request**: "Hello, Carlos. Your invoice is due today. Avoid interest by paying via the copy-and-paste Pix available in your financial app."
  40. **Delivery tracking update**: "Great news! Your package is out for delivery. Please keep an eye out at the registered address throughout the day."
  41. **Abandoned cart recovery**: "We noticed you left items in your cart! Complete your purchase today and take advantage of the special conditions reserved for you."
  42. 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:

  43. **Incorrect number formatting**: The API expects the format with the country code (55 for Brazil), a two-digit area code, and the mandatory ninth digit for mobile phones. Characters such as parentheses, hyphens, or spaces cause a 400 error. Sanitize strings on your backend before dispatching the JSON.
  44. **Inadvertent use of Unicode characters**: Messages in standard basic GSM accept up to 160 characters per credit. If you insert characters with special accents, uppercase cedillas, or emojis, the protocol switches to UCS-2 encoding, which reduces the limit to 70 characters per part and can consume multiple credits without you realizing it.
  45. **Blocking synchronous requests**: Triggering calls to `/v1/send` in the middle of your user's request (for example, in the same checkout completion thread) can slow down your page load. Always offload dispatching to asynchronous queues (such as Redis, RabbitMQ, or SQS).
  46. **Neglecting Webhook processing**: Failing to respond with an HTTP 200 status to our webhook within 5 seconds causes our platform to attempt resending the notification, resulting in duplicate processing on your server. Make sure to record the status and respond immediately.
  47. Metrics to monitor in your control panel

    Monitoring API delivery performance ensures the health of the integration and budgetary control for the project:

  48. **Delivery Rate**: Measures the percentage of messages with a `delivered` status relative to the total sent (`sent`). Sharp drops in this indicator usually signal outdated contact lists or issues with local carriers.
  49. **Sending latency**: Time interval between record creation (`queued`) and confirmation of receipt on the device (`delivered`). Essential for OTP authentication flows, where the user expects the code within seconds.
  50. **Invalid number rate (Bounces)**: Messages with `failed` status resulting from non-existent or landline numbers. Serves as a benchmark to trigger cleanup routines in your database.
  51. **Credit consumption (Burn Rate)**: Daily monitoring of the debited balance. Helps forecast the exact moment to top up to keep automated sends active without operational disruptions.
  52. 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.