- [JSON representation](https://docs.cloud.google.com/gemini/data-agents/reference/rest/Shared.Types/Message.md.txt#SCHEMA_REPRESENTATION)

Message is one unit of communication between client and server. It is associated with a context and optionally a task. Since the server is responsible for the context definition, it must always provide a contextId in its messages. The client can optionally provide the contextId if it knows the context to associate the message to. Similarly for taskId, except the server decides if a task is created and whether to include the taskId.

| JSON representation |
|---|
| ``` { "messageId": string, "contextId": string, "taskId": string, "role": enum (`Role`), "content": [ { object (`Part`) } ], "metadata": { object }, "extensions": [ string ] } ``` |

| Fields ||
|---|---|
| `messageId` | `string` The unique identifier (e.g. UUID)of the message. This is required and created by the message creator. |
| `contextId` | `string` The context id of the message. This is optional and if set, the message will be associated with the given context. |
| `taskId` | `string` The task id of the message. This is optional and if set, the message will be associated with the given task. |
| `role` | ``enum (`Role`)`` A role for the message. |
| `content[]` | ``object (`Part`)`` protolint:disable REPEATED_FIELD_NAMES_PLURALIZED Content is the container of the message content. |
| `metadata` | ``object (`Struct` format)`` protolint:enable REPEATED_FIELD_NAMES_PLURALIZED Any optional metadata to provide along with the message. |
| `extensions[]` | `string` The URIs of extensions that are present or contributed to this Message. |