Use the Service-scoped Conversation Message resource to interact with messages in Conversations that belong to a non-default, service-scoped Conversation resource.
Please see the Conversation Message Resource API Reference page for Messages that belong to Conversations in the default Conversation Service.
All URLs in the reference documentation use the following base URL:
1https://conversations.twilio.com/v12
For Conversations applications that build on more than one Conversation Service instance, you will need to specify the Conversation Service SID in the REST API call:
1GET /v1/Services/ISxx/Conversations/CHxx/Messages2
The unique ID of the Account responsible for this message.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Conversation Service the Participant resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique ID of the Conversation for this message.
^CH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A 34 character string that uniquely identifies this resource.
^IM[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The channel specific identifier of the message's author. Defaults to system
.
An array of objects that describe the Message's media, if the message contains media. Each 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
.
A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set "{}" will be returned.
The unique ID of messages's author participant. Null in case of system
sent message.
^MB[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The date that this resource was last updated. null
if the message has not been edited.
An object that contains the summary of delivery statuses for the message to non-chat participants.
Contains an absolute API resource URL to access the delivery & read receipts of this message.
The unique ID of the multi-channel Rich Content template.
^HX[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
POST https://conversations.twilio.com/v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Messages
The X-Twilio-Webhook-Enabled HTTP request header
true
false
The SID of the Conversation Service the Participant resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique ID of the Conversation for this message.
application/x-www-form-urlencoded
The channel specific identifier of the message's author. Defaults to system
.
The date that this resource was last updated. null
if the message has not been edited.
A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set "{}" will be returned.
The Media SID to be attached to the new Message.
^ME[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique ID of the multi-channel Rich Content template, required for template-generated messages. Note that if this field is set, Body
and MediaSid
parameters are ignored.
^HX[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A structurally valid JSON string that contains values to resolve Rich Content template variables.
The subject of the message, can be up to 256 characters long.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createServiceConversationMessage() {11const message = await client.conversations.v112.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.conversations("ConversationSid")14.messages.create();1516console.log(message.accountSid);17}1819createServiceConversationMessage();
1{2"sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"conversation_sid": "ConversationSid",6"body": "Hello",7"media": null,8"author": "message author",9"participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",10"attributes": "{ \"importance\": \"high\" }",11"date_created": "2015-12-16T22:18:37Z",12"date_updated": "2015-12-16T22:18:38Z",13"index": 0,14"delivery": {15"total": 2,16"sent": "all",17"delivered": "some",18"read": "some",19"failed": "none",20"undelivered": "none"21},22"content_sid": null,23"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",24"links": {25"delivery_receipts": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts",26"channel_metadata": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelMetadata"27}28}
GET https://conversations.twilio.com/v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Messages/{Sid}
The SID of the Conversation Service the Participant resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A 34 character string that uniquely identifies this resource.
^IM[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchServiceConversationMessage() {11const message = await client.conversations.v112.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.conversations("ConversationSid")14.messages("IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.fetch();1617console.log(message.accountSid);18}1920fetchServiceConversationMessage();
1{2"sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"conversation_sid": "ConversationSid",6"body": "Welcome!",7"media": null,8"author": "system",9"participant_sid": null,10"attributes": "{ \"importance\": \"high\" }",11"date_created": "2016-03-24T20:37:57Z",12"date_updated": "2016-03-24T20:37:57Z",13"index": 0,14"delivery": {15"total": 2,16"sent": "all",17"delivered": "some",18"read": "some",19"failed": "none",20"undelivered": "none"21},22"content_sid": null,23"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",24"links": {25"delivery_receipts": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts",26"channel_metadata": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelMetadata"27}28}
GET https://conversations.twilio.com/v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Messages
The SID of the Conversation Service the Participant resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique ID of the Conversation for messages.
The sort order of the returned messages. Can be: asc
(ascending) or desc
(descending), with asc
as the default.
asc
desc
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1
Maximum: 1000
The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listServiceConversationMessage() {11const messages = await client.conversations.v112.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.conversations("ConversationSid")14.messages.list({ limit: 20 });1516messages.forEach((m) => console.log(m.accountSid));17}1819listServiceConversationMessage();
1{2"meta": {3"page": 0,4"page_size": 50,5"first_page_url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0",6"previous_page_url": null,7"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages?PageSize=50&Page=0",8"next_page_url": null,9"key": "messages"10},11"messages": [12{13"sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",16"conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",17"body": "I like pie.",18"media": null,19"author": "pie_preferrer",20"participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",21"attributes": "{ \"importance\": \"high\" }",22"date_created": "2016-03-24T20:37:57Z",23"date_updated": "2016-03-24T20:37:57Z",24"index": 0,25"delivery": {26"total": 2,27"sent": "all",28"delivered": "some",29"read": "some",30"failed": "none",31"undelivered": "none"32},33"content_sid": null,34"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",35"links": {36"delivery_receipts": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts",37"channel_metadata": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelMetadata"38}39},40{41"sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",42"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",43"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",44"conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",45"body": "Cake is my favorite!",46"media": null,47"author": "cake_lover",48"participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",49"attributes": "{ \"importance\": \"high\" }",50"date_created": "2016-03-24T20:38:21Z",51"date_updated": "2016-03-24T20:38:21Z",52"index": 0,53"delivery": {54"total": 2,55"sent": "all",56"delivered": "some",57"read": "some",58"failed": "none",59"undelivered": "none"60},61"content_sid": null,62"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",63"links": {64"delivery_receipts": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts",65"channel_metadata": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelMetadata"66}67},68{69"sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",70"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",71"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",72"conversation_sid": "CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",73"body": null,74"media": [75{76"sid": "MEaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",77"size": 42056,78"content_type": "image/jpeg",79"filename": "car.jpg"80}81],82"author": "cake_lover",83"participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",84"attributes": "{ \"importance\": \"high\" }",85"date_created": "2016-03-24T20:38:21Z",86"date_updated": "2016-03-24T20:38:21Z",87"index": 0,88"delivery": {89"total": 2,90"sent": "all",91"delivered": "some",92"read": "some",93"failed": "none",94"undelivered": "none"95},96"content_sid": null,97"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",98"links": {99"delivery_receipts": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts",100"channel_metadata": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelMetadata"101}102}103]104}
POST https://conversations.twilio.com/v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Messages/{Sid}
The X-Twilio-Webhook-Enabled HTTP request header
true
false
The SID of the Conversation Service the Participant resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A 34 character string that uniquely identifies this resource.
^IM[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
application/x-www-form-urlencoded
The channel specific identifier of the message's author. Defaults to system
.
The date that this resource was last updated. null
if the message has not been edited.
A string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set "{}" will be returned.
The subject of the message, can be up to 256 characters long.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateServiceConversationMessage() {11const message = await client.conversations.v112.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.conversations("ConversationSid")14.messages("IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.update({ author: "Author" });1617console.log(message.accountSid);18}1920updateServiceConversationMessage();
1{2"sid": "IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"chat_service_sid": "ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",5"conversation_sid": "ConversationSid",6"body": "Hello",7"media": null,8"author": "Author",9"participant_sid": "MBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",10"attributes": "{ \"importance\": \"high\" }",11"date_created": "2015-12-16T22:18:37Z",12"date_updated": "2015-12-16T22:18:38Z",13"index": 0,14"delivery": {15"total": 2,16"sent": "all",17"delivered": "some",18"read": "some",19"failed": "none",20"undelivered": "none"21},22"content_sid": null,23"url": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",24"links": {25"delivery_receipts": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Receipts",26"channel_metadata": "https://conversations.twilio.com/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Conversations/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/ChannelMetadata"27}28}
DELETE https://conversations.twilio.com/v1/Services/{ChatServiceSid}/Conversations/{ConversationSid}/Messages/{Sid}
The X-Twilio-Webhook-Enabled HTTP request header
true
false
The SID of the Conversation Service the Participant resource is associated with.
^IS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
A 34 character string that uniquely identifies this resource.
^IM[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteServiceConversationMessage() {11await client.conversations.v112.services("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.conversations("ConversationSid")14.messages("IMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.remove();16}1718deleteServiceConversationMessage();