Programmable Chat Message Resource
The Message resource of Programmable Chat represents a single message within a Channel in a Service instance. Creating a new Message resource sends a message to the Channel. Fetching and Reading Message resources provide information about previously sent messages.
Each Message resource contains these properties.
Resource properties sid
type: SID<IM>
The unique string that we created to identify the Message resource.
attributes
type: string
The JSON string that stores application-specific data. If attributes have not been set, {}
is returned.
date_created
type: string<date-time>
date_updated
type: string<date-time>
last_updated_by
type: string
was_edited
type: boolean
Whether the message has been edited since it was created.
body
type: string
The content of the message.
type
type: string
The Message type. Can be: text
or media
.
media
type: object
An object that describes the Message's media, if the message contains media. The object contains these fields: content_type
with the MIME type of the media, filename
with the name of the media, sid
with the SID of the Media resource, and size
with the media object's file size in bytes. If the Message has no media, this value is null
.
url
type: string<uri>
The absolute URL of the Message resource.
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Messages
The {ChannelSid}
value can be the Channel resource's sid
or unique_name
.
Creating a new Message resource in a Channel sends a message to the Channel.
Request headers X-Twilio-Webhook-Enabled
type: enum<string>
The X-Twilio-Webhook-Enabled HTTP request header
Possible values:
true
false
URI parameters Request body parameters Attributes
type: string
A valid JSON string that contains application-specific data.
DateCreated
type: string<date-time>
The date, specified in ISO 8601(link takes you to an external page) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. This parameter should only be used when a Chat's history is being recreated from a backup/separate source.
DateUpdated
type: string<date-time>
LastUpdatedBy
type: string
Body
type: string
The message to send to the channel. Can be an empty string or null
, which sets the value as an empty string. You can send structured data in the body by serializing it as a string.
_12 // Download the helper library from https://www.twilio.com/docs/node/install
_12 // Find your Account SID and Auth Token at twilio.com/console
_12 // and set the environment variables. See http://twil.io/secure
_12 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12 const authToken = process.env.TWILIO_AUTH_TOKEN;
_12 const client = require('twilio')(accountSid, authToken);
_12 client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12 .channels('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12 .create({body: 'Hello, world!'})
_12 .then(message => console.log(message.sid));
_18 "sid": "IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "to": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "date_created": "2016-03-24T20:37:57Z",
_18 "date_updated": "2016-03-24T20:37:57Z",
_18 "last_updated_by": "system",
_18 "body": "Hello, world!",
_18 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Messages/{Sid}
The {ChannelSid}
value can be the Channel resource's sid
or unique_name
.
URI parameters Sid
type: SID<IM>
The SID of the Message resource to fetch.
_12 // Download the helper library from https://www.twilio.com/docs/node/install
_12 // Find your Account SID and Auth Token at twilio.com/console
_12 // and set the environment variables. See http://twil.io/secure
_12 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12 const authToken = process.env.TWILIO_AUTH_TOKEN;
_12 const client = require('twilio')(accountSid, authToken);
_12 client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12 .channels('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12 .messages('IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12 .then(message => console.log(message.to));
_18 "sid": "IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "to": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_18 "date_created": "2016-03-24T20:37:57Z",
_18 "date_updated": "2016-03-24T20:37:57Z",
_18 "last_updated_by": null,
_18 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
GET https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Messages
The {ChannelSid}
value can be the Channel resource's sid
or unique_name
.
URI parameters Order
type: enum<string>
The sort order of the returned messages. Can be: asc
(ascending) or desc
(descending) with asc
as the default.
PageSize
type: integer
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Page
type: integer
The page index. This value is simply for client state.
PageToken
type: string
The page token. This is provided by the API.
_12 // Download the helper library from https://www.twilio.com/docs/node/install
_12 // Find your Account SID and Auth Token at twilio.com/console
_12 // and set the environment variables. See http://twil.io/secure
_12 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12 const authToken = process.env.TWILIO_AUTH_TOKEN;
_12 const client = require('twilio')(accountSid, authToken);
_12 client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12 .channels('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12 .then(messages => messages.forEach(m => console.log(m.sid)));
_54 "first_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages?PageSize=50&Page=0",
_54 "previous_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages?PageSize=50&Page=0",
_54 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages?PageSize=50&Page=0",
_54 "next_page_url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages?PageSize=50&Page=1",
_54 "sid": "IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "to": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "date_created": "2016-03-24T20:37:57Z",
_54 "date_updated": "2016-03-24T20:37:57Z",
_54 "last_updated_by": null,
_54 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
_54 "sid": "IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "to": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "date_created": "2016-03-24T20:37:57Z",
_54 "date_updated": "2016-03-24T20:37:57Z",
_54 "last_updated_by": null,
_54 "sid": "MEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_54 "size": 99999999999999,
_54 "content_type": "application/pdf",
_54 "filename": "hello.pdf"
_54 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
POST https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Messages/{Sid}
The {ChannelSid}
value can be the Channel resource's sid
or unique_name
.
Request headers X-Twilio-Webhook-Enabled
type: enum<string>
The X-Twilio-Webhook-Enabled HTTP request header
Possible values:
true
false
URI parameters Sid
type: SID<IM>
The SID of the Message resource to update.
Request body parameters Body
type: string
The message to send to the channel. Can be an empty string or null
, which sets the value as an empty string. You can send structured data in the body by serializing it as a string.
Attributes
type: string
A valid JSON string that contains application-specific data.
DateCreated
type: string<date-time>
The date, specified in ISO 8601(link takes you to an external page) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. This parameter should only be used when a Chat's history is being recreated from a backup/separate source.
DateUpdated
type: string<date-time>
LastUpdatedBy
type: string
_12 // Download the helper library from https://www.twilio.com/docs/node/install
_12 // Find your Account SID and Auth Token at twilio.com/console
_12 // and set the environment variables. See http://twil.io/secure
_12 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_12 const authToken = process.env.TWILIO_AUTH_TOKEN;
_12 const client = require('twilio')(accountSid, authToken);
_12 client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12 .channels('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12 .messages('IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_12 .update({body: 'body'})
_12 .then(message => console.log(message.to));
_20 "sid": "IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20 "service_sid": "ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20 "to": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20 "channel_sid": "CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_20 "date_created": "2015-12-16T22:18:37Z",
_20 "date_updated": "2015-12-16T22:18:38Z",
_20 "last_updated_by": "username",
_20 "url": "https://chat.twilio.com/v2/Services/ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Channels/CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
DELETE https://chat.twilio.com/v2/Services/{ServiceSid}/Channels/{ChannelSid}/Messages/{Sid}
The {ChannelSid}
value can be the Channel resource's sid
or unique_name
.
Request headers X-Twilio-Webhook-Enabled
type: enum<string>
The X-Twilio-Webhook-Enabled HTTP request header
Possible values:
true
false
URI parameters Sid
type: SID<IM>
The SID of the Message resource to delete.
_11 // Download the helper library from https://www.twilio.com/docs/node/install
_11 // Find your Account SID and Auth Token at twilio.com/console
_11 // and set the environment variables. See http://twil.io/secure
_11 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11 const authToken = process.env.TWILIO_AUTH_TOKEN;
_11 const client = require('twilio')(accountSid, authToken);
_11 client.chat.v2.services('ISXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .channels('CHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .messages('IMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')