# REST Resource: projects.messages

## Resource: Message

The Message resource. This represents a message, such as an SMS.

<div class="highlight"><span class="filename">JSON representation</span><pre><code><span class="p">{</span>
  <span class="s2">&quot;name&quot;</span><span class="p">: </span><span class="kd">string</span><span class="p">,</span>
  <span class="s2">&quot;to&quot;</span><span class="p">: </span><span class="kd">string</span><span class="p">,</span>
  <span class="s2">&quot;from&quot;</span><span class="p">: </span><span class="kd">string</span><span class="p">,</span>
  <span class="s2">&quot;body&quot;</span><span class="p">: </span><span class="kd">string</span><span class="p">,</span>
  <span class="s2">&quot;statusUpdateUrl&quot;</span><span class="p">: </span><span class="kd">string</span><span class="p">,</span>
  <span class="s2">&quot;replyUrl&quot;</span><span class="p">: </span><span class="kd">string</span><span class="p">,</span>
  <span class="s2">&quot;validityPeriodSeconds&quot;</span><span class="p">: </span><span class="kd">number (</span><a href="https://developers.google.com/protocol-buffers/docs/proto3#json" target="_blank"><strong><span class="kd">int32</span></strong></a><span class="kd">)</span><span class="p">,</span>
  <span class="s2">&quot;smartEncoding&quot;</span><span class="p">: </span><span class="kd">boolean</span><span class="p">,</span>
  <span class="s2">&quot;labels&quot;</span><span class="p">: </span><span class="p">{</span>
    <span class="kd">string</span><span class="p">: </span><span class="kd">string</span><span class="p">,</span>
    <span class="p">...</span>
  <span class="p">}</span><span class="p">,</span>
  <span class="s2">&quot;classification&quot;</span><span class="p">: </span><span class="kd">enum (</span><a href="#messagemessageclassification"><strong><span class="kd">MessageClassification</span></strong></a><span class="kd">)</span><span class="p">,</span>
  <span class="s2">&quot;unsubscribeContentBehavior&quot;</span><span class="p">: </span><span class="kd">enum (</span><a href="#messageunsubscribecontentbehavior"><strong><span class="kd">UnsubscribeContentBehavior</span></strong></a><span class="kd">)</span><span class="p">,</span>
  <span class="s2">&quot;direction&quot;</span><span class="p">: </span><span class="kd">enum (</span><a href="#messagedirection"><strong><span class="kd">Direction</span></strong></a><span class="kd">)</span><span class="p">,</span>
  <span class="s2">&quot;errorCode&quot;</span><span class="p">: </span><span class="kd">string</span><span class="p">,</span>
  <span class="s2">&quot;errorMessage&quot;</span><span class="p">: </span><span class="kd">string</span><span class="p">,</span>
  <span class="s2">&quot;segmentCount&quot;</span><span class="p">: </span><span class="kd">number (</span><a href="https://developers.google.com/protocol-buffers/docs/proto3#json" target="_blank"><strong><span class="kd">int32</span></strong></a><span class="kd">)</span><span class="p">,</span>
  <span class="s2">&quot;price&quot;</span><span class="p">: </span><span class="p">{</span>
    <span class="kd">object (</span><a href="https://github.com/googleapis/googleapis/blob/master/google/type/money.proto" target="_blank"><strong><span class="kd">google.type.Money</span></strong></a><span class="kd">)</span>
  <span class="p">}</span><span class="p">,</span>
  <span class="s2">&quot;status&quot;</span><span class="p">: </span><span class="kd">enum (</span><a href="#messagestatus"><strong><span class="kd">Status</span></strong></a><span class="kd">)</span><span class="p">,</span>
  <span class="s2">&quot;createIdentity&quot;</span><span class="p">: </span><span class="kd">string</span><span class="p">,</span>
  <span class="s2">&quot;createTime&quot;</span><span class="p">: </span><span class="kd">string (</span><a href="https://developers.google.com/protocol-buffers/docs/proto3#json" target="_blank"><strong><span class="kd">Timestamp</span></strong></a><span class="kd">)</span><span class="p">,</span>
  <span class="s2">&quot;sendTime&quot;</span><span class="p">: </span><span class="kd">string (</span><a href="https://developers.google.com/protocol-buffers/docs/proto3#json" target="_blank"><strong><span class="kd">Timestamp</span></strong></a><span class="kd">)</span><span class="p">,</span>
  <span class="s2">&quot;deliverTime&quot;</span><span class="p">: </span><span class="kd">string (</span><a href="https://developers.google.com/protocol-buffers/docs/proto3#json" target="_blank"><strong><span class="kd">Timestamp</span></strong></a><span class="kd">)</span><span class="p">,</span>
  <span class="s2">&quot;encoding&quot;</span><span class="p">: </span><span class="kd">enum (</span><a href="#messagemessageencoding"><strong><span class="kd">MessageEncoding</span></strong></a><span class="kd">)</span>
<span class="p">}</span></code></pre></div>

