SMS API documentation This guide is available in: Portuguese, German, Russian and Spanish


SMS is the simplest, easiest, and most commonly used communication channel for enterprises addressing consumers on a larger scale. Various industries, such as banking, finance, retail, healthcare, travel, and hospitality, use SMS to communicate with consumers. This guide shows how you can send a SMS using Gupshup APIs.

We will cover the following topics in this guide:

  1. Setup Webhook/Callback URL
  2. Type of messages & events
  3. Whitelisted Numbers
  4. Sender IDs
  5. Permitted countries
  6. Annexure

Setup Webhook/Callback URL

Inbound events/DLR events sent by operators for SMSs sent, will be sent to your Webhook i.e. If a SMS is successfully sent to the user, Gupshup registers the event and immediately sends a notification (HTTP POST request) to the Webhook specified in your application settings. Some important notes on Webhook:

  1. The webhook should return HTTP_SUCCESS (code: 2xx) with an empty response.
  2. Your webhook should process inbound events asynchronously, but acknowledge its reception synchronously & immediately. Best acknowledge time should be less than 100 millisecond, it is understood that there can be a network delay. Hence, recommended is within 500-1000 millisecond. The Greater your response time, the more delayed inbound messages and events you will receive each time.
  3. The webhook should have public access.

If the callback URL is toggled OFF, you can see incoming messages under Inbound Messages | Events field. Messages and events logged under this field are stored temporarily, meaning if you refresh the page, the logs will be cleared.

Outbound Text Message

Using Gupshup APIs you can send SMSs to permitted countries.

API request

curl --location --request POST 'http://api.gupshup.io/sms/v1/message/:appid' \
--header 'Authorization: api_key' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'destination=918XX9X33X59' \
--data-urlencode 'message=hi' \
--data-urlencode 'source=GSDSMS'

Request Headers

Content-type application/json
apikey

The unique identifier for a Gupshup account.

Request Body

key Description Example Required

destination

The phone number on which the message is to be sent.
The number must be in E.164 format.

441735481364

Yes

message

The content of the message.
Maximum limit is 160 characters.

Hi, your transaction is complete.

Yes

source

The sender ID associated with the approved template message.
Businesses based in India can acquire sender IDs & verified templates using DLT registeration, [click here](https://www.airtel.in/business/commercial-communication/home) to know more.

GSDSMS

Required only for India.
Other permitted countries do not require to specify the sender ID as it is assigned by the operator.

Path variables

Key Description Example Required

appid

The unique identifier for an app.
An app's appid can be found in the cURL request generated on the dashboard.

d7233f89-bf13-27e4-70d1-a981b1427249

Yes

API Response

{
"status": "submitted",
"messageId": "888748c2-0049-4a2f-98d0-5f6967b9d9fd"
}
Key Description Example

status

The delivery status of the message.
The async DLR events for a successful sendmessage API call are sent to your configured webhook/Callback URL.

submitted

messageId

Unique identifier for a message.

888748c2-0049-4a2f-98d0-5f6967b9d9gd

Inbound events

These events state the status of the messages sent. We will send notifications to inform you of the status of a message. When a message is sent, you will receive notifications for when the message is enqueued, sent, and delivered or failed. The order of these notifications in your app may not reflect the actual timing of the message status. View the timestamp to determine the timing, if necessary.

{
"destination": "5535121332829",
"messageId": "6a5a9990-80b3-4a2e-9d37-6442261095a9",
"ts": "1633074677239",
"status": "enqueued | sent | delivered | failed"
}

The payload object

Key Description Example

destination

The phone number of the customer to whom the message was sent. The number is in E.164 format

5535121332829

messageId

This is MessageId for tracking the status of the message

6a5a9930-82b3-4a2e-9d37-6442261095a9

ts

The timestamp of the DLR event

1633074677239

status

The DLR status of message. The status can be: enqueued | sent | delivered or failed

sent

Failure reasons and error codes

Error code Description
NOT_WHITELISTED_COUNTRY(8001) The country you have selected is not currently activated
INSUFFICIENT_WALLET_BALANCE(8002) You do not have sufficient funds to proceed
SENT_FAILED(8003) Message sent failure
INVALID_PHONE_NUMBER(8004) Please enter valid phone number
SERVER_ERROR(8005) The server encountered an internal error and was unable to complete your request
USER_NOT_OPTED_IN(8006) The entered phone number is not opted in
TEMPLATE_MATCHING_FAILED(8007) The template Id does not match with the entered sender ID
INVALID_SENDER_ID(8008) Please enter valid Sender ID
DISABLED_COUNTRY(8009) The recipient country is in a disabled state, please view ?Application Settings? to enable it.
TEMPLATE_DISABLED(8010) The selected template is in a disabled state
BAD_REQUEST(8011) You have sent a request this server could not understand
NOT_FOUND(8012) Template/Sender ID not found
HEADER_DISABLED(8013) The selected Sender ID is in a disabled state
COUNTRY_NOT_FOUND(8014) The selected country is currently not available

Whitelisted numbers

For a sandbox app, the recipient's number must be whitelisted for the app before you can send a SMS message to them. Additionally, Gupshup provides 5 USD worth of free credits in the Gupshup wallet.
There are two ways in which you can whitelist a number.

Sender IDs

Sender IDs are alphanumeric keywords you can use to send messages from. It can help the user identify your business. Sender ID formats vary by channel.
Currently sender IDs are only supported for India. For the remaining permitted countries: Brazil, Colombia, Mexico and Peru, User defined Sender IDs are not allowed, and are assigned depending on the country and the operators.
Businesses based in India can log in to their Airtel DLT account to import their approved Sender IDs and templates. To learn more about DLT registration, click here.

Permitted countries

The degree of rules and regulations for SMS vary from country-to-country. Owing to the personal nature of SMS messages, it is highly regulated by government bodies all over the globe. Using Gupshup APIs you can send SMSs to users based in the following countries: Brazil, Mexico, Colombia, Peru & India.

Annexure

  1. Application (App): An application on the Gupshup platform is a logical container for specific integrations and services. For example, there are two kinds of SMS applications: Sandbox and LIVE Apps.
  2. Number Format: The Gupshup messaging API supports numbers in E.164 format.
  3. API Key: It is the unique identifier for a Gupshup account. It authenticates the APIs.
  4. Webhook(Callback URL): These are user-defined HTTP callbacks triggered by events such as DLRs consisting of the message delivery status.