SMS

A SMS Message resource represents an inbound or outbound SMS message.

SMS Message Resource URI

/2012-04-24/Accounts/{AccountSid}/SMS/Messages/{SMSMessageSid}

Resource Properties

Property Description

Sid

A string that uniquely identifies this SMS Message.

DateCreated

The date that this SMS Message was created.

DateUpdated

The date that this SMS Message was last updated.

DateSent

The date that the SMS was sent or received by RestComm.

AccountSid

The unique id of the Account that sent or received this SMS message.

From

The phone number or short code that initiated the message.

To

The phone number or short code that received the message.

Body

The text body of the SMS message. Up to 160 characters long.

Status

The status of this SMS message. Possible values are queued, sending, sent, failed, and received.

Direction

The direction of this SMS message. Possible values are incoming, outbound-api, outbound-call.

ApiVersion

The API version RestComm used to handle the SMS message.

Uri

The URI for this account, relative to https://localhost/restcomm.

Supported Operations

HTTP GET. Returns the representation of an SMS Message resource, including the properties above. SMS Message List Resource

SMS Message List Resource URI

/2012-04-24/Accounts/{AccountSid}/SMS/Messages

Supported Operations

HTTP GET

Returns the list representation of all the Call resources for this Account, including the properties above.  

HTTP POST

Sends a new SMS Message and returns the representation of the SMS Message resource, including the properties above. Below you will find a list of required and optional parameters.

Request Parameters

Description A phone number that is enabled for SMS. The destination phone number in E.164 format. The text of the message you want to send, limited to 160 characters.

Parameter

From(Required)

To(Required)

Body(Required)

Using SMS and making DID calls

You need to configure Restcomm to send SMS messages and DID phone calls to a Service Provider for provisioning. In the restcomm.xml file, the outbound-proxy-uri and the SMS outbound-endpoint must point to the Service Provider IP address. You may also decide to use Restcomm AMI.

Send SMS Messages

Note the encoding used %2B13216549878 instead of the 13216549878**  The ** sign is encoded to to send SMS from the command line. "From" DID number The "From**" number should be the DID SMS enabled number from VoIP Innovations. From the bash terminal, you can run the command below:

curl -X POST https://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages -d "To=%2B13216549878" -d "From=%2B19876543212" -d "Body=This is a test from RestComm"

Get list of SMS Messages

This will display list of message sent

From the bash terminal, you can run the command below:

curl -X GET https://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages

Example POST Response - XML and JSON

XML POST Response

curl -X POST https://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/Accounts/ACae6e0f425248d6a26948c17a9e2acf/SMS/Messages -d "To=%2B1321654879" -d "From=%2B1654123987" -d "Body=This is a test from RestComm"
<RestcommResponse>
  <SMSMessage>
    <Sid>SM55ce5cf07b9649c283cbacab4dae56a9</Sid>
    <DateCreated>Thu, 19 Nov 2015 07:21:24 -0500</DateCreated>
    <DateUpdated>Thu, 19 Nov 2015 07:21:24 -0500</DateUpdated>
    <DateSent/>
    <AccountSid>ACae6e420f425248d6a26948c17a9e2acf</AccountSid>
    <From>+1654123987</From>
    <To>+1321654879</To>
    <Body>This is a test from RestComm</Body>
    <Status>sending</Status>
    <Direction>outbound-api</Direction>
    <Price>0</Price>
    <PriceUnit>USD</PriceUnit>
    <ApiVersion>2012-04-24</ApiVersion>
    <Uri>/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages/SM55ce5cf07b9649c283cbacab4dae56a9</Uri>
  </SMSMessage>

JSON POST Response

curl -X POST https://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-20f425248d6a26948c17a9e2acf/SMS/Messages.json -d "To=%2B1321654879" -d "From=%2B1654123987" -d "Body=This is a test from RestComm"
{
  "sid": "SM5dd70f7ea54e47f1a49749debeec3f7f",
  "date_created":"Thu, 19 Nov 2015 07:21:35 -0500",
  "date_updated":"Thu, 19 Nov 2015 07:21:35 -0500",
  "account_sid":"ACae6e420f425248d6a26948c17a9e2acf",
  "from":"+1654123987",
  "to":"+1321654879",
  "body":"This is a test from RestComm",
  "status":"sending",
  "direction":"outbound-api",
  "price":"0",
  "price_unit":"USD",
  "api_version":"2012-04-24",
  "uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages/SM5dd70f7ea54e47f1a49749debeec3f7f.json"
}

Example GET Response

JSON GET Response

curl -X GET https://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json
{"page":0,"num_pages":0,"page_size":50,"total":34,"start":"0","end":"34","uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json","first_page_uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json?Page=0&PageSize=50","previous_page_uri":"null","next_page_uri":"null","last_page_uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json?Page=0&PageSize=50","messages":
    [
      {
        "sid":"SM55ce5cf07b9649c283cbacab4dae56a9",
        "date_created":"Thu, 19 Nov 2015 07:21:24 -0500",
        "date_updated":"Thu, 19 Nov 2015 07:21:24 -0500",
        "date_sent":"2015-11-19T07:21:24.000-05:00",
        "account_sid":"ACae6e420f425248d6a26948c17a9e2acf",
        "from":"+19876543212",
        "to":"+13216549878",
        "body":"This is a test from RestComm",
        "status":"sent",
        "direction":"outbound-api",
        "price":"0",
        "price_unit":"USD",
        "api_version":"2012-04-24",
        "uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages/SM55ce5cf07b9649c283cbacab4dae56a9.json"
      },
      ...
    ]
}

