About

This API method allows you to programatically send or schedule an SMS message. SMS may be sent to any destination and can be sent using an E164, alphanumeric or "leased" sender ID.

Your account and property must be enabled for SMS. Please contact client services to have SMS enabled.

Alphanumeric Sender IDs

Alphanumeric sender IDs are supported in many regions, notably excluding US and Canada. If a recipient operator does not support alphanumeric sender IDs, a leased sender ID will be applied. The following rules apply for alphanumeric sender IDs:

  • Length between 1 and 11 characters
  • Valid characters include A-Z, a-z, 0-9 and spaces
  • Must include at least one letter

Leased Sender IDs

Leased sender IDs are automatically assigned sender IDs that are unique to the recipient and that are valid for 30 days. Leased sender IDs allow you to specify response options on a per message basis, such as forwarding responses to a mobile or email or forwarding responses and delivery receipts to a webhook URI.

Note that you may only have 5 leases to a specific recipient at any one time.

Resource URI

SMS messages are sent using the following call.

POST

/v2/Properties/[PropertySid]/Messages

Request

URI Parameters

ParameterTypeDescription
PropertySidstringThe secure identifier of the property from which to send the SMS.

Resource Parameters

ParameterTypeDescription
FromstringThe sender ID. This can be a mobile phone number in E164 format (including + prefix), an alphanumeric string, or blank or omitted to send from a leased number.
TostringThe recipient of the SMS message in E164 format (including + prefix).
TextstringThe content of the SMS message.

Optional Parameters

ParameterTypeDescription
ScheduleintegerThe UTC time in seconds since Unix Epoch to send the message. This can be at most 14 days in the future. If the value is in the past, the request will fail, unless the value is less than 1 hour in the past, in which case the request will succeed and the message will be sent immediately.
DeliveryReceiptbooleanWhether to request a delivery receipt. Valid options are:
  • true – request a delivery receipt (default)
  • false – do not request a delivery receipt
DeliveryReceiptWebhookUristringThe callback URI to invoke when a delivery receipt is received. Note that DeliveryReceipt must be set to true for this to be triggered.
DeliveryReceiptWebhookMethodstringThe method to use for delivery receipt callbacks. Valid options are POST and GET. Default is POST.
ExternalIdstringUser-defined arbitrary id which is attached to the message and can be retrieved later.

Lease-Specific Optional Parameters

The following optional parameters may be used when sending from a leased number (when From is blank or unspecified). When a response to the sent message is received, the following parameters define how the response is treated.

ParameterTypeDescription
ForwardToSmsstringWhen a response is received, forward it to this number in E164 format.
ForwardFromSmsstringWhen forwarding via SMS, send from this E164 formatted number or alphanumeric sender ID. By default the sender ID will be the sender ID of the responding party.
ForwardToEmailstringWhen a response is received, forward it over email to this email address.
ForwardFromEmailstringWhen forwarding via email, send from this email address. By default this is a "no reply" email address.
WebhookUristringThe callback URI to invoke when a response is received.
WebhookMethodstringThe method to use for response callbacks. Valid options are POST and GET. Default is POST.
Example: Sending a simple SMS message.
  • JSON
{

"From": "+61499009990",

"To": "+61488023555",

"Text": "You win again, gravity!"

}
Example: Sending an SMS message from a lease with all parameters.
  • JSON
{

"From": "",

"To": "+61488023555",

"Text": "You call that an antenna?",

"Schedule": 1321009871,

"DeliveryReceipt": true,

"DeliveryReceiptWebhookUri": "https://callback.2.me/for/delivery_receipt",

"DeliveryReceiptWebhookMethod": "POST",

"ForwardToSms": "+61499333222",

"ForwardFromSms": "",

"ForwardToEmail": "forwarded@2.me",

"ForwardFromEmail": "noreply@fonedynamics.com",

"WebhookUri": "https://callback.2.me/for/sms_responses",

"WebhookMethod": "POST",

"ExternalId": "testid123"

}

Response

200 – OK

On successful acknowledgement of the SMS message, a 200 OK is returned with a JSON formatted Message resource instance.

Message Resource Parameters

ParameterTypeDescription
MessageSidstringThe message secure identifier which uniquely identifies this message.
AccountSidstringThe account secure identifier associated with the message.
PropertySidstringThe property secure identifier associated with the message.
FromstringThe alphanumeric or E164 formatted sender ID of the message. If the message was sent using a leased sender ID, this field will be populated with the actual E164 sender ID that was allocated to the SMS message.
TostringThe E164 formatted recipient of the SMS message.
TextstringThe content of the SMS message.

Example: An example response to the successful acknowledgement of an SMS message.
  • JSON
{
    Message:
    {
        "MessageSid": "M87DMNHSDJHSD48DMNSDS6VJCNKD9MD0",

        "AccountSid": "AG5T3HFR5ASD54FS5GB3SDAFJAKSH6DS",

        "PropertySid": "S7DNJ9KJDS0MDS23DKS9QMZ8DKJSD9KL",

        "From": "+6199111222",

        "To": "+61488023555",

        "Text": "You call that an antenna?"
    }
}

400 – Error

For error codes and messages, please refer here.