Send SMS

Description

Sends an SMS message to a given device or short code.

Users with Essential accounts must purchase the Essential SMS Service package in order to use this API.

Resource URL

POST rws/api/v{apiVersion}/devices/{iccid}/smsMessages

Request Parameters

Request Parameters and Descriptions
Parameter Description
apiVersion

The version number for this API. The current version for all functions is 1.

iccid The ICCID of the device you want information about.
messageText

The SMS message text. The maximum length of the message depends on the data coding type (see dataCoding).

  • 0 - 160 characters
  • 1 - 160 characters
  • 3 - 160 characters
  • 4 - 140 characters
  • 8 - 70 characters

If the API does not specify the data coding type, the default maximum message length is 320 characters. Messages that exceed 160 characters appear on two lines.

messageEncoding (Optional) The type of message encoding used. Valid values are: LITERAL (default) or BASE64.
dataCoding

(Optional) The type of data encoding used.

  • 0 - SMSC default alphabet; often GSM encoding
  • 1 - IA5/ASCII, but sometimes GSM encoding, depending on the SMSC implementation
  • 3 - Latin 1 (ISO-8859-1)
  • 4 - Binary SMS
  • 8 - Unicode UCS2
tpvp

(Optional) The length of time the message is available before expiring. For more information about setting this value, see SMS Validity Period.

Response Parameters

Return Values and Descriptions
Return Value Description
smsMsgId A unique identifier for the SMS message. You can use this ID to get details about a particular message with the Get SMS Details API.

Request Example

Make sure to use your own user credentials. See Authentication for information about creating an authorization header.

json
Copycurl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Basic <YOUR-ENCRYPTED-CREDENTIALS>" -d "{
   \"messageText\": \"Hello world\"
}" "https://rws-jpotest.jasper.com/rws/api/v1/devices/89302720396916018117/smsMessages"

Response Example

json
Copy{
	"smsMsgId": 106184
}

Code Samples

Make sure to use the Control Center sandbox URL and your own user credentials.

javascript
ruby
Copyvar request = require('request'); 
var body = []; 
var auth = "Basic " + new Buffer("username:password").toString("base64"); 
request.post({ 
 url: 'https://rws-jpotest.jasper.com/rws/api/v1/devices/8988216716970004975/smsMessages', 
 headers : {"Authorization" : auth}, 
 body: {"messageText": "Test"}, 
 json: true 
}, 
 function(error, response, body) { 
  if(error) { 
   console.log('Error:', error); 
   return; 
  } else {
   // return statusCode  
   console.log(response.statusCode); 
   // return contentType 
   console.log(response.headers['content-type']); 
   console.log(body); 
  } 
 } 
)
Copy#!/usr/bin/ruby -w 
require 'rest-client' 
require 'json' 
     
url = 'https://rws-jpotest.jasper.com/rws/api/v1/devices/89011704252318147060/smsMessages' 
response = RestClient::Request.execute( 
 method: :post,  
 url: url, 
 user: 'dpSKit20', 
 password: 'b09c4266-83c6-411a-a475-ca4925b3bb4a', 
 :payload => '{"messageText":"testing from minde: sent by ruby"}', 
 :headers => {:accept => :json, 
  :content_type => :json} 
) 
puts JSON.pretty_generate(JSON.parse(response))

Errors

Error Codes, HTTP Codes, and Descriptions
Error Code HTTP Code Error Message
10000001 401

Invalid credentials.

Description: Control Center uses this error message when the API credentials are invalid or when the IP address is not within the allowed range.

10000017 400 Invalid messageEncoding.
10000018 400 Invalid dataCoding.
10000019 400

Invalid tpvp.

Description: The validityPeriod is invalid.

10000020 400

Message length exceeds the maximum permissible length.

10000023 400 The JSON in the request is not well formed. Please ensure that commas, colons, braces etc. are formatted properly.
10000024 400 Invalid apiVersion.
10000028 400

Invalid request.

Description: The request contained one or more unrecognized parameters.

10000030 400 Your role does not have access to this API function.
10000031 400 Invalid Zone.
20000001 404 Resource not found - Invalid ICCID.
30000001 500 Unknown server error.
30000002 500 Control Center failed to submit the message to the SMSC.