Menu

Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Messages Resource

The Message resource of Programmable Chat represents a single message within a Channel in a Service instance. POSTing to the Messages resource of a Channel allows you to send messages to the Channel via the REST API.

Properties

Each message has these properties:

Names in Python format
sid
sid<IM> Not PII

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

account_sid
sid<AC> Not PII

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.

service_sid
sid<IS> Not PII

The SID of the Service the resource is associated with.

to
sid<CH> Not PII

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

channel_sid
sid<CH> Not PII

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

date_created
date_time<iso8601> Not PII

The date and time in GMT when the resource was created specified in RFC 2822 format.

date_updated
date_time<iso8601> Not PII

The date and time in GMT when the resource was last updated specified in RFC 2822 format.

last_updated_by

The Identity of the User who last updated the Message if relevant.

was_edited
boolean Not PII

Whether the message has been edited since it was created.

from_

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

body

The content of the message.

index
integer Not PII

The index of the message within the Channel.

type
string Not PII

The Message type. Can be: text or media.

media
object Not PII

A Media object that describes the Message's media if attached. A Media 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`.

url
url Not PII

The absolute URL of the Message resource.

Media resource object properties:

name description
sid A 34 character string that uniquely identifies this resource.
content_type MIME content type which reflects uploaded file type. For example: video/mp4, image/jpeg, etc.
filename Optional — provided filename for the file uploaded. May be null.
size Uploaded file size in bytes

List All Messages in a Channel

GET /Services/{Service SID}/Channels/{Channel SID}/Messages

Parameters

Names in Python format
service_sid
Required
get sid<IS> Not PII

The SID of the Service to read the resources from.

channel_sid
Required
get sid_like<CH> Not PII

The unique ID of the Channel the message to read belongs to. Can be the Channel's sid or unique_name.

order
Optional
get enum:order_type Not PII

The sort order of the returned messages. Can be: asc (ascending) or desc (descending) with asc as the default.

        
        
        
        

        Send a Message to a Channel

        POST /Services/{Service SID}/Channels/{Channel SID}/Messages
        

        Parameters

        Names in Python format
        service_sid
        Required
        post sid<IS> Not PII

        The SID of the Service to create the resource under.

        channel_sid
        Required
        post sid_like<CH> Not PII

        The unique ID of the Channel the new resource belongs to. Can be the Channel resource's sid or unique_name.

        from_
        Optional
        post string PII MTL: 120 DAYS

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

        attributes
        Optional
        post string PII MTL: 120 DAYS

        A valid JSON string that contains application-specific data.

        date_created
        Optional
        post date_time<iso8601> Not PII

        The date, specified in ISO 8601 format, to assign to the resource as the date it was created. The default 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.

        date_updated
        Optional
        post date_time<iso8601> Not PII

        The date, specified in ISO 8601 format, to assign to the resource as the date it was last updated. The default value is null. Note that this parameter should only be used when a Chat's history is being recreated from a backup/separate source and where a Message was previously updated.

        last_updated_by
        Optional
        post string PII MTL: 120 DAYS

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

        body
        Optional
        post string PII MTL: 120 DAYS

        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.

        media_sid
        Optional
        post sid<ME> Not PII

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

              
              
              
              

              Retrieve a Message from a Channel

              GET /Services/{Service SID}/Channels/{Channel SID}/Messages/{Message SID}
              
                    
                    
                    
                    

                    Update an existing Message

                    POST /Services/{Service SID}/Channels/{Channel SID}/Messages/{Message SID}
                    

                    Parameters

                    Names in Python format
                    service_sid
                    Required
                    post sid<IS> Not PII

                    The SID of the Service to update the resource from.

                    channel_sid
                    Required
                    post sid_like<CH> Not PII

                    The unique ID of the Channel the message belongs to. Can be the Channel's sid or unique_name.

                    sid
                    Required
                    post sid<IM> Not PII

                    The Twilio-provided string that uniquely identifies the Message resource to update.

                    body
                    Optional
                    post string PII MTL: 120 DAYS

                    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.

                    attributes
                    Optional
                    post string PII MTL: 120 DAYS

                    A valid JSON string that contains application-specific data.

                    date_created
                    Optional
                    post date_time<iso8601> Not PII

                    The date, specified in ISO 8601 format, to assign to the resource as the date it was created.

                    date_updated
                    Optional
                    post date_time<iso8601> Not PII

                    The date, specified in ISO 8601 format, to assign to the resource as the date it was last updated.

                    last_updated_by
                    Optional
                    post string PII MTL: 120 DAYS

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

                    from_
                    Optional
                    post string PII MTL: 120 DAYS

                    The Identity of the message's author.

                          
                          
                          
                          

                          Delete a Message from a Channel

                          DELETE /Services/{Service SID}/Channels/{Channel SID}/Messages/{Message SID}
                          
                                
                                
                                
                                
                                Rate this page:

                                Need some help?

                                We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.