NAME

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

SYNOPSIS

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

my $message = $client->chat->v1->services($service_sid)->channels($channel_sid)->messages->create($body, \%options);
for my $message ($client->chat->v1->services($service_sid)->channels($channel_sid)->messages->read({}, 20)) {
  ...
}
my $message = $client->chat->v1->services($service_sid)->channels($channel_sid)->messages($sid)->fetch;
$client->chat->v1->services($service_sid)->channels($channel_sid)->messages($sid)->update(\%options);
$client->chat->v1->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->v1->services($service_sid)->channels($channel_sid)->messages. See also Twilio::ListResource.

create

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

Returns a MessageInstance.

The required values are:

$body

The message to send to the channel. Can also 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.

The options are:

attributes

A valid JSON string that contains application-specific data.

from

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

read

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

fetch

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

Returns a MessageInstance.

update

my $message = $client->chat->v1->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 also 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.

delete

$client->chat->v1->services($service_sid)->channels($channel_sid)->messages($sid)->delete;

Returns true.

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. Note If this property has been assigned a value, it's only displayed in a FETCH action that returns a single resource; otherwise, it's null. If the attributes have not been set, {} is returned.

body

The content of the message.

channel_sid

The unique ID of the Channel the Message resource belongs to.

date_created

The date and time in GMT when the resource was created specified in RFC 2822 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 RFC 2822 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.

service_sid

The SID of the Service the 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.

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.