Fields | &nbsp;
--|--
<span class="e-code">name</span> | <span class="e-code">string</span><br/>Resource name of the message. It must match the pattern `projects/*/messages/*`
<span class="e-code">to</span> | <span class="e-code">string</span><br/>Required. The recipient phone number in +E164. 
<span class="e-code">from</span> | <span class="e-code">string</span><br/>Required. The phone number in +E164 or alphanumeric sender ID that initiated the message. 
<span class="e-code">body</span> | <span class="e-code">string</span><br/>The text of the message. Maximum of 1530 characters for messages encoding using GSM 7-bit encoding and 670 characters for messages encoding using UCS2 encoding. If a longer body is specified, it will be truncated to the maximum length.
<span class="e-code">statusUpdateUrl</span> | <span class="e-code">string</span><br/>The URL where [status updates webhooks](https://enfonica.com/docs/cloud-sms/webhooks/#message-status-update) should be sent. 
<span class="e-code">replyUrl</span> | <span class="e-code">string</span><br/>The URL where replies, in the form of [incoming message webhooks](https://enfonica.com/docs/cloud-sms/webhooks/#incoming-message) should be sent. This overrides any message handler URLs defined against the phone number receiving the reply. 
<span class="e-code">validityPeriodSeconds</span> | <span class="e-code">number (<a href="https://developers.google.com/protocol-buffers/docs/proto3#json" target="_blank">int32</a> format)</span><br/>How long the message can stay in Enfonica's outgoing message queue, in seconds. Once the message has been accepted by carriers, we cannot guarantee the message will not be queued after this period. 
<span class="e-code">smartEncoding</span> | <span class="e-code">boolean</span><br/>Whether to automatically reply certain Unicode characters with similar GSM-7 characters.
<span class="e-code">labels</span> | <span class="e-code">map (key: <span class="e-code">string</span>, value: <span class="e-code">string</span>)</span><br/>You can store any arbitrary data against labels. The maximum key size is 100. The maximum value size is 1000. The maximum number of keys is 50.
<span class="e-code">classification</span> | <span class="e-code">enum ([MessageClassification](#messagemessageclassification))</span><br/>The type of message that this is, such as transactional or marketing.
<span class="e-code">unsubscribeContentBehavior</span> | <span class="e-code">enum ([UnsubscribeContentBehavior](#messageunsubscribecontentbehavior))</span><br/>Whether the `body` should be modified to include content indicatig how to unsubscribe.
<span class="e-code">direction</span> | <span class="e-code">enum ([Direction](#messagedirection))</span><br/>Output only. The direction of the message. Can be `outgoing` for messages that are sent or `incoming` for messages that are received.
<span class="e-code">errorCode</span> | <span class="e-code">string</span><br/>Output only. If the outgoing message failed to be delivered, the reason why.
<span class="e-code">errorMessage</span> | <span class="e-code">string</span><br/>Output only. The human readable message associated with the error.
<span class="e-code">segmentCount</span> | <span class="e-code">number (<a href="https://developers.google.com/protocol-buffers/docs/proto3#json" target="_blank">int32</a> format)</span><br/>Output only. The number of segments that make up the body.
<span class="e-code">price</span> | <span class="e-code">object (<a href="https://github.com/googleapis/googleapis/blob/master/google/type/money.proto" target="_blank">google.type.Money</a> format)</span><br/>Output only. The price of this message. This may not be populated until a certain stage in the message lifecycle.
<span class="e-code">status</span> | <span class="e-code">enum ([Status](#messagestatus))</span><br/>Output only. The current status of the message. 
<span class="e-code">createIdentity</span> | <span class="e-code">string</span><br/>Output only. The identity that created the message.  This may be your user or service account, or identities used internally by Enfonica products.
<span class="e-code">createTime</span> | <span class="e-code">string (<a href="https://developers.google.com/protocol-buffers/docs/proto3#json" target="_blank">Timestamp</a> format)</span><br/>Output only. The creation time of the message.
<span class="e-code">sendTime</span> | <span class="e-code">string (<a href="https://developers.google.com/protocol-buffers/docs/proto3#json" target="_blank">Timestamp</a> format)</span><br/>Output only. The time the message was sent. Only set for outgoing message.
<span class="e-code">deliverTime</span> | <span class="e-code">string (<a href="https://developers.google.com/protocol-buffers/docs/proto3#json" target="_blank">Timestamp</a> format)</span><br/>Output only. The time when delivery was confirmed for the message. Only set for outgoing message.
<span class="e-code">encoding</span> | <span class="e-code">enum ([MessageEncoding](#messagemessageencoding))</span><br/>Output only. The encoding used for the body.

## Message.MessageClassification

The type of message that this is.

Enums | &nbsp;
--|--
<span class="e-code">MESSAGE_CLASSIFICATION_UNSPECIFIED</span> | Unspecified.
<span class="e-code">UNCLASSIFIED</span> | The message is not classified. This message will be checked against unsubscribers before being sent.
<span class="e-code">TRANSACTIONAL</span> | A transactional message. This message will not be checked against unsubscribers before being sent.
<span class="e-code">MARKETING</span> | A marketing message. This message will be checked against unsubscribers before being sent.

## Message.UnsubscribeContentBehavior

Behaviour with regards to unsubscribe content within the message.

Enums | &nbsp;
--|--
<span class="e-code">UNSUBSCRIBE_CONTENT_BEHAVIOR_UNSPECIFIED</span> | Unspecified.
<span class="e-code">NONE</span> | Do not insert any unsubscribe content within the message.
<span class="e-code">APPEND_URL</span> | Append a short URL to the end of the message body which allows the user to unsubscribe. This will only append the URL, and optionally a whitespace character before the URL.<br/><br/>Example `body` to use with this paramater:<br/><br/>``` "This is a marketing message. To unsubscribe:" ```

## Message.Direction

The direction of a message.

Enums | &nbsp;
--|--
<span class="e-code">DIRECTION_UNSPECIFIED</span> | Unspecified direction.
<span class="e-code">OUTGOING</span> | An outgoing message.
<span class="e-code">INCOMING</span> | An incoming message

## Message.Status

The status of a message. 

Enums | &nbsp;
--|--
<span class="e-code">STATUS_UNSPECIFIED</span> | Unspecified status.
<span class="e-code">QUEUED</span> | The message has been queued for sending.
<span class="e-code">SENDING</span> | The message is currently being dispatched to an upstream carrier.
<span class="e-code">SENT</span> | The upstream carrier has accepted the message.
<span class="e-code">FAILED</span> | The message failed to be sent within the Enfonica network. For upstream failures, the status will be `UNDELIVERED`.
<span class="e-code">DELIVERED</span> | The upstream has confirmed message delivery, where available, to the destination handset.
<span class="e-code">UNDELIVERED</span> | The upstream returned a delivery receipt indicating the message was not delivered.
<span class="e-code">RECEIVED</span> | The message is an incoming message that has been received.

## Message.MessageEncoding

The encoding of a message body.

Enums | &nbsp;
--|--
<span class="e-code">MESSAGE_ENCODING_UNSPECIFIED</span> | Unknown message encoding.
<span class="e-code">GSM7</span> | GSM 7-bit encoding.
<span class="e-code">UCS2</span> | UCS-2 encoding.

## Methods

Methods | &nbsp;
--|--
<span class="e-code">[create](/docs/cloud-sms/api-reference/rest/v1/projects.messages/create/)</span> | <span class="e-code">POST /v1/{parent}/messages</span><br/>Creates a Message and queues it for sending. Returns the created message.<br/><br/>The caller must have `messaging.messages.create` permission on the project.
<span class="e-code">[get](/docs/cloud-sms/api-reference/rest/v1/projects.messages/get/)</span> | <span class="e-code">GET /v1/{name}</span><br/>Retrieves a Message identified by the supplied resource name.<br/><br/>The caller must have `messaging.messages.get` permission on the project.
<span class="e-code">[list](/docs/cloud-sms/api-reference/rest/v1/projects.messages/list/)</span> | <span class="e-code">GET /v1/{parent}/messages</span><br/>Lists the Messages of the specified project. List returns Messages sorted by create_time descending.<br/><br/>The caller must have `messaging.messages.list` permission on the project.

