0.31.0 (latest) 0.30.0 0.29.0 0.28.0 0.27.0 0.23.0 0.20.0 0.19.0 0.18.0 0.17.1 0.16.1 0.15.0 0.14.0 0.13.1 0.12.1 0.11.2 0.10.0 0.9.0 0.8.1 0.7.2 0.6.1 0.5.0 0.4.0 0.3.0 0.2.0 0.1.4 Reference documentation and code samples for the Google Apps Chat V1 Client class CreateMessageRequest.

Creates a message.

Generated from protobuf message `google.chat.v1.CreateMessageRequest`

## Namespace

Google \\ Apps \\ Chat \\ V1

## Methods

### __construct

Constructor.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `data` | `array` Optional. Data for populating the Message object. |
| `↳ parent` | `string` Required. The resource name of the space in which to create a message. Format: `spaces/{space}` |
| `↳ message` | `Message` Required. Message body. |
| `↳ thread_key` | `string` Optional. Deprecated: Use [thread.thread_key](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.Thread.md.txt#_Google_Apps_Chat_V1_Thread__getThreadKey__) instead. ID for the thread. Supports up to 4000 characters. To start or add to a thread, create a message and specify a `threadKey` or the [thread.name](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.Thread.md.txt#_Google_Apps_Chat_V1_Thread__getName__). For example usage, see [Start or reply to a message thread](https://developers.google.com/workspace/chat/create-messages#create-message-thread). |
| `↳ request_id` | `string` Optional. A unique ID for this request. A random UUID is recommended. Specifying a request ID makes the request idempotent, which ensures that multiple identical requests with the same request ID result in only a single message being created. Subsequent requests with the same request ID return the existing message and do not update the message, even if the requested details differ from the current state. To use this field effectively: - Ensure that subsequent requests are identical and use the same authentication credentials as the original request. - If a message was already created with the provided request ID, the request returns that message. Note that the returned message might not be fully populated; the API echoes the message in your request with the system-assigned resource names populated. To retrieve the latest metadata for the message, call `GetMessage`. - Reusing an existing request ID with a different authenticated user results in an error. |
| `↳ message_reply_option` | `int` Optional. Specifies whether a message starts a thread or replies to one. Only supported in named spaces. When [responding to user interactions](https://developers.google.com/workspace/chat/receive-respond-interactions), this field is ignored. For interactions within a thread, the reply is created in the same thread. Otherwise, the reply is created as a new thread. |
| `↳ message_id` | `string` Optional. A custom ID for a message. Lets Chat apps get, update, or delete a message without needing to store the system-assigned ID in the message's resource name (represented in the message `name` field). The value for this field must meet the following requirements: \* \* Begins with `client-`. For example, `client-custom-name` is a valid custom ID, but `custom-name` is not. \* \* Contains up to 63 characters and only lowercase letters, numbers, and hyphens. \* \* Is unique within a space. A Chat app can't use the same custom ID for different messages. For details, see [Name a message](https://developers.google.com/workspace/chat/create-messages#name_a_created_message). |
| `↳ create_message_notification_options` | `CreateMessageNotificationOptions` Optional. Controls the notification behavior when the message is posted. To learn more, see [Force notifications or send silent messages](https://developer.google.com/workspace/chat/create-messages#force-notify-silent). |

### getParent

Required. The resource name of the space in which to create a message.

Format: `spaces/{space}`

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setParent

Required. The resource name of the space in which to create a message.

Format: `spaces/{space}`

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getMessage

Required. Message body.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `Message|null` |   |

### hasMessage

### clearMessage

### setMessage

Required. Message body.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `Message` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getThreadKey

Optional. Deprecated: Use
[thread.thread_key](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.Thread.md.txt#_Google_Apps_Chat_V1_Thread__getThreadKey__) instead. ID for the
thread. Supports up to 4000 characters. To start or add to a thread, create
a message and specify a `threadKey` or the
[thread.name](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.Thread.md.txt#_Google_Apps_Chat_V1_Thread__getName__). For example usage, see [Start or
reply to a message
thread](https://developers.google.com/workspace/chat/create-messages#create-message-thread).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setThreadKey

Optional. Deprecated: Use
[thread.thread_key](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.Thread.md.txt#_Google_Apps_Chat_V1_Thread__getThreadKey__) instead. ID for the
thread. Supports up to 4000 characters. To start or add to a thread, create
a message and specify a `threadKey` or the
[thread.name](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.Thread.md.txt#_Google_Apps_Chat_V1_Thread__getName__). For example usage, see [Start or
reply to a message
thread](https://developers.google.com/workspace/chat/create-messages#create-message-thread).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getRequestId

Optional. A unique ID for this request. A random UUID is recommended.

Specifying a request ID makes the request idempotent, which ensures that
multiple identical requests with the same request ID result in only a
single message being created. Subsequent requests with the same request
ID return the existing message and do not update the message, even if the
requested details differ from the current state.
To use this field effectively:

- Ensure that subsequent requests are identical and use the same authentication credentials as the original request.
- If a message was already created with the provided request ID, the request returns that message. Note that the returned message might not be fully populated; the API echoes the message in your request with the system-assigned resource names populated. To retrieve the latest metadata for the message, call `GetMessage`.
- Reusing an existing request ID with a different authenticated user results in an error.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setRequestId

Optional. A unique ID for this request. A random UUID is recommended.

Specifying a request ID makes the request idempotent, which ensures that
multiple identical requests with the same request ID result in only a
single message being created. Subsequent requests with the same request
ID return the existing message and do not update the message, even if the
requested details differ from the current state.
To use this field effectively:

- Ensure that subsequent requests are identical and use the same authentication credentials as the original request.
- If a message was already created with the provided request ID, the request returns that message. Note that the returned message might not be fully populated; the API echoes the message in your request with the system-assigned resource names populated. To retrieve the latest metadata for the message, call `GetMessage`.
- Reusing an existing request ID with a different authenticated user results in an error.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getMessageReplyOption

Optional. Specifies whether a message starts a thread or replies to one.

Only supported in named spaces.
When [responding to user
interactions](https://developers.google.com/workspace/chat/receive-respond-interactions),
this field is ignored. For interactions within a thread, the reply is
created in the same thread. Otherwise, the reply is created as a new
thread.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `int` | Enum of type [MessageReplyOption](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.CreateMessageRequest.MessageReplyOption.md.txt). |

### setMessageReplyOption

Optional. Specifies whether a message starts a thread or replies to one.

Only supported in named spaces.
When [responding to user
interactions](https://developers.google.com/workspace/chat/receive-respond-interactions),
this field is ignored. For interactions within a thread, the reply is
created in the same thread. Otherwise, the reply is created as a new
thread.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `int` Enum of type [MessageReplyOption](https://docs.cloud.google.com/php/docs/reference/apps-chat/latest/Chat.V1.CreateMessageRequest.MessageReplyOption.md.txt). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getMessageId

Optional. A custom ID for a message. Lets Chat apps get, update, or delete
a message without needing to store the system-assigned ID in the message's
resource name (represented in the message `name` field).

The value for this field must meet the following requirements:

- Begins with `client-`. For example, `client-custom-name` is a valid custom ID, but `custom-name` is not.
- Contains up to 63 characters and only lowercase letters, numbers, and hyphens.
- Is unique within a space. A Chat app can't use the same custom ID for different messages. For details, see [Name a
  message](https://developers.google.com/workspace/chat/create-messages#name_a_created_message).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `string` |   |

### setMessageId

Optional. A custom ID for a message. Lets Chat apps get, update, or delete
a message without needing to store the system-assigned ID in the message's
resource name (represented in the message `name` field).

The value for this field must meet the following requirements:

- Begins with `client-`. For example, `client-custom-name` is a valid custom ID, but `custom-name` is not.
- Contains up to 63 characters and only lowercase letters, numbers, and hyphens.
- Is unique within a space. A Chat app can't use the same custom ID for different messages. For details, see [Name a
  message](https://developers.google.com/workspace/chat/create-messages#name_a_created_message).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `string` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### getCreateMessageNotificationOptions

Optional. Controls the notification behavior when the message is posted.

To learn more, see [Force notifications or send silent
messages](https://developer.google.com/workspace/chat/create-messages#force-notify-silent).

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `CreateMessageNotificationOptions|null` |   |

### hasCreateMessageNotificationOptions

### clearCreateMessageNotificationOptions

### setCreateMessageNotificationOptions

Optional. Controls the notification behavior when the message is posted.

To learn more, see [Force notifications or send silent
messages](https://developer.google.com/workspace/chat/create-messages#force-notify-silent).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `var` | `CreateMessageNotificationOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `$this` |   |

### static::build

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `parent` | `string` Required. The resource name of the space in which to create a message. Format: `spaces/{space}` Please see ChatServiceClient::spaceName() for help formatting this field. |
| `message` | `Message` Required. Message body. |
| `messageId` | `string` Optional. A custom ID for a message. Lets Chat apps get, update, or delete a message without needing to store the system-assigned ID in the message's resource name (represented in the message `name` field). The value for this field must meet the following requirements: - - Begins with `client-`. For example, `client-custom-name` is a valid custom ID, but `custom-name` is not. - - Contains up to 63 characters and only lowercase letters, numbers, and hyphens. - - Is unique within a space. A Chat app can't use the same custom ID for different messages. For details, see [Name a message](https://developers.google.com/workspace/chat/create-messages#name_a_created_message). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `CreateMessageRequest` |   |