NAME

Twilio::Rest::Chat::V2::Service::Channel::Message - The Message resource

SYNOPSIS

my $client = Twilio::Rest::Client->new($account_sid, $auth_token);

my $message = $client->chat->v2->services($service_sid)->channels($channel_sid)->messages->create(\%options);
for my $message ($client->chat->v2->services($service_sid)->channels($channel_sid)->messages->read({}, 20)) {
  ...
}
my $message = $client->chat->v2->services($service_sid)->channels($channel_sid)->messages($sid)->fetch;
$client->chat->v2->services($service_sid)->channels($channel_sid)->messages($sid)->update(\%options);
$client->chat->v2->services($service_sid)->channels($channel_sid)->messages($sid)->delete;

DESCRIPTION

Individual chat messages

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->chat->v2->services($service_sid)->channels($channel_sid)->messages. See also Twilio::ListResource.

create

my $message = $client->chat->v2->services($service_sid)->channels($channel_sid)->messages->create(\%options);

Returns a MessageInstance.

The options are:

attributes

A valid JSON string that contains application-specific data.

body

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.

date_created

The date, specified in ISO 8601 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. A string, or an object with an epoch method. See "iso8601_date_time" in Twilio::Serialize.

date_updated

The date, specified in ISO 8601 format, to assign to the resource as the date it was last updated. A string, or an object with an epoch method. See "iso8601_date_time" in Twilio::Serialize.

from

The Identity of the new message's author. The default value is system.

last_updated_by

The Identity of the User who last updated the Message, if applicable.

media_sid

The SID of the Media to attach to the new Message.

x_twilio_webhook_enabled

The X-Twilio-Webhook-Enabled HTTP request header One of true or false.

read

my @records = $client->chat->v2->services($service_sid)->channels($channel_sid)->messages->read(\%options, $limit, $page_size);

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) or desc (descending) with asc as the default. One of asc or desc.

stream

my $stream = $client->chat->v2->services($service_sid)->channels($channel_sid)->messages->stream(\%options, $limit, $page_size);

Takes the same arguments as "read", and returns a Twilio::Stream.

page

my $page = $client->chat->v2->services($service_sid)->channels($channel_sid)->messages->page(\%options, $page_size, $page_token, $page_number);

Fetches one page, and returns a Twilio::Page.

get_page

my $page = $client->chat->v2->services($service_sid)->channels($channel_sid)->messages->get_page($url);

Fetches the page at a URL given by Twilio.

get_context

my $context = $client->chat->v2->services($service_sid)->channels($channel_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->chat->v2->services($service_sid)->channels($channel_sid)->messages($sid). It makes no request until one of these methods is called.

fetch

my $message = $client->chat->v2->services($service_sid)->channels($channel_sid)->messages($sid)->fetch;

Returns a MessageInstance.

update

my $message = $client->chat->v2->services($service_sid)->channels($channel_sid)->messages($sid)->update(\%options);

Returns a MessageInstance.

The options are:

attributes

A valid JSON string that contains application-specific data.

body

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.

date_created

The date, specified in ISO 8601 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. A string, or an object with an epoch method. See "iso8601_date_time" in Twilio::Serialize.

date_updated

The date, specified in ISO 8601 format, to assign to the resource as the date it was last updated. A string, or an object with an epoch method. See "iso8601_date_time" in Twilio::Serialize.

from

The Identity of the message's author.

last_updated_by

The Identity of the User who last updated the Message, if applicable.

x_twilio_webhook_enabled

The X-Twilio-Webhook-Enabled HTTP request header One of true or false.

delete

$client->chat->v2->services($service_sid)->channels($channel_sid)->messages($sid)->delete(\%options);

Returns true.

The options are:

x_twilio_webhook_enabled

The X-Twilio-Webhook-Enabled HTTP request header One of true or false.

MessageInstance

See also Twilio::InstanceResource.

It has fetch, update and delete, which work as they do on the context.

Its fields are:

account_sid

The SID of the Account that created the Message resource.

attributes

The JSON string that stores application-specific data. If attributes have not been set, {} is returned.

body

The content of the message.

channel_sid

The SID of the Channel the Message resource belongs to.

date_created

The date and time in GMT when the resource was created specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.

date_updated

The date and time in GMT when the resource was last updated specified in ISO 8601 format. A Time::Piece object in UTC. See "date_time" in Twilio::Deserialize.

from

The Identity of the message's author. The default value is system.

index

The index of the message within the Channel. Indices may skip numbers, but will always be in order of when the message was received.

last_updated_by

The Identity of the User who last updated the Message, if applicable.

media

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.

service_sid

The SID of the Service the Message resource is associated with.

sid

The unique string that we created to identify the Message resource.

to

The SID of the Channel that the message was sent to.

type

The Message type. Can be: text or media.

url

The absolute URL of the Message resource.

was_edited

Whether the message has been edited since it was created.

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.