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:

account_sid
sid<AC> Not PII

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.

body

The contents of the message.

date_created
date_time<iso8601> Not PII

The date that this resource was created.

date_updated
date_time<iso8601> Not PII

The date that this resource was last updated. null if the message has not been edited.

from

The identity of the message's author. Defaults to system.

index
integer Not PII

The index of the message within the Channel

last_updated_by

Field to specify the Identity of the User that last updated the Message (if relevant)

media
object Not PII

If a Media resource instance (file) is attached to the Message, this will contain the Media object for the attached Media. null if no Media is attached to the Message. See the table below for the details.

service_sid
sid<IS> Not PII

The unique id of the Service this message belongs to.

sid
sid<IM> Not PII

A 34 character string that uniquely identifies this resource.

to
sid<CH> Not PII

The unique id of the Channel this message was sent to.

type
string Not PII

Message type. Can be text or media currently, representing if it's text message or media message accordingly.

url
url Not PII

An absolute URL for this message.

was_edited
boolean Not PII

true if the message has been updated since it was created. false if it has not changed.

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

Order
Optional
get enum:order_type Not PII

Specifies sorting order for messages list, possible values are: asc or desc. If no value is specified, then asc is used as the default.

Loading Code Sample...
      
      
      
      

      Send a Message to a Channel

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

      Parameters

      Attributes
      Optional
      post string PII MTL: 120 DAYS

      An string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that this will always be null for resources returned via LIST GET operations, but will be present for single GET operations.

      Body
      Optional
      post string PII MTL: 120 DAYS

      A string message to send to this channel. You can also send structured data by serializing it into a string. May be empty string or null, will be set as empty string as a result in this cases.

      DateCreated
      Optional
      post date_time<iso8601> Not PII

      The ISO8601 time specifying the datetime the Message should be set as being created. Will be set to the current time by the Chat service if not specified. Note that this should only be used in cases where a Chat's history is being recreated from a backup/separate source.

      DateUpdated
      Optional
      post date_time<iso8601> Not PII

      The ISO8601 time specifying the datetime the Message should be set as having been last updated. Will be set to the null by the Chat service if not specified. Note that this should only be used in cases where a Chat's history is being recreated from a backup/separate source and where a Message was previously updated.

      From
      Optional
      post string PII MTL: 120 DAYS

      The identity of the message's author. Defaults to system.

      LastUpdatedBy
      Optional
      post string PII MTL: 120 DAYS

      Specify the Identity of the User that last updated the Message (if relevant)

      MediaSid
      Optional
      post sid<ME> Not PII

      The Media Sid to be attached to this Message.

      Loading Code Sample...
          
          
          
          

          Retrieve a Message from a Channel

          GET /Services/{Service SID}/Channels/{Channel SID}/Messages/{Message SID}
          
          Loading Code Sample...
              
              
              
              

              Update an existing Message

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

              Parameters

              Attributes
              Optional
              post string PII MTL: 120 DAYS

              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 this will always be null for resources returned via LIST GET operations, but will be present for single GET operations.

              Body
              Optional
              post string PII MTL: 120 DAYS

              The message body string. You can also send structured data by serializing it into a string. May be updated to empty string or null, will be set as empty string as a result in this cases.

              DateCreated
              Optional
              post date_time<iso8601> Not PII

              The ISO8601 time specifying the datetime the Message should be set as being created.

              DateUpdated
              Optional
              post date_time<iso8601> Not PII

              The ISO8601 time specifying the datetime the Message should be set as having been last updated.

              From
              Optional
              post string PII MTL: 120 DAYS

              The identity of the message's author.

              LastUpdatedBy
              Optional
              post string PII MTL: 120 DAYS

              Specify the Identity of the User that last updated the Message (if relevant)

              Loading Code Sample...
                  
                  
                  
                  

                  Delete a Message from a Channel

                  DELETE /Services/{Service SID}/Channels/{Channel SID}/Messages/{Message SID}
                  
                  Loading Code Sample...
                      
                      
                      
                      

                      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.

                      Loading Code Sample...