# Service enfonica.messaging.v1.Messages

## Methods

| CreateMessage |
| -- |
| <span class="e-code">rpc CreateMessage(<span class="e-code">[CreateMessageRequest](#createmessagerequest)</span>) returns (<span class="e-code">[Message](#resource-message)</span>)</span><br/><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. |

| GetMessage |
| -- |
| <span class="e-code">rpc GetMessage(<span class="e-code">[GetMessageRequest](#getmessagerequest)</span>) returns (<span class="e-code">[Message](#resource-message)</span>)</span><br/><br/>Retrieves a Message identified by the supplied resource name.<br/><br/>The caller must have `messaging.messages.get` permission on the project. |

| ListMessages |
| -- |
| <span class="e-code">rpc ListMessages(<span class="e-code">[ListMessagesRequest](#listmessagesrequest)</span>) returns (<span class="e-code">[ListMessagesResponse](#listmessagesresponse)</span>)</span><br/><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. |

## Resource: Message

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

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">status_update_url</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">reply_url</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">validity_period_seconds</span> | <span class="e-code">int32</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">smart_encoding</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<<span class="e-code">string</span>, <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">[MessageClassification](#messagemessageclassification)</span><br/>The type of message that this is, such as transactional or marketing.
<span class="e-code">unsubscribe_content_behavior</span> | <span class="e-code">[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">[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">error_code</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">error_message</span> | <span class="e-code">string</span><br/>Output only. The human readable message associated with the error.
<span class="e-code">segment_count</span> | <span class="e-code">int32</span><br/>Output only. The number of segments that make up the body.
<span class="e-code">price</span> | <span class="e-code"><a href="https://github.com/googleapis/googleapis/blob/master/google/type/money.proto" target="_blank">google.type.Money</a></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">[Status](#messagestatus)</span><br/>Output only. The current status of the message. 
<span class="e-code">create_identity</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">create_time</span> | <span class="e-code"><a href="https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#timestamp" target="_blank">google.protobuf.Timestamp</a></span><br/>Output only. The creation time of the message.
<span class="e-code">send_time</span> | <span class="e-code"><a href="https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#timestamp" target="_blank">google.protobuf.Timestamp</a></span><br/>Output only. The time the message was sent. Only set for outgoing message.
<span class="e-code">deliver_time</span> | <span class="e-code"><a href="https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#timestamp" target="_blank">google.protobuf.Timestamp</a></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">[MessageEncoding](#messagemessageencoding)</span><br/>Output only. The encoding used for the body.

## 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.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.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.

## 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.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:" ```

## CreateMessageRequest

Request to create a new message.

Fields | &nbsp;
--|--
<span class="e-code">parent</span> | <span class="e-code">string</span><br/>Required. The resource name of the parent project to create the message under. Must be of the form `projects/*`.
<span class="e-code">message</span> | <span class="e-code">[Message](#resource-message)</span><br/>Required. The message resource to be created.

## GetMessageRequest

The GetMessage request message.

Fields | &nbsp;
--|--
<span class="e-code">name</span> | <span class="e-code">string</span><br/>Required. The resource name of the Message to retrieve. Must be of the form `projects/*/messages/*`.

## ListMessagesRequest

The ListMessages request message.

Fields | &nbsp;
--|--
<span class="e-code">parent</span> | <span class="e-code">string</span><br/>Required. The resource name of the parent of which to list messages. Must be of the form `projects/*`.
<span class="e-code">page_size</span> | <span class="e-code">int32</span><br/>The maximum number of Messages to return in the response. Default value is 10 and maximum value is 100.
<span class="e-code">page_token</span> | <span class="e-code">string</span><br/>A pagination token returned from a previous call to `ListMessages` that indicates where this listing should continue from.
<span class="e-code">filter</span> | <span class="e-code">string</span><br/>Filter string to specify which results should be returned.<br/><br/>The following fields can be filtered: - `createTime` - `to` - `from` - `status` - `direction` - `encoding`<br/><br/>For example: createTime >= '2021-01-01T06:00:00.0Z' AND createTime < '2021-02-01' AND status = DELIVERED OR status = UNDELIVERED AND to = '+61*' OR from = '+61*'<br/><br/>Note that OR has higher precendence than AND.

## ListMessagesResponse

The ListMessages response message.

Fields | &nbsp;
--|--
<span class="e-code">messages[]</span> | <span class="e-code">[Message](#resource-message)</span><br/>A possibly paginated list of Messages that are direct descendants of the specified parent resource.
<span class="e-code">next_page_token</span> | <span class="e-code">string</span><br/>If this is set, it indicates there are additional results and contains the token to retrieve the next page of results. To use this, pass it in the `page_token` field when calling `ListMessages`.

