What is an SMS API? Meaning, how it works and an example

An SMS API is a link that lets your website, app or software send SMS by itself, with one web request, instead of a person typing the message and clicking Send. API stands for Application Programming Interface: a fixed set of rules that two programs use to talk to each other. Your code sends the numbers and the message details to the SMS provider, the provider delivers the SMS through the mobile operators and then tells you whether it was delivered.

Businesses use an SMS API for OTPs, order updates, payment alerts and reminders. Below: how it works in India, SMS API vs gateway vs SMPP, the DLT details you need and a real Fast2SMS request.

SMS API meaning in simple words

An SMS API is a web address on the provider’s server, called an endpoint. Your program sends a request to that address, and the request carries four things:

  • Your API key: a long secret code that proves the request comes from your account. It works like a password for programs.
  • The sender ID and template: which approved header and which approved message text to use.
  • The mobile numbers: one number or many, separated by commas.
  • The variable values: the parts that change in each SMS, such as a name, an order number or an amount.

The API replies within moments with a request ID. You use this ID later to check what happened to each number. When people search for “API SMS”, they mean the same thing: SMS sent through an API.

How an SMS API works in India

  1. Your app sends the request

    A customer places an order. Your website calls the SMS API with your API key, your sender ID, the template and the customer’s number.

  2. Fast2SMS checks the request

    Fast2SMS checks the API key, that the sender ID and template are approved in your account, that the numbers are valid Indian mobile numbers and that your wallet has enough balance. It then replies with a request ID.

  3. The operator runs the DLT check

    The SMS goes to the mobile operator, such as Jio, Airtel, Vi or BSNL. The operator matches it against DLT records: your entity, header, template and PE-TM chain. If something does not match, the operator blocks the SMS. Promotional SMS are not delivered to DND numbers.

  4. The SMS reaches the phone

    When the checks pass and the phone is on and in network, the SMS is delivered, usually within seconds.

  5. You get the delivery report

    The operator sends back a delivery report (DLR). You can see it in Delivery Report in the panel, fetch it with the request ID, or let Fast2SMS post it to your own URL with a webhook. A webhook is a message that your server receives automatically when the status changes.

SMS API vs SMS gateway vs SMPP

These three words are often mixed up. This table shows the difference.

Term What it means Who uses it
SMS gateway The whole service that connects to the operators, runs the checks and returns delivery reports. You use it from a web panel or through an API. Every business that sends SMS
SMS API (HTTP API) The door your software uses to send SMS through the gateway: a web request over HTTPS, with GET or POST, that returns JSON. Websites, apps and CRMs. A few lines of code in any language
SMPP Short Message Peer-to-Peer, a telecom protocol. Your system keeps a long open connection, called a bind, with a system ID and password. Very high-volume senders and SMS platforms that run their own SMPP client

For a closer look, read what an SMS gateway is and how it delivers your messages and SMPP API vs HTTPS API. DLT rules apply in the same way, whichever one you use.

What you need to use an SMS API in India