Get Response Using SMS SID

curl -X GET https://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/Accounts/ACae6e42f425248d6a26948c17a9e2acf/SMS/Messages/SM55ce5cf07b9649c283cbacab4dae56a9.json
{
  "sid":"SM55ce5cf07b9649c283cbacab4dae56a9",
  "date_created":"Thu, 19 Nov 2015 07:21:24 -0500",
  "date_updated":"Thu, 19 Nov 2015 07:21:24 -0500",
  "date_sent":"2015-11-19T07:21:24.000-05:00",
  "account_sid":"ACae6e420f425248d6a26948c17a9e2acf",
  "from":"+19876543212",
  "to":"+13216549878",
  "body":"This is a test from RestComm",
  "status":"sent",
  "direction":"outbound-api",
  "price":"0",
  "price_unit":"USD",
  "api_version":"2012-04-24",
  "uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages/SM55ce5cf07b9649c283cbacab4dae56a9.json"
}
 

List Filter

HTTP GET. The following GET query string parameters allow you to limit the list returned. Note, parameters are case-sensitive:

Request Parameters

Parameter Description

To

Only show messages to this phone number or Client identifier.

From

Only show messages from this phone number or Client identifier.

StartTime

Only show messages that started on this date, given as YYYY-MM-DD. Also supports inequalities, such as StartTime=YYYY-MM-DD for messages that started at or before midnight on a date, and StartTime=YYYY-MM-DD for messages that started at or after midnight on a date.

EndTime

Only show messages that ended on this date, given as YYYY-MM-DD. Also supports inequalities, such as StartTime=YYYY-MM-DD for messages that started at or before midnight on a date, and StartTime=YYYY-MM-DD for messages that started at or after midnight on a date.

Body

Only show messages that contain this body.

 

Filter using the From parameter.

The example below will only return Messages made from client Alice

 curl -X GET  https://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json?From=alice

The result will be similar to the one below

{"page":0,"num_pages":0,"page_size":50,"total":1,"start":"0","end":"1","uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json","first_page_uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json?Page=0&PageSize=50","previous_page_uri":"null","next_page_uri":"null","last_page_uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json?Page=0&PageSize=50","messages":
    [
      {
        "sid":"SM55ce5cf07b9649c283cbacab4dae56a9",
        "date_created":"Thu, 19 Nov 2015 07:21:24 -0500",
        "date_updated":"Thu, 19 Nov 2015 07:21:24 -0500",
        "date_sent":"2015-11-19T07:21:24.000-05:00",
        "account_sid":"ACae6e420f425248d6a26948c17a9e2acf",
        "from":"alice",
        "to":"+13216549878",
        "body":"This is a test from RestComm",
        "status":"sent",
        "direction":"outbound-api",
        "price":"0",
        "price_unit":"USD",
        "api_version":"2012-04-24",
        "uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages/SM55ce5cf07b9649c283cbacab4dae56a9.json"
      }
    ]
}

Paging Information

HTTP GET. The following GET query string parameters allow you to limit the list returned. Note, parameters are case-sensitive:

Request Parameters

Parameter Description

Page

The current page number. Zero-indexed, so the first page is 0.

NumPages

The total number of pages.

PageSize

How many items are in each page

Total

The total number of items in the list.

Start

The position in the overall list of the first item in this page.

End

The position in the overall list of the last item in this page.

 

Example.

The command below will return a single item from the list of messages using the PageSize parameter

curl -X GET  https://ACae6e420f425248d6a26948c17a9e2acf:77f8c12cc7b8f8423e5c38b035249166@127.0.0.1:8080/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json?PageSize=1

The result of the PageSize parameter

{"page":0,"num_pages":34,"page_size":1,"total":34,"start":"0","end":"0","uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json","first_page_uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json?Page=0&PageSize=1","previous_page_uri":"null","next_page_uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json?Page=1&PageSize=1&AfterSid=SM00ae962506694a61a4e29d776918a747","last_page_uri":"/restcomm/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages.json?Page=34&PageSize=1","messages":
    [
        {
            "sid":"SM00ae962506694a61a4e29d776918a747",
            "date_created":"Fri, 5 Jul 2013 21:32:40 +0900",
            "date_updated":"Fri, 5 Jul 2013 21:32:40 +0900",
            "account_sid":"ACae6e420f425248d6a26948c17a9e2acf",
            "from":"19549376176",
            "to":"+13213557674",
            "body":"Hello",
            "status":"received",
            "direction":"inbound",
            "price":"0.00",
            "price_unit":"USD",
            "api_version":"2012-04-24",
            "uri":"/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/SMS/Messages/SM00ae962506694a61a4e29d776918a747.json"
        }
    ]
}
 

Additional Paging Information.

The API returns URIs to the next, previous, first and last pages of the returned list as shown in the table below:

Request Parameters

Parameter Description

Uri

The URI of the current page.

Firstpageuri

The URI for the first page of this list.

Nextpageuri

The URI for the next page of this list.

Previouspageuri

The URI for the previous page of this list.

Lastpageuri

The URI for the last page of this list.