Twilio SMS and Call management Service
Use Twilio to send SMS notifications and make calls.
This service provides integration with Twilio to allow your Murano solution to send SMS messages or make calls.
Before you can use this service, you need to add your twilio credentials in the service configuration. You can refer to the "configuration" section in following doc for instructions of setting your service configuration - http://docs.exosite.com/development/services/send-notifications/.
Operations
Calls
- Twilio.createCall() - create call
- Twilio.deleteCall() - delete a call
- Twilio.getCall() - get a call
- Twilio.listCall() - list calls
Media
- Twilio.deleteMedia() - delete a media
- Twilio.getMedia() - get a media
- Twilio.listMedia() - get a list of media from a message
Messages
- Twilio.deleteMessage() - delete a message
- Twilio.getMessage() - get a message
- Twilio.listMessage() - list messages
- Twilio.postMessage() - send an SMS message
Tokens
- Twilio.createToken() - create network traversal service tokens
Configuration parameters
Name | Type | Description |
---|---|---|
AccountSid | ^[0-9a-zA-Z]{34}$ | Account SID |
AuthToken | string(password) | Authentication Token |
Operations
createCall
Make a phone call
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
To | string(E.164) | The phone number, SIP address or client identifier to call. |
Url | string(uri) | The fully qualified URL that should be consulted when the call connects. Just like when you set a URL on a phone number for handling inbound calls. When you initiate a call through the REST API, Twilio makes a synchronous HTTP request to the URL found in the value of the "Url" POST parameter, in order to retrieve TwiML for handling the call. This request is identical to the request Twilio sends when receiving a phone call to one of your Twilio numbers. URLs must contain a valid hostname (underscores are not permitted). More information: https://www.twilio.com/docs/api/twiml |
From | string(E.164) | The phone number or client identifier to use as the caller ID. If using a phone number, it must be a Twilio number or a Verified outgoing caller ID for your account. |
Method | "GET", "PUT", "POST" | The HTTP method Twilio should use when making its request to the above URL parameter's value. Default: "POST" |
Record | string | Set this parameter to "true" to record the entirety of a phone call. The RecordingUrl will be sent to the StatusCallback URL. |
Timeout | integer | The integer number of seconds that Twilio should allow the phone to ring before assuming there is no answer. |
IfMachine | "Continue", "Hangup" | Tell Twilio to try and determine if a machine (like voicemail) or a human has answered the call. |
SendDigits | ^[0-9\#\*w]+$ | A string of keys to dial after connecting to the number, maximum of 32 digits. |
FallbackUrl | string(uri) | A URL that Twilio will request if an error occurs requesting or executing the TwiML at URL. |
ApplicationSid | ^[0-9a-zA-Z]{34}$ | The 34 character sid of the application Twilio should use to handle this phone call. |
FallbackMethod | "GET", "POST" | The HTTP method that Twilio should use to request the FallbackUrl. Default: "POST" |
StatusCallback | string(uri) | A URL that Twilio will send asynchronous webhook requests to on every call event specified in the StatusCallbackEvent parameter. |
StatusCallbackEvent | "initiated", "ringing", "answered", "completed" | The call progress events that Twilio will send webhooks on. |
StatusCallbackMethod | "GET", "PUT", "POST" | The HTTP method Twilio should use when requesting the above URL. Default: "POST" |
Responses
Call created
Content: object A Call details
Name | Type | Description |
---|---|---|
to | string(E.164) | The destination phone number. Format with a '+' and country code e.g., +16175551212 (E.164 format). |
sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
uri | string(uri) | The URI for this resource, relative to https://api.twilio.com |
from | string(E.164) | A Twilio phone number (in E.164 format) or alphanumeric sender ID enabled for the type of message you wish to send |
price | ^-?[0-9]*.?[0-9]*$ | The amount billed for the call, in the currency associated with the account. |
status | "queued", "ringing", "in-progress", "canceled", "completed", "failed", "busy", "no-answer" | The status of this message. |
duration | integer | The length of the call in seconds. |
end_time | string(date-time) | The end time of the call, given as GMT in RFC 2822 format. |
direction | "inbound", "outbound-api", "outbound-dial" | The direction of this message. |
price_unit | string(ISO 4127) | The currency in which Price is measured, in ISO 4127 format (e.g., usd, eur, jpy). |
start_time | string(date-time) | The start time of the call, given as GMT in RFC 2822 format. |
account_sid | ^[0-9a-zA-Z]{34}$ | The 34 character unique ID of the Messaging Service you want to associate with this Message. |
answered_by | "human", "machine" | If this call was initiated with answering machine detection. |
api_version | string(date) | The version of the Twilio API used to process the message. |
caller_name | string | If this call was an incoming call to a phone number with Caller ID Lookup enabled, the caller's name. |
date_created | string(date) | The date that this resource was created, given in RFC 2822 format. |
date_updated | string(date) | The date that this resource was last updated, given in RFC 2822 format. |
formatted_to | string | Formatted To |
formatted_from | string | Formatted From |
forwarded_from | string | If this call was an incoming call forwarded from another number, the forwarding phone number. |
parent_call_sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
phone_number_sid | ^[0-9a-zA-Z]{34}$ | If the call was inbound, this is the Sid of the IncomingPhoneNumber that received the call. |
subresource_uris | object | The URIs for any sub-resources associate with this resource, relative to https://api.twilio.com |
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
-- you need to provide a url that has the predefined TwiML files -- for reference - https://www.twilio.com/docs/api/twiml
local out = Twilio.createCall({
From = "+16123409875",
To = "+886912345678",
Url = "https://markpeng-test01.apps.exosite-dev.io/twiml"
})
response.message = out
deleteCall
Delete a call
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
CallSid | ^[0-9a-zA-Z]{34}$ | Twilio call Sid |
Responses
Call deleted
Content: nil
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
-- get a list of call records
local list = Twilio.listCall()
local calls = list.calls
-- get CallSid of the first call
local first_call_sid = calls[1].sid
-- use CallSid as argument to delete the record of first call
local out = Twilio.deleteCall({CallSid = first_call_sid})
response.message = out
getCall
Returns the call details
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
CallSid | ^[0-9a-zA-Z]{34}$ | Twilio call Sid |
Responses
Call information retrieved
Content: object A Call details
Name | Type | Description |
---|---|---|
to | string(E.164) | The destination phone number. Format with a '+' and country code e.g., +16175551212 (E.164 format). |
sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
uri | string(uri) | The URI for this resource, relative to https://api.twilio.com |
from | string(E.164) | A Twilio phone number (in E.164 format) or alphanumeric sender ID enabled for the type of message you wish to send |
price | ^-?[0-9]*.?[0-9]*$ | The amount billed for the call, in the currency associated with the account. |
status | "queued", "ringing", "in-progress", "canceled", "completed", "failed", "busy", "no-answer" | The status of this message. |
duration | integer | The length of the call in seconds. |
end_time | string(date-time) | The end time of the call, given as GMT in RFC 2822 format. |
direction | "inbound", "outbound-api", "outbound-dial" | The direction of this message. |
price_unit | string(ISO 4127) | The currency in which Price is measured, in ISO 4127 format (e.g., usd, eur, jpy). |
start_time | string(date-time) | The start time of the call, given as GMT in RFC 2822 format. |
account_sid | ^[0-9a-zA-Z]{34}$ | The 34 character unique ID of the Messaging Service you want to associate with this Message. |
answered_by | "human", "machine" | If this call was initiated with answering machine detection. |
api_version | string(date) | The version of the Twilio API used to process the message. |
caller_name | string | If this call was an incoming call to a phone number with Caller ID Lookup enabled, the caller's name. |
date_created | string(date) | The date that this resource was created, given in RFC 2822 format. |
date_updated | string(date) | The date that this resource was last updated, given in RFC 2822 format. |
formatted_to | string | Formatted To |
formatted_from | string | Formatted From |
forwarded_from | string | If this call was an incoming call forwarded from another number, the forwarding phone number. |
parent_call_sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
phone_number_sid | ^[0-9a-zA-Z]{34}$ | If the call was inbound, this is the Sid of the IncomingPhoneNumber that received the call. |
subresource_uris | object | The URIs for any sub-resources associate with this resource, relative to https://api.twilio.com |
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
-- get a list of call records
local list = Twilio.listCall()
local calls = list.calls
-- get CallSid of the first call
local first_call_sid = calls[1].sid
-- use CallSid as argument for getCall -- to get the details of the call
local out = Twilio.getCall({CallSid = first_call_sid})
response.message = out
listCall
List all calls on Twilio.
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
PageSize | integer {..1000} | How many resources to return in each list page. Default: 50 |
From | string(E.164) | Only show calls from this phone number or Client identifier. |
To | string(E.164) | Only show calls to this phone number or Client identifier. |
Status | "queued", "ringing", "in-progress", "canceled", "completed", "failed", "busy", "no-answer" | Only show calls currently in this status. |
StartTime | string(date) | Only show messages sent on this date (in GMT format), given as YYYY-MM-DD. |
ParentCallSid | ^[0-9a-zA-Z]{34}$ | Only show calls spawned by the call with this Sid. |
Responses
List call results
Content: object
Name | Type | Description |
---|---|---|
uri | string(uri) | Current page URI |
page | integer | The current page number. Zero-indexed, so the first page is 0. |
calls | [ object ] | Call list |
calls[].to | string(E.164) | The destination phone number. Format with a '+' and country code e.g., +16175551212 (E.164 format). |
calls[].sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
calls[].uri | string(uri) | The URI for this resource, relative to https://api.twilio.com |
calls[].from | string(E.164) | A Twilio phone number (in E.164 format) or alphanumeric sender ID enabled for the type of message you wish to send |
calls[].price | ^-?[0-9]*.?[0-9]*$ | The amount billed for the call, in the currency associated with the account. |
calls[].status | "queued", "ringing", "in-progress", "canceled", "completed", "failed", "busy", "no-answer" | The status of this message. |
calls[].duration | integer | The length of the call in seconds. |
calls[].end_time | string(date-time) | The end time of the call, given as GMT in RFC 2822 format. |
calls[].direction | "inbound", "outbound-api", "outbound-dial" | The direction of this message. |
calls[].price_unit | string(ISO 4127) | The currency in which Price is measured, in ISO 4127 format (e.g., usd, eur, jpy). |
calls[].start_time | string(date-time) | The start time of the call, given as GMT in RFC 2822 format. |
calls[].account_sid | ^[0-9a-zA-Z]{34}$ | The 34 character unique ID of the Messaging Service you want to associate with this Message. |
calls[].answered_by | "human", "machine" | If this call was initiated with answering machine detection. |
calls[].api_version | string(date) | The version of the Twilio API used to process the message. |
calls[].caller_name | string | If this call was an incoming call to a phone number with Caller ID Lookup enabled, the caller's name. |
calls[].date_created | string(date) | The date that this resource was created, given in RFC 2822 format. |
calls[].date_updated | string(date) | The date that this resource was last updated, given in RFC 2822 format. |
calls[].formatted_to | string | Formatted To |
calls[].formatted_from | string | Formatted From |
calls[].forwarded_from | string | If this call was an incoming call forwarded from another number, the forwarding phone number. |
calls[].parent_call_sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
calls[].phone_number_sid | ^[0-9a-zA-Z]{34}$ | If the call was inbound, this is the Sid of the IncomingPhoneNumber that received the call. |
calls[].subresource_uris | object | The URIs for any sub-resources associate with this resource, relative to https://api.twilio.com |
page_size | integer | Number of items in this page |
next_page_uri | string,null(uri) | Next page URI |
first_page_uri | string,null(uri) | First page URI |
previous_page_uri | string,null(uri) | Previous page URI |
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
local out = Twilio.listCall()
response.message = out
deleteMedia
Delete a media
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
MessageSid | ^[0-9a-zA-Z]{34}$ | Twilio message Sid |
MediaSid | ^[0-9a-zA-Z]{34}$ | Twilio message Sid |
Responses
Media deleted
Content: nil
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
-- delete a media from a message
local out = Twilio.deleteMedia({MessageSid = "xxxx", MediaSid = "yyyy"})
response.message = out
getMedia
Returns the media details
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
MessageSid | ^[0-9a-zA-Z]{34}$ | Twilio message Sid |
MediaSid | ^[0-9a-zA-Z]{34}$ | Twilio message Sid |
Responses
Media information retrieved
Content: object The SMS media in Twilio
Name | Type | Description |
---|---|---|
sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
uri | string(uri) | The URI for this resource, relative to https://api.twilio.com |
parent_sid | ^[0-9a-zA-Z]{34}$ | The unique ID of the resource that created the media. |
account_sid | ^[0-9a-zA-Z]{34}$ | The 34 character unique ID of the Messaging Service you want to associate with this Media. |
content_type | string(mime-type) | The default mime-type of the media, for example image/jpeg, image/png, or image/gif |
date_created | string(date) | The date that this resource was created, given in RFC 2822 format. |
date_updated | string(date) | The date that this resource was last updated, given in RFC 2822 format. |
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
-- get media from a message
local out = Twilio.getMedia({MessageSid = "xxxx", MediaSid = "yyyy"})
response.message = out
listMedia
List all SMS media on Twilio
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
MessageSid | ^[0-9a-zA-Z]{34}$ | Twilio message Sid |
PageSize | integer {..1000} | How many resources to return in each list page. Default: 50 |
DateCreated | string(date) | Only show media created on the given date. |
Responses
Media list result
Content: object
Name | Type | Description |
---|---|---|
uri | string(uri) | Current page URI |
page | integer | The current page number. Zero-indexed, so the first page is 0. |
page_size | integer | Number of items in this page |
media_list | [ object ] | Media list |
media_list[].sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
media_list[].uri | string(uri) | The URI for this resource, relative to https://api.twilio.com |
media_list[].parent_sid | ^[0-9a-zA-Z]{34}$ | The unique ID of the resource that created the media. |
media_list[].account_sid | ^[0-9a-zA-Z]{34}$ | The 34 character unique ID of the Messaging Service you want to associate with this Media. |
media_list[].content_type | string(mime-type) | The default mime-type of the media, for example image/jpeg, image/png, or image/gif |
media_list[].date_created | string(date) | The date that this resource was created, given in RFC 2822 format. |
media_list[].date_updated | string(date) | The date that this resource was last updated, given in RFC 2822 format. |
next_page_uri | string,null(uri) | Next page URI |
first_page_uri | string,null(uri) | First page URI |
previous_page_uri | string,null(uri) | Previous page URI |
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
-- get a list of messages
local list = Twilio.listMessage()
local messages = list.messages
-- get MessageSid of the first message
local first_msg_sid = messages[1].sid
-- use MessageSid as argument to get media list of the message
local out = Twilio.listMedia({MessageSid = first_msg_sid})
response.message = out
deleteMessage
Delete a message
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
MessageSid | ^[0-9a-zA-Z]{34}$ | Twilio message Sid |
Responses
Message deleted
Content: nil
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
-- get a list of messages
local list = Twilio.listMessage()
local messages = list.messages
-- get the MessageSid of the first message
local first_msg_sid = messages[1].sid
-- use MessageSid as argument to delete the first message
local out = Twilio.deleteMessage({MessageSid = first_msg_sid})
response.message = out
getMessage
Returns the message details
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
MessageSid | ^[0-9a-zA-Z]{34}$ | Twilio message Sid |
Responses
Message information retrieved
Content: object The SMS message in Twilio
Name | Type | Description |
---|---|---|
to | string(E.164) | The destination phone number. Format with a '+' and country code e.g., +16175551212 (E.164 format). |
sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
uri | string(uri) | The URI for this resource, relative to https://api.twilio.com |
body | string {..1600} | The text of the message you want to send, limited to 1600 characters. |
from | string(E.164) | A Twilio phone number (in E.164 format) or alphanumeric sender ID enabled for the type of message you wish to send |
price | ^-?[0-9]*.?[0-9]*$ | The amount billed for the message, in the currency associated with the account. |
status | "accepted", "queued", "sending", "sent", "failed", "delivered", "undelivered", "receiving", "received" | The status of this message. |
date_sent | string(date) | The date that the message was sent or received, given in RFC 2822 format. |
direction | "inbound", "outbound-api", "outbound-call", "outbound-reply" | The direction of this message. |
num_media | string(integer) | This property indicates the number of media files associated with the message. Each message may send up to 10 media files. |
error_code | string | The error code, if any, associated with your message. If your message status is failed or undelivered, the ErrorCode can give you more information about the failure. |
price_unit | string(ISO 4127) | The currency in which Price is measured, in ISO 4127 format (e.g., usd, eur, jpy). |
account_sid | ^[0-9a-zA-Z]{34}$ | The 34 character unique ID of the Messaging Service you want to associate with this Message. |
api_version | string(date) | The version of the Twilio API used to process the message. |
date_created | string(date) | The date that this resource was created, given in RFC 2822 format. |
date_updated | string(date) | The date that this resource was last updated, given in RFC 2822 format. |
num_segments | string(integer) | This property indicates the number of segments that make up the message. If your body is too large to be sent as a single SMS message, it will be segmented and charged accordingly. |
error_message | string | The human readable description of the ErrorCode above. |
subresource_uri | string(uri) | The URIs for any sub-resources associate with this resource, relative to https://api.twilio.com |
MessagingServiceSid | ^[0-9a-zA-Z]{34}$ | The unique ID of the Messaging Service used with the message. |
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
-- get a list of messages
local list = Twilio.listMessage()
local messages = list.messages
-- get MessageSid of the first message
local first_msg_sid = messages[1].sid
-- use MessageSid as the argument to getMessage
-- to get details about the message
local out = Twilio.getMessage({MessageSid = first_msg_sid})
response.message = out
listMessage
List all SMS messages on Twilio
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
PageSize | integer {..1000} | How many resources to return in each list page. Default: 50 |
From | string(E.164) | Only show messages from this phone number or alphanumeric sender ID. |
To | string(E.164) | Only show messages to this phone number. |
DateSent | string(date) | Only show messages sent on this date (in GMT format), given as YYYY-MM-DD. |
Responses
Message list result
Content: object
Name | Type | Description |
---|---|---|
uri | string(uri) | Current page URI |
page | integer | The current page number. Zero-indexed, so the first page is 0. |
messages | [ object ] | Message list |
messages[].to | string(E.164) | The destination phone number. Format with a '+' and country code e.g., +16175551212 (E.164 format). |
messages[].sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
messages[].uri | string(uri) | The URI for this resource, relative to https://api.twilio.com |
messages[].body | string {..1600} | The text of the message you want to send, limited to 1600 characters. |
messages[].from | string(E.164) | A Twilio phone number (in E.164 format) or alphanumeric sender ID enabled for the type of message you wish to send |
messages[].price | ^-?[0-9]*.?[0-9]*$ | The amount billed for the message, in the currency associated with the account. |
messages[].status | "accepted", "queued", "sending", "sent", "failed", "delivered", "undelivered", "receiving", "received" | The status of this message. |
messages[].date_sent | string(date) | The date that the message was sent or received, given in RFC 2822 format. |
messages[].direction | "inbound", "outbound-api", "outbound-call", "outbound-reply" | The direction of this message. |
messages[].num_media | string(integer) | This property indicates the number of media files associated with the message. Each message may send up to 10 media files. |
messages[].error_code | string | The error code, if any, associated with your message. If your message status is failed or undelivered, the ErrorCode can give you more information about the failure. |
messages[].price_unit | string(ISO 4127) | The currency in which Price is measured, in ISO 4127 format (e.g., usd, eur, jpy). |
messages[].account_sid | ^[0-9a-zA-Z]{34}$ | The 34 character unique ID of the Messaging Service you want to associate with this Message. |
messages[].api_version | string(date) | The version of the Twilio API used to process the message. |
messages[].date_created | string(date) | The date that this resource was created, given in RFC 2822 format. |
messages[].date_updated | string(date) | The date that this resource was last updated, given in RFC 2822 format. |
messages[].num_segments | string(integer) | This property indicates the number of segments that make up the message. If your body is too large to be sent as a single SMS message, it will be segmented and charged accordingly. |
messages[].error_message | string | The human readable description of the ErrorCode above. |
messages[].subresource_uri | string(uri) | The URIs for any sub-resources associate with this resource, relative to https://api.twilio.com |
messages[].MessagingServiceSid | ^[0-9a-zA-Z]{34}$ | The unique ID of the Messaging Service used with the message. |
page_size | integer | Number of items in this page |
next_page_uri | string,null(uri) | Next page URI |
first_page_uri | string,null(uri) | First page URI |
previous_page_uri | string,null(uri) | Previous page URI |
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
local list = Twilio.listMessage()
response.message = list
postMessage
Send an SMS message
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
To | string(E.164) | The destination phone number. Format with a "+" and country code e.g., +16175551212 (E.164 format). |
Body | string {..1600} | The text of the message you want to send, limited to 1600 characters. |
From | string(E.164) | A Twilio phone number (in E.164 format) or alphanumeric sender ID enabled for the type of message you wish to send |
MaxPrice | ^-?[0-9]*.?[0-9]*$ | The total maximum price up to the fourth decimal (0.0001) in US dollars acceptable for the message to be delivered. |
MediaUrl | string(uri) | The URL of the media you wish to send out with the message. gif , png and jpeg content is currently supported and will be formatted correctly on the recipient's device. |
SmartEncoded | boolean | Whether to detect Unicode characters that have a similar GSM-7 character and replace them. Default: true |
ApplicationSid | string | Twilio will POST MessageSid as well as MessageStatus=sent or MessageStatus=failed to the URL in the MessageStatusCallback property of this Application |
StatusCallback | string(uri) | A URL that Twilio will POST to each time your message status changes |
ValidityPeriod | integer | How long in seconds the message can remain in our outgoing message queue. After this period elapses, the message fails and we call your status callback. Can be between 1 and the default value of 14,400 seconds. After a message has been accepted by a carrier, however, we cannot guarantee that the message will not be queued after this period. We recommend that this value be at least 5 seconds. |
ProvideFeedback | boolean | Whether to confirm delivery of the message. Set this value to true if you are sending messages that have a trackable user action and you intend to confirm delivery of the message using the Message Feedback API. This parameter is false by default. |
MessagingServiceSid | ^[0-9a-zA-Z]{34}$ | The 34 character unique ID of the Messaging Service you want to associate with this Message. |
Responses
Message posted
Content: object The SMS message in Twilio
Name | Type | Description |
---|---|---|
to | string(E.164) | The destination phone number. Format with a '+' and country code e.g., +16175551212 (E.164 format). |
sid | ^[0-9a-zA-Z]{34}$ | A 34 character string that uniquely identifies this resource. |
uri | string(uri) | The URI for this resource, relative to https://api.twilio.com |
body | string {..1600} | The text of the message you want to send, limited to 1600 characters. |
from | string(E.164) | A Twilio phone number (in E.164 format) or alphanumeric sender ID enabled for the type of message you wish to send |
price | ^-?[0-9]*.?[0-9]*$ | The amount billed for the message, in the currency associated with the account. |
status | "accepted", "queued", "sending", "sent", "failed", "delivered", "undelivered", "receiving", "received" | The status of this message. |
date_sent | string(date) | The date that the message was sent or received, given in RFC 2822 format. |
direction | "inbound", "outbound-api", "outbound-call", "outbound-reply" | The direction of this message. |
num_media | string(integer) | This property indicates the number of media files associated with the message. Each message may send up to 10 media files. |
error_code | string | The error code, if any, associated with your message. If your message status is failed or undelivered, the ErrorCode can give you more information about the failure. |
price_unit | string(ISO 4127) | The currency in which Price is measured, in ISO 4127 format (e.g., usd, eur, jpy). |
account_sid | ^[0-9a-zA-Z]{34}$ | The 34 character unique ID of the Messaging Service you want to associate with this Message. |
api_version | string(date) | The version of the Twilio API used to process the message. |
date_created | string(date) | The date that this resource was created, given in RFC 2822 format. |
date_updated | string(date) | The date that this resource was last updated, given in RFC 2822 format. |
num_segments | string(integer) | This property indicates the number of segments that make up the message. If your body is too large to be sent as a single SMS message, it will be segmented and charged accordingly. |
error_message | string | The human readable description of the ErrorCode above. |
subresource_uri | string(uri) | The URIs for any sub-resources associate with this resource, relative to https://api.twilio.com |
MessagingServiceSid | ^[0-9a-zA-Z]{34}$ | The unique ID of the Messaging Service used with the message. |
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
-- send an SMS message to a phone number
local out = Twilio.postMessage({
From = "+16125550923",
To = "+17635551234",
Body = "Your device is in an error state."
})
response.message = out
createToken
Network Traversal Service Tokens are ephemeral credentials that let you access TURN resources from WebRTC and VoIP clients. It also provide STUN service.
Arguments
parameters - object - Object containing service call parameters.
Name | Type | Description |
---|---|---|
Ttl | integer {..86400} | The duration in seconds for which the generated credentials are valid. Default: 86400 |
Responses
Returns tokens
Content: object A Token instance resource has the following properties.
Name | Type | Description |
---|---|---|
Ttl | integer {..86400} | The duration in seconds for which the username and password are valid. Default: 86400 |
Password | string | The temporary password that the username will use when authenticating with Twilio. |
Username | string | The temporary username that uniquely identifies a Token. |
AccountSid | string | The unique id of the Account that created this Token. |
IceServers | array | An array representing the ephemeral credentials and the STUN and TURN server URIs. |
DateCreated | string(date) | The date that this resource was created, given in RFC 2822 format. |
DateUpdated | string(date) | The date that this resource was last updated, given in RFC 2822 format. |
Error
Content: object Request error
Name | Type | Description |
---|---|---|
type | string | Error type |
error | string | Error message |
status | integer | Response code |
Example
-- get network traversal service tokens
local out = Twilio.createToken({
Ttl = 3600
})
response.message = out