Method: spaces.messages.create
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Google Chat 스페이스에 메시지를 만듭니다. 예를 보려면 메시지 보내기를 참고하세요.
다음 유형의 인증을 지원합니다.
- 승인 범위가 있는 앱 인증:
https://www.googleapis.com/auth/chat.bot
- 다음 승인 범위 중 하나를 사용하여 사용자 인증:
https://www.googleapis.com/auth/chat.messages.create
https://www.googleapis.com/auth/chat.messages
https://www.googleapis.com/auth/chat.import
(가져오기 모드 스페이스만 해당)
Chat은 요청에 사용하는 인증 유형에 따라 메일 발신자를 다르게 지정합니다.
다음 이미지는 앱 인증을 사용할 때 Chat에서 메시지에 속성을 부여하는 방법을 보여줍니다. Chat에서는 Chat 앱을 메시지 발신자로 표시합니다. 메시지 콘텐츠에는 텍스트 (text
), 카드 (cardsV2
), 액세서리 위젯 (accessoryWidgets
)이 포함될 수 있습니다.

다음 이미지는 사용자 인증을 사용할 때 Chat에서 메시지에 속성을 부여하는 방법을 보여줍니다. Chat은 사용자를 메시지 발신자로 표시하고 Chat 앱의 이름을 표시하여 메시지에 Chat 앱의 속성을 부여합니다. 메시지 콘텐츠에는 텍스트 (text
)만 포함할 수 있습니다.

