NAME
Twilio::Rest::Conversations::V1::Conversation::Message - The Message resource
SYNOPSIS
my $client = Twilio::Rest::Client->new($account_sid, $auth_token);
my $message = $client->conversations->v1->conversations($conversation_sid)->messages->create(\%options);
for my $message ($client->conversations->v1->conversations($conversation_sid)->messages->read({}, 20)) {
...
}
my $message = $client->conversations->v1->conversations($conversation_sid)->messages($sid)->fetch;
$client->conversations->v1->conversations($conversation_sid)->messages($sid)->update(\%options);
$client->conversations->v1->conversations($conversation_sid)->messages($sid)->delete;
DESCRIPTION
A Message resource represents a message in a conversation.
This file holds MessageList, MessagePage, MessageContext and MessageInstance. Methods that make a request throw Twilio::Exceptions::RestException on an error response.
MessageList
Returned by $client->conversations->v1->conversations($conversation_sid)->messages. See also Twilio::ListResource.
create
my $message = $client->conversations->v1->conversations($conversation_sid)->messages->create(\%options);
Add a new message to the conversation. Returns a MessageInstance.
The options are:
attributes-
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 channel specific identifier of the message's author. Defaults to
system. body-
The content of the message, can be up to 1,600 characters long.
content_sid-
The unique ID of the multi-channel Rich Content template, required for template-generated messages. Note that if this field is set,
BodyandMediaSidparameters are ignored. content_variables-
A structurally valid JSON string that contains values to resolve Rich Content template variables.
date_created-
The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. A string, or an object with an
epochmethod. See "iso8601_date_time" in Twilio::Serialize. date_updated-
The date that this resource was last updated.
nullif the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. A string, or an object with anepochmethod. See "iso8601_date_time" in Twilio::Serialize. media_sid-
The Media SID to be attached to the new Message.
subject-
The subject of the message, can be up to 256 characters long.
x_twilio_webhook_enabled-
The X-Twilio-Webhook-Enabled HTTP request header One of
trueorfalse.
read
my @records = $client->conversations->v1->conversations($conversation_sid)->messages->read(\%options, $limit, $page_size);
Retrieve a list of all messages in the conversation. Returns the records as a list, fetching as many pages as it needs.
The options are:
order-
The sort order of the returned messages. Can be:
asc(ascending) ordesc(descending), withascas the default. One ofascordesc.
stream
my $stream = $client->conversations->v1->conversations($conversation_sid)->messages->stream(\%options, $limit, $page_size);
Takes the same arguments as "read", and returns a Twilio::Stream.
page
my $page = $client->conversations->v1->conversations($conversation_sid)->messages->page(\%options, $page_size, $page_token, $page_number);
Fetches one page, and returns a Twilio::Page.
get_page
my $page = $client->conversations->v1->conversations($conversation_sid)->messages->get_page($url);
Fetches the page at a URL given by Twilio.
get_context
my $context = $client->conversations->v1->conversations($conversation_sid)->messages->get_context($sid);
Returns a MessageContext, and makes no request.
MessagePage
A Twilio::Page of MessageInstance objects.
records_key
build_instance
Used by Twilio::Page.
MessageContext
Returned by $client->conversations->v1->conversations($conversation_sid)->messages($sid). It makes no request until one of these methods is called.
fetch
my $message = $client->conversations->v1->conversations($conversation_sid)->messages($sid)->fetch;
Fetch a message from the conversation. Returns a MessageInstance.
update
my $message = $client->conversations->v1->conversations($conversation_sid)->messages($sid)->update(\%options);
Update an existing message in the conversation. Returns a MessageInstance.
The options are:
attributes-
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 channel specific identifier of the message's author. Defaults to
system. body-
The content of the message, can be up to 1,600 characters long.
date_created-
The date that this resource was created. If you set this parameter, Twilio ignores any milliseconds in the timestamp. A string, or an object with an
epochmethod. See "iso8601_date_time" in Twilio::Serialize. date_updated-
The date that this resource was last updated.
nullif the message has not been edited. If you set this parameter, Twilio ignores any milliseconds in the timestamp. A string, or an object with anepochmethod. See "iso8601_date_time" in Twilio::Serialize. subject-
The subject of the message, can be up to 256 characters long.
x_twilio_webhook_enabled-
The X-Twilio-Webhook-Enabled HTTP request header One of
trueorfalse.
delete
$client->conversations->v1->conversations($conversation_sid)->messages($sid)->delete(\%options);
Remove a message from the conversation. Returns true.
The options are:
x_twilio_webhook_enabled-
The X-Twilio-Webhook-Enabled HTTP request header One of
trueorfalse.
delivery_receipts
my $list = $object->delivery_receipts;
my $context = $object->delivery_receipts($sid);
See Twilio::Rest::Conversations::V1::Conversation::Message::DeliveryReceipt.
MessageInstance
See also Twilio::InstanceResource.
It has fetch, update, delete and delivery_receipts, which work as they do on the context.
Its fields are:
- account_sid
-
The unique ID of the Account responsible for this message.
- attributes
-
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 channel specific identifier of the message's author. Defaults to
system. - body
-
The content of the message, can be up to 1,600 characters long.
- content_sid
-
The unique ID of the multi-channel Rich Content template.
- conversation_sid
-
The unique ID of the Conversation for this message.
- date_created
-
The date that this resource was created. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.
- date_updated
-
The date that this resource was last updated.
nullif the message has not been edited. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize. - delivery
-
An object that contains the summary of delivery statuses for the message to non-chat participants.
- index
-
The index of the message within the Conversation. Indices may skip numbers, but will always be in order of when the message was received.
- links
-
Contains an absolute API resource URL to access the delivery & read receipts of this message.
- media
-
An array of objects that describe the Message's media, if the message contains media. Each object contains these fields:
content_typewith the MIME type of the media,filenamewith the name of the media,sidwith the SID of the Media resource, andsizewith the media object's file size in bytes. If the Message has no media, this value isnull. - participant_sid
-
The unique ID of messages's author participant. Null in case of
systemsent message. - sid
-
A 34 character string that uniquely identifies this resource.
- url
-
An absolute API resource API URL for this message.
CONSTRUCTORS
new
Objects here come from the methods above, so there is no need to call new directly.
LICENSE
Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.