Send a Message

Base URI

https://rest.telemessage.com

Endpoint

POST /rest/message/send

Sends a message via TeleMessage service.

Request

Provides the sending user’s authentication details and the message contents.

Property Type Description
loginDetails
AuthenticationDetails The credentials of the user sending the message.
message
Message The message data.

Response

Returns a MessageResponse object, containing the request result code and description. A successfully received message will also include the message ID and key.

Property Type Description
resultCode
int Numeric representation of result (see Error & Status Codes).
resultDescription
String Textual explanation of result (see Error & Status Codes).
messageID
long Unique identifier for each message in the TeleMessage system. Used to track messages throughout the system.
messageID
String Unique key of a message in the TeleMessage system. The key is randomly generated and used for security reasons to acquire the information about the message. This is similar to having a password accompanying a user ID to secure entrance.

 

  • [  
       {  
          "class":"telemessage.web.services.AuthenticationDetails",
          "username":"john_doe",
          "password":"84738821"
       },
       {  
          "class":"telemessage.web.services.Message",
          "textMessage":"Hello dear, how are you? :-)",
          "recipients":[  
             {  
                "value":"+1-781-3683109",
                "type":"SMS",
                "description":"Mrs. Jane Doe",
                "class":"telemessage.web.services.Recipient"
             }
          ]
       }
    ]
    [  
       {  
          "class":"telemessage.web.services.MessageResponse",
          "messageID":27042354,
          "messageKey":"986307652533704548852455773225",
          "resultCode":100,
          "resultDescription":"Message has been sent"
       }
    ]

    See the following code examples in Java of how to Post JSON to the TeleMessage REST gateway:

    Note: we are using Apache HttpClient 4.3 in this example. 

            String json = "....your json here...";
            
            try {
                CloseableHttpClient httpclient = HttpClients.createDefault();
                HttpPost httppost = new HttpPost(tm.getSendURL(TeleMessage.Interface.JSON));
                StringEntity entity = new StringEntity(json, Charset.forName("UTF-8"));
                httppost.setEntity(entity);
    
                HttpResponse resp = httpclient.execute(httppost);
                if (resp != null && resp.getStatusLine().getStatusCode() == 200) {
                    InputStream in = resp.getEntity().getContent();
                    try {
                        // read and parse response from TeleMessage
                        ........................
                        ........................
                        ........................
                        ........................
                    } finally { 
                       if (in != null) IOUtils.closeQuietly(in); 
                    } 
                 } 
            } catch (Exception e) { 
                 e.printStackTrace(); 
            } 

    Store messageID and messageKey in order to query status.

    Note: in order to send an IP Push Notification, you would send the message as if you were sending an SMS. TeleMessage checks if the recipient has the application. If so, the message will then be sent as an IP Push Notification. Please configure whether you want to send IP Push Notifications only, or enable SMS Fallback to ensure that messages will be delivered to the recipient in case the IP Push Notification fails via the TeleMessage web portal

  •  

    [  
       {  
          "username":"john_doe",
          "password":"84738821",
          "class":"telemessage.web.services.AuthenticationDetails"
       },
       {  
          "textMessage":"Rest sample",
          "fileMessages":[  
             {  
                "fileName":"file.png",
                "mimeType":"image/png",
                "value":"iVBORw0KGgoAAAANSUhEUgAAASAAAAAqCAMA
    			AAAksXZgAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1M
    			AAA6mAAADqYAAAXb5JfxUYAAAMAUExURQAAAGtpbW5scG
    			9tcWxxc3Fvc3NxdXVzd3F1eHd1eXZ6fXp3e3x6fn17f3h
    			9gH99gQCa1gCb1wCe2x2Y1gWg3Qqh3g6k2xWm3Rmn3h2p
    			3ySv3ymg2DKp2jWq2zer3D+03yGq4Six4Suy4jyu4D2v4
    			XyBg36DhXWIlH2MknKRoHWUo3+ao3KfsmGiv2ijunKnuX
    			6ls0Kq1Uiu2k+z31SoyVuvz1Cs00O34Ua55Ei75lG24la
    			55lS84Va94le+41i\/5WCsx2ytymq20WK84mS+5VrA5lv
    			C52bA52bE42nG52nC6XHD5HLE5XTG53fI6n3I5HnK7IB+
    			goJ\/g4SChoOHioaEiIWJjIeMj4iGioqIjI2KjoOKkoqP
    			koKSmICTn4iQl4iUlY2RlI6TlZCOkpKQlJORlZaUmJOYm
    			pWanJecnpiWmpqXnJuZnZ2bn4Kdp42co5qfoYintp2ipK
    			GeoqOgpKClp6Wjp6GmqaSprKarraimqqqorKupra2rr6m
    			usK+ssayxs622vrGvs7C1t7Wytre1ubO4urW6vbe8v7q3
    			vLy6voWxxZq1wJu3wbq\/wYLM6YTO6oXQ7IfS7o7T6pDR
    			75XQ6JfS6pjT7JvW7pzX757Z8bzBw7\/Ex6PZ7KXb7q7X
    			5aje8bbe7bDd8bLf86rg87Pg9Lni8Lvk8r3m9MC9wsbDy
    			MPIy8bLzsvJzcnO0c\/N0czS1NDSz9DV19LX2tfU2dbb3
    			trc2drf4sbm98Dp98Xp8srn8czo88\/r9sjo+Nzh49\/k
    			5tbv9NLu+d7v9dru+uHj4OPg5ePm4uDl6Obo5eTp6+ft7
    			+jl6unr6Ozq7uzv6+nu8e\/x7uDx9+Pz+uT1++b3\/ej1
    			9un29+zy9O\/09\/L08QAAAAAAAAAAAAAAAAAAAAAAAAA
    			AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    			AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    			AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD74ZDkAAAEAdF
    			.............................................
    			.............................................",
                "type":0,
                "class":"telemessage.web.services.FileMessage"
             }
          ],
          "recipients":[  
             {  
                "value":"someemail@somedomain.com",
                "type":"EMAIL",
                "addresType":0,
                "class":"telemessage.web.services.Recipient"
             }
          ],
          "subject":"Hello World",
          "class":"telemessage.web.services.Message"
       }
    ]
    [  
       {  
          "class":"telemessage.web.services.MessageResponse",
          "messageID":27042354,
          "messageKey":"986307652533704548852455773225",
          "resultCode":100,
          "resultDescription":"Message has been sent"
       }
    ]

    Note: The value inside fileMessages element, has to be file data encoded using the Base64 encoding format. Read more here.

    Store messageID and messageKey in order to query status.

    Note: in order to send an IP Push Notification, you would send the message as if you were sending an SMS. TeleMessage checks if the recipient has the application. If so, the message will then be sent as an IP Push Notification. Please configure whether you want to send IP Push Notifications only, or enable SMS Fallback to ensure that messages will be delivered to the recipient in case the IP Push Notification fails via the TeleMessage web portal

  •  

    [  
       {  
          "class":"telemessage.web.services.AuthenticationDetails",
          "username":"john_doe",
          "password":"84738821"
       },
       {  
          "class":"telemessage.web.services.Message",
          "textMessage":"Hello dear, how are you? :-)",
          "recipients":[  
             {  
                "value":"+1-781-3683109",
                "type":"SMS",
                "description":"Mrs. Jane Doe",
                "class":"telemessage.web.services.Recipient"
             }
          ],
          "properties": [
             {
                "class": "telemessage.web.services.Property",
                "name" : "AlphanumericSender",
                "value": "13 Character Sender"
             }
          ]
       }
    ]
    [  
       {  
          "class":"telemessage.web.services.MessageResponse",
          "messageID":27042354,
          "messageKey":"986307652533704548852455773225",
          "resultCode":100,
          "resultDescription":"Message has been sent"
       }
    ]

For more information, please read this FAQ.

 

Explore additional code samples & developer resources:

JAVA LibraryPHP LibrarySOAP APIXML APIHTTP API, and more