메일 내용을 포함한 최대 메일 크기는 32,000바이트입니다.
Webhook 요청의 경우 응답에 전체 메시지가 포함되지 않습니다. 응답은 요청에 포함된 정보 외에 name
및 thread.name
필드만 채웁니다.
HTTP 요청
POST https://chat.googleapis.com/v1/{parent=spaces/*}/messages
URL은 gRPC 트랜스코딩 문법을 사용합니다.
경로 매개변수
매개변수 |
parent |
string
필수 항목입니다. 메시지를 만들 스페이스의 리소스 이름입니다. 형식: spaces/{space}
|
쿼리 매개변수
매개변수 |
threadKey (deprecated) |
string
선택사항입니다. 지원 중단됨: 대신 thread.thread_key 를 사용하세요. 대화목록의 ID입니다. 최대 4,000자(영문 기준)를 지원합니다. 대화목록을 시작하거나 대화목록에 추가하려면 메시지를 만들고 threadKey 또는 thread.name 를 지정합니다. 사용 예는 메시지 대화목록 시작 또는 답장을 참고하세요.
|
requestId |
string
선택사항입니다. 이 메시지의 고유한 요청 ID입니다. 기존 요청 ID를 지정하면 새 메시지를 만드는 대신 해당 ID로 생성된 메시지가 반환됩니다.
|
messageReplyOption |
enum (MessageReplyOption )
선택사항입니다. 메시지가 대화목록을 시작하는지 또는 대화목록에 답장하는지를 지정합니다. 이름이 지정된 스페이스에서만 지원됩니다. 사용자 상호작용에 응답할 때는 이 필드가 무시됩니다. 대화목록 내 상호작용의 경우 답글이 동일한 대화목록에 생성됩니다. 그렇지 않으면 답장이 새 대화목록으로 생성됩니다.
|
messageId |
string
선택사항입니다. 메시지의 맞춤 ID입니다. Chat 앱이 메시지의 리소스 이름 (메시지 name 필드에 표시됨)에 시스템 할당 ID를 저장하지 않고도 메시지를 가져오거나 업데이트하거나 삭제할 수 있도록 합니다. 이 필드의 값은 다음 요구사항을 충족해야 합니다.
client- 로 시작합니다. 예를 들어 client-custom-name 는 유효한 맞춤 ID이지만 custom-name 는 그렇지 않습니다.
- 최대 63자(영문 기준)이며 소문자, 숫자, 하이픈만 포함할 수 있습니다.
- 스페이스 내에서 고유합니다. 채팅 앱은 여러 메시지에 동일한 맞춤 ID를 사용할 수 없습니다.
자세한 내용은 메시지 이름 지정하기를 참고하세요.
|
요청 본문
요청 본문에 Message
의 인스턴스가 포함됩니다.
응답 본문
성공한 경우 응답 본문에 새로 생성된 Message
의 인스턴스가 포함됩니다.
승인 범위
다음 OAuth 범위 중 하나가 필요합니다.
https://www.googleapis.com/auth/chat.bot
https://www.googleapis.com/auth/chat.import
https://www.googleapis.com/auth/chat.messages
https://www.googleapis.com/auth/chat.messages.create
자세한 내용은 승인 가이드를 참고하세요.
MessageReplyOption
메시지에 답장하는 방법을 지정합니다. 향후 더 많은 주가 추가될 수 있습니다.
열거형 |
MESSAGE_REPLY_OPTION_UNSPECIFIED |
기본값입니다. 새 대화목록을 시작합니다. 이 옵션을 사용하면 포함된 thread ID 또는 threadKey 가 무시됩니다. |
REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD |
thread ID 또는 threadKey 로 지정된 대화목록에 대한 답장으로 메시지를 만듭니다. 실패하면 메시지가 대신 새 스레드를 시작합니다. |
REPLY_MESSAGE_OR_FAIL |
thread ID 또는 threadKey 로 지정된 대화목록에 대한 답장으로 메시지를 만듭니다. 새 threadKey 가 사용되면 새 스레드가 생성됩니다. 메시지 생성이 실패하면 대신 NOT_FOUND 오류가 반환됩니다. |
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-25(UTC)
[null,null,["최종 업데이트: 2025-07-25(UTC)"],[[["\u003cp\u003eCreates a message in a Google Chat space, attributing it to the Chat app or user based on authentication.\u003c/p\u003e\n"],["\u003cp\u003eSupports sending text, cards, and widgets using app authentication, while user authentication only allows text.\u003c/p\u003e\n"],["\u003cp\u003eOffers different message reply options for starting new threads or replying within existing ones.\u003c/p\u003e\n"],["\u003cp\u003eRequires specific authorization scopes for the request, such as \u003ccode\u003echat.bot\u003c/code\u003e or \u003ccode\u003echat.messages\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eProvides a way to name a message with a custom ID for easy retrieval and management within a space.\u003c/p\u003e\n"]]],["This document outlines the process for creating messages in Google Chat spaces via the `create()` method, using either user or app authentication. Messages can include text, cards, and widgets, with a maximum size of 32,000 bytes. The process involves a POST request to a specified URL with path parameters for the space and query parameters like `threadKey`, `requestId`, `messageReplyOption` and `messageId`. The request body defines the message content, and the successful response returns the new message details. It also specifies the required OAuth scopes.\n"],null,["# Method: spaces.messages.create\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [MessageReplyOption](#MessageReplyOption)\n- [Try it!](#try-it)\n\nCreates a message in a Google Chat space. For an example, see [Send a message](https://developers.google.com/workspace/chat/create-messages).\n\nSupports the following types of [authentication](https://developers.google.com/workspace/chat/authenticate-authorize):\n\n- [App authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-app) with the authorization scope:\n - `https://www.googleapis.com/auth/chat.bot`\n- [User authentication](https://developers.google.com/workspace/chat/authenticate-authorize-chat-user) with one of the following authorization scopes:\n - `https://www.googleapis.com/auth/chat.messages.create`\n - `https://www.googleapis.com/auth/chat.messages`\n - `https://www.googleapis.com/auth/chat.import` (import mode spaces only)\n\nChat attributes the message sender differently depending on the type of authentication that you use in your request.\n\nThe following image shows how Chat attributes a message when you use app authentication. Chat displays the Chat app as the message sender. The content of the message can contain text (`text`), cards (`cardsV2`), and accessory widgets (`accessoryWidgets`).\n\nThe following image shows how Chat attributes a message when you use user authentication. Chat displays the user as the message sender and attributes the Chat app to the message by displaying its name. The content of message can only contain text (`text`).\n\nThe maximum message size, including the message contents, is 32,000 bytes.\n\nFor [webhook](https://developers.google.com/workspace/chat/quickstart/webhooks) requests, the response doesn't contain the full message. The response only populates the `name` and `thread.name` fields in addition to the information that was in the request.\n\n### HTTP request\n\n`POST https://chat.googleapis.com/v1/{parent=spaces/*}/messages`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|----------------------------------------------------------------------------------------------------------|\n| `parent` | `string` Required. The resource name of the space in which to create a message. Format: `spaces/{space}` |\n\n### Query parameters\n\n| Parameters ||\n|------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `threadKey` **(deprecated)** | `string` Optional. Deprecated: Use [thread.thread_key](/workspace/chat/api/reference/rest/v1/spaces.messages#Message.Thread.FIELDS.thread_key) 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](/workspace/chat/api/reference/rest/v1/spaces.messages#Message.Thread.FIELDS.name). For example usage, see [Start or reply to a message thread](https://developers.google.com/workspace/chat/create-messages#create-message-thread). |\n| `requestId` | `string` Optional. A unique request ID for this message. Specifying an existing request ID returns the message created with that ID instead of creating a new message. |\n| `messageReplyOption` | `enum (`[MessageReplyOption](/workspace/chat/api/reference/rest/v1/spaces.messages/create#MessageReplyOption)`)` 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. |\n| `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). |\n\n### Request body\n\nThe request body contains an instance of [Message](/workspace/chat/api/reference/rest/v1/spaces.messages#Message).\n\n### Response body\n\nIf successful, the response body contains a newly created instance of [Message](/workspace/chat/api/reference/rest/v1/spaces.messages#Message).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/chat.bot`\n- `https://www.googleapis.com/auth/chat.import`\n- `https://www.googleapis.com/auth/chat.messages`\n- `https://www.googleapis.com/auth/chat.messages.create`\n\nFor more information, see the [Authorization guide](/workspace/chat/authenticate-authorize).\n\nMessageReplyOption\n------------------\n\nSpecifies how to reply to a message. More states might be added in the future.\n\n| Enums ||\n|----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `MESSAGE_REPLY_OPTION_UNSPECIFIED` | Default. Starts a new thread. Using this option ignores any [thread ID](/workspace/chat/api/reference/rest/v1/spaces.messages#Message.Thread.FIELDS.name) or [`threadKey`](/workspace/chat/api/reference/rest/v1/spaces.messages#Message.Thread.FIELDS.thread_key) that's included. |\n| `REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD` | Creates the message as a reply to the thread specified by [thread ID](/workspace/chat/api/reference/rest/v1/spaces.messages#Message.Thread.FIELDS.name) or [`threadKey`](/workspace/chat/api/reference/rest/v1/spaces.messages#Message.Thread.FIELDS.thread_key). If it fails, the message starts a new thread instead. |\n| `REPLY_MESSAGE_OR_FAIL` | Creates the message as a reply to the thread specified by [thread ID](/workspace/chat/api/reference/rest/v1/spaces.messages#Message.Thread.FIELDS.name) or [`threadKey`](/workspace/chat/api/reference/rest/v1/spaces.messages#Message.Thread.FIELDS.thread_key). If a new `threadKey` is used, a new thread is created. If the message creation fails, a `NOT_FOUND` error is returned instead. |"]]