Appearance
$io.twilio
Server API reference.
Functions
- $io.twilio.deleteMessage
- $io.twilio.directApiCall
- $io.twilio.fetchMessage
- $io.twilio.listMessages
- $io.twilio.sendMessage
- $io.twilio.updateMessage
$io.twilio.deleteMessage
Delete an SMS or MMS message by its SID using a Twilio connection.
Usage
js
$io.twilio.deleteMessage(connectionName, sid)Description
Deletes an SMS or MMS message from your Twilio account using the specified connection and the message SID. Deletion is permanent and cannot be undone. Returns a status object indicating whether the deletion was successful.
Usage Scenarios
- Remove a message from your Twilio account (note: deletion is permanent)
- Automate cleanup of sensitive or test messages
- Programmatically delete messages as part of a workflow
Parameters
connectionName
Type: String
Required: Yes
The name of the Twilio connection configured in the ioLoop app.
sid
Type: String
Required: Yes
The unique SID of the Twilio message to delete.
Output
Type: Promise
Resolves to an object:
- status: Boolean (true on success, false on error)
- data: Any (the result of Twilio's delete operation; often true on success or API's delete result; null if failed)
- err: String|null (Error message if failed, otherwise null)
Related Functions
$io.twilio.directApiCall
Make a direct HTTP API call to the Twilio REST API using a configured connection.
Usage
js
$io.twilio.directApiCall(connectionName, url, method, queryParams, body, headers)Description
Makes a raw HTTP request to the specified Twilio REST API endpoint using the stored connection's credentials for authentication. Allows for full control over the method, path, query parameters, body, and headers. This is useful for calling endpoints that are not yet wrapped by the SDK or ioLoop plugin. The request will be made using proper authentication, and the response is returned as a status/data/err object.
Usage Scenarios
- Call Twilio REST API endpoints not yet supported by the SDK or wrapper
- Access new or less common Twilio features and resources
- Debug or prototype against the raw Twilio API
Parameters
connectionName
Type: String
Required: Yes
The name of the Twilio connection configured in the ioLoop app.
url
Type: String
Required: Yes
The URL path to the Twilio API endpoint (e.g., '/2010-04-01/Accounts.json' or 'https://api.twilio.com/2010-04-01/Accounts.json', etc). The string {AccountSid} e.g. /2010-04-01/Accounts/{AccountSid}/Messages.json or https://api.twilio.com/2010-04-01/Accounts/{AccountSid}/Messages.json will automatically be replaced by the stored AccountSid from the connection's credentials.
method
Type: String
Required: Yes
HTTP method (GET, POST, PATCH, DELETE, etc.).
queryParams
Type: Object
Required: No
Key-value pairs for the URL query string (optional).
body
Type: Object | String
Required: No
The request body (for POST, PATCH, etc.).
headers
Type: Object
Required: No
Additional HTTP headers as key-value pairs (optional).
Output
Type: Promise
Resolves to an object:
- status: Boolean (true on HTTP 2xx/3xx, false on error or HTTP error)
- data: Any (the raw JSON response or response body from Twilio, or null on error)
- err: String|null (Error message if failed, otherwise null)
Related Functions
$io.twilio.sendMessage$io.twilio.listMessages$io.twilio.fetchMessage$io.twilio.updateMessage$io.twilio.deleteMessage
$io.twilio.fetchMessage
Fetch the details of a single SMS or MMS message by its SID using a Twilio connection.
Usage
js
$io.twilio.fetchMessage(connectionName, sid)Description
Fetches the full details of a single SMS or MMS message by its unique Twilio SID, using the specified connection. Returns all properties provided by the Twilio Message Resource API.
Usage Scenarios
- Retrieve the status and content of a previously sent or received message
- Audit message delivery or troubleshoot issues for a specific message
- Get the full response from Twilio for an individual message
Parameters
connectionName
Type: String
Required: Yes
The name of the Twilio connection configured in the ioLoop app.
sid
Type: String
Required: Yes
The unique SID of the Twilio message to retrieve.
Output
Type: Promise
Resolves to an object:
- status: Boolean (true on success, false on error)
- data: Twilio Message object if found, otherwise null. Includes:
- sid: String (Twilio message SID)
- status: String (queued, sent, delivered, etc.)
- to: String (recipient phone)
- from: String (sender phone or service SID)
- body: String (message text)
- dateCreated: String (RFC 2822 timestamp)
- dateSent: String (RFC 2822 timestamp or null)
- dateUpdated: String (RFC 2822 timestamp)
- errorCode: Number|null
- errorMessage: String|null
- direction: String
- messagingServiceSid: String|null
- ...all other fields from the Twilio REST API message response
- err: String|null (Error message if failed, otherwise null)
Related Functions
$io.twilio.listMessages
List SMS or MMS messages sent or received using a configured Twilio connection.
Usage
js
$io.twilio.listMessages(connectionName, criteria, limit)Description
Retrieves a list of SMS or MMS messages from the Twilio account associated with the specified connection. You can filter results using the criteria object (e.g., by to/from phone, date, status). The limit parameter controls the maximum number of messages returned. Each entry includes detailed information as provided by Twilio's Message Resource API.
Usage Scenarios
- Retrieve message history for auditing or troubleshooting
- Display recent sent or received messages for a user
- Export message logs for analysis or reporting
Parameters
connectionName
Type: String
Required: Yes
The name of the Twilio connection configured in the ioLoop app.
criteria
Type: Object
Required: No
Optional filter criteria as key-value pairs, such as to, from, dateSent, status, etc. See Twilio API documentation for supported fields.
limit
Type: Number
Required: No
Maximum number of messages to return. Defaults to 20 if not specified.
Output
Type: Promise
Resolves to an object:
- status: Boolean (true on success, false on error)
- data: Array of Twilio Message objects, each including:
- sid: String (Twilio message SID)
- status: String (queued, sent, delivered, etc.)
- to: String (recipient phone)
- from: String (sender phone or service SID)
- body: String (message text)
- dateCreated: String (RFC 2822 timestamp)
- dateSent: String (RFC 2822 timestamp or null)
- dateUpdated: String (RFC 2822 timestamp)
- errorCode: Number|null
- errorMessage: String|null
- direction: String
- messagingServiceSid: String|null
- ...all other fields from the Twilio REST API message response
- err: String|null (Error message if failed, otherwise null)
Related Functions
$io.twilio.sendMessage$io.twilio.directApiCall$io.twilio.fetchMessage$io.twilio.updateMessage$io.twilio.deleteMessage
$io.twilio.sendMessage
Send an SMS or MMS message using a configured Twilio connection.
Usage
js
$io.twilio.sendMessage(connectionName, fromPhone, fromService, toPhone, msg, customProps)Description
Sends an SMS or MMS message using the specified Twilio connection. The sender can be a phone number (fromPhone) or a Messaging Service SID (fromService). You must specify the recipient (toPhone) and the message body (msg). The customProps object allows you to pass additional Twilio parameters, such as media URLs for MMS, statusCallback for webhooks, etc. Returns a status object indicating success or failure, along with Twilio's message response data.
Usage Scenarios
- Programmatically send SMS notifications or alerts to users
- Send verification codes, reminders, or OTPs to customers
- Automate text messages as part of workflow or business logic
Parameters
connectionName
Type: String
Required: Yes
The name of the Twilio connection configured in the ioLoop app.
fromPhone
Type: String
Required: No
The Twilio phone number to send from. Either this or fromService is required.
fromService
Type: String
Required: No
The Messaging Service SID to send from. Either this or fromPhone is required.
toPhone
Type: String
Required: Yes
The recipient's phone number (E.164 format).
msg
Type: String
Required: Yes
The text body of the SMS or MMS message.
customProps
Type: Object
Required: No
Optional additional Twilio message parameters (e.g., mediaUrl for MMS, statusCallback, applicationSid, etc.).
Output
Type: Promise
Resolves to an object:
- status: Boolean (true on success, false on error)
- data: Twilio Message object if successful, otherwise null. This object includes:
- sid: String (Twilio message SID)
- status: String (queued, sent, delivered, etc.)
- to: String (recipient phone)
- from: String (sender phone or service SID)
- body: String (message text)
- dateCreated: String (RFC 2822 timestamp)
- dateSent: String (RFC 2822 timestamp or null if not yet sent)
- dateUpdated: String (RFC 2822 timestamp)
- errorCode: Number|null
- errorMessage: String|null
- direction: String
- messagingServiceSid: String|null
- ...plus all other fields from the Twilio REST API message response
- err: String|null (Error message if failed, otherwise null)
Related Functions
$io.twilio.listMessages$io.twilio.directApiCall$io.twilio.fetchMessage$io.twilio.updateMessage$io.twilio.deleteMessage
$io.twilio.updateMessage
Update an SMS or MMS message using a Twilio connection.
Usage
js
$io.twilio.updateMessage(connectionName, sid, customProps)Description
Updates a previously sent SMS or MMS message using the specified Twilio connection. You must specify the message SID and the properties to update via the customProps object. Twilio only allows certain fields to be modified after message creation (e.g., message status, body before delivery). Returns a status object with the updated message details on success.
Usage Scenarios
- Modify the status of a message (e.g., cancel an undelivered message)
- Update message body or other mutable fields if supported
- Programmatically change certain message properties after creation
Parameters
connectionName
Type: String
Required: Yes
The name of the Twilio connection configured in the ioLoop app.
sid
Type: String
Required: Yes
The unique SID of the Twilio message to update.
customProps
Type: Object
Required: No
Key-value pairs of message fields to update. E.g., {body: 'New text', status: 'canceled'}. Only certain fields are permitted by Twilio.
Output
Type: Promise
Resolves to an object:
- status: Boolean (true on success, false on error)
- data: Updated Twilio Message object if successful, otherwise null. Includes:
- sid: String (Twilio message SID)
- status: String (queued, sent, delivered, canceled, etc.)
- to: String (recipient phone)
- from: String (sender phone or service SID)
- body: String (updated message text, if applicable)
- dateCreated: String (RFC 2822 timestamp)
- dateSent: String (RFC 2822 timestamp or null)
- dateUpdated: String (RFC 2822 timestamp)
- errorCode: Number|null
- errorMessage: String|null
- direction: String
- messagingServiceSid: String|null
- ...all other fields from the Twilio REST API message response
- err: String|null (Error message if failed, otherwise null)