Under TRAI rules, every business SMS to an Indian number must match records on DLT (Distributed Ledger Technology), the registration system of the operators. Before your first API call, you need:

  • DLT entity registration: your business registers once as a Principal Entity on any one operator’s DLT portal. The entity ID (PE ID) you get works for all operators.
  • An approved header: the sender ID that shows on the phone, such as DEMOTR.
  • Approved content templates: the fixed text of each SMS, with {#var#} where the values change.
  • PE-TM binding: the link between your entity and Fast2SMS as your telemarketer, so operators accept your SMS.
  • A Fast2SMS account: with wallet balance and your API key.

The DLT entity registration fee is ₹5,900 per year including GST (at the time of writing), the same on every DLT portal. SMS sent through the API are charged per SMS from your wallet. See the current rates on the Fast2SMS SMS API page.

Sending in bulk? For high SMS volumes our team offers discounted rates. Talk to our team or see SMS pricing.

New to these terms? Read DLT full form and meaning and what entity ID, sender ID and content template ID are. If you want help with the registration, see DLT registration with Fast2SMS. For testing and internal alerts, the Quick SMS route (route=q) sends without your own DLT template when Quick API Access is switched on.

An SMS API example: a real Fast2SMS request

This is the DLT SMS request from our bulk SMS API guide for India. It sends one approved template to two numbers:

curl -X POST "https://www.fast2sms.com/dev/bulkV2" \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "route": "dlt",
    "sender_id": "FSTSMS",
    "message": "111111",
    "variables_values": "Rahul|8888888888|6695",
    "numbers": "8888888888,9999999999"
  }'
  • Authorization: your API key.
  • route: dlt means “send my approved DLT template”.
  • sender_id: your approved DLT header.
  • message: the Message ID of the template in Fast2SMS DLT Manager. It is not the 19-digit DLT Template ID.
  • variables_values: the value for each {#var#}, in the same order, separated by a pipe (|).
  • numbers: 10-digit mobile numbers, separated by commas.

When the request is accepted, the reply has “return”: true and a request_id. Accepted means the SMS is queued, not yet delivered. The delivery report gives the final status.

You do not have to write this request by hand. In DLT Manager, open Content Template and click Sample Code on an approved template. You get the request with your own sender ID and Message ID filled in.

Fast2SMS SMS API sample code in cURL for an approved DLT template, with sender_id, message, route and numbers
Sample Code on an approved template gives a ready SMS API request.

Set up the SMS API in Fast2SMS

  1. Copy your API key

    Open Account Setting and click API Key under UTILITY. Click View, enter the OTP sent to your account mobile, then copy the Authorization Key. Keep API Access switched on. Reset makes a new key, and the old key stops working. Keep the key on your server, never in browser or app code.

    Fast2SMS API Key page with the masked Authorization Key, View and Reset buttons and the API Access switch
    The API Key page: View the key with an OTP, then copy it.
  2. Allow only your server’s IP

    Open API Security. Add your server’s public IP with Add IP and switch API Security on. Changing the switch needs an OTP. When it is on, only whitelisted IPs can call the API. Calls from other IPs are refused with error 414 and are listed under Latest hits by other IP.

    Fast2SMS API Security page with the API Security switch on, three whitelisted IPs and Latest hits by other IP
    API Security: only the whitelisted IPs can use your API key.
  3. Send a test and check API Logs

    Open API Logs. Every call made with your key is listed for 7 days, with the endpoint, response time, HTTP code, IP, the reply and the status Success or Failed. Click the menu on a row and choose View Details to see the full request and response. Calls with a wrong key are not listed.

    Fast2SMS API Logs list with BULKV2, OTP and WhatsApp API calls, HTTP codes, IPs and Success or Failed status
    API Logs show each request and its reply for 7 days.
  4. Get delivery reports on your server

    Open Webhook, then SMS, and create a webhook with your URL. Fast2SMS posts the status of each number you send through the API to that URL.

SMS API code in your language

Each guide shows working code, error handling and delivery reports:

Frequently asked questions

What is an SMS API?

An SMS API is a link that lets your software send SMS automatically with a web request. You send the numbers and message details, and the provider delivers the SMS and returns a delivery report.

What does API SMS mean?

It means SMS sent through an API, from a website, app or CRM, instead of from a web panel. It is the same thing as an SMS API.

Is an SMS API free?

Creating a Fast2SMS account and getting the API key is free. Each SMS is charged from your wallet, because operators charge for delivery.

Do I need DLT registration to use an SMS API in India?

Yes, for SMS from your own sender ID. Operators block SMS whose header or template is not registered on DLT.

Can I send OTPs with an SMS API?

Yes. Smart OTP creates, sends and verifies the code for you on SMS or WhatsApp with fallback. You can also send your own approved DLT OTP template with route=dlt, and then your app creates and checks the code itself.

What is the difference between an SMS API and an SMS gateway?

The gateway is the whole service that talks to the operators. The API is the door your software uses to send SMS through it.