Send text message over URL parameters

Send SMS by including all the required parameters in the URL using HTTP GET request.

Owning custom made applications tailored for specific requirements of a single organization is an expensive privilege not many can afford. Using third party software solutions for your business needs is a more common case for most businesses today. Those “generic” applications are usually highly configurable in order to cover the widest range of use cases. No matter how clever the application is designed, it seems like there is always at least one crucial feature missing.

If you happen to have one of those applications, you probably have options to configure different workflows and triggers. Very often the application also offers some integration options too. Due to its generic nature, the application has to cover a variety of integration scenarios and also keep a certain level of simplicity to remain intuitive and usable. This trade-off between options and usability can result in a solution with limited integration possibilities.

Integrating our REST API method for sending SMS in such an application may be impossible since you have to configure the request type, headers, and body model. This is something that is usually handled by developers and this type of application will not allow you to write custom code. In a best case scenario it will provide you with a single input to enter the URL of the service you want to trigger, and that’s it.

Simple SMS with basic parameters


With this single input problem in mind, we have designed a method which allows you to send SMS in a single line of the HTTP request:

https://api.infobip.com/sms/1/text/query?username=myUsername&password=myPassword&to=41793026727&text=Message text

This is all you need to send a message. You can even send this message through your web browser address bar, the same way you would type an address to open a web page. Now, this is something that you could put into your application without writing any code!

The response will be identical to the fully featured SMS response:

{
  "bulkId": "1478260834465349757",
  "messages": [
    {
      "to": "41793026727",
      "status": {
        "groupId": 1,
        "groupName": "PENDING",
        "id": 7,
        "name": "PENDING_ENROUTE",
        "description": "Message sent to next instance"
      },
      "smsCount": 1,
      "messageId": "844acc75-e5c6-4a21-a7e3-444c412c385b"
    }
  ]
}	
  

XML response format

The default response format is JSON. However, if you would like to receive XML as a response instead, you may specify the format .xml extension at the end of the method base URL, such as:

https://api.infobip.com/sms/1/text/query.xml

There is one more catch. You will probably need to replace hard-coded values like phone number and message text with placeholders unless you want to send the same message to the same recipient every time. Placeholder names will be provided by the application system you are using. What you need to understand is where to put these placeholders. Let’s break down our example request in several lines so we can examine it closely:

https://api.infobip.com/sms/1/text/query?
username=myUsername
&password=myPassword
&to=41793026727
&text=Message text

The first line is the API endpoint and this never changes. The question mark at the end represents the beginning of the query string parameters. It is a system of key / value pairs separated by the symbol &. It’s quite clear now what the values are and which values you will need to replace by a value placeholder.

&to=%phoneNumber%
&text=%message%

Value placeholders

Placeholder names and format will vary depending on your application. Refer to your application documentation for instructions.

Here is the final result:

https://api.infobip.com/sms/1/text/query?username=myUsername&password=myPassword&to=%phoneNumber%&text=%message%

Your application should now dynamically send different messages to different recipients by dynamically replacing placeholders with the recipient phone number and message.

Key / value pairs

It’s important to understand how to properly format the query string in order to make it work properly. Here is the rule that must be followed:

https://api.infobip.com/sms/1/text/query ? key = value & key = value & key = value

The sorting of key / value pairs is not important as long as it’s well formatted. If your application supports placeholders, you should use it to replace values only!

Multiple recipients


Sending messages to multiple recipients at once is also supported, as long as they all get the same message. The URL is basically the same as simple SMS. The only difference is in the to key, where you need to separate recipients by coma.

https://api.infobip.com/sms/1/text/query?username=myUsername&password=myPassword&to=41793026727,41793026834&text=Message text

Closer look:

&to=41793026727,41793026834

Fully featured SMS


You can use this method to send an SMS with almost all of the features of our standard fully featured SMS

Optional key value pairs:

&from=InfoSMS
&flash=true
&transliteration=TURKISH
&languageCode=TR
&intermediateReport=true
&notifyUrl=https//www.example.com
&notifyContentType=application/json
&callbackData=callbackData
&validityPeriod=86400000
&track=SMS
&processKey=A612ECB0F62799FDC12EC50D2A6F0472
&trackingType=Custom+field+test

Refer to our fully featured SMS documentation for an explanation of each parameter.

Important!

Please use this method for sending messages only when you don’t have the option to integrate via the fully featured SMS method.

Please keep in mind:

  • This method does not support API key authorization. You are sending the username and password over the network which is less secure than while using API key.
  • Your application should support URL encoding of your requests. Messages that are not properly formatted may be delivered with incorrectly encoded text or not delivered at all.