Method: media.upload

Uploads an attachment. For an example, see Upload media as a file attachment. Requires user authentication.

You can upload attachments up to 200 MB. Certain file types aren't supported. For details, see File types blocked by Google Chat.

HTTP request

  • Upload URI, for media upload requests:
    POST https://chat.googleapis.com/upload/v1/{parent=spaces/*}/attachments:upload
  • Metadata URI, for metadata-only requests:
    POST https://chat.googleapis.com/v1/{parent=spaces/*}/attachments:upload

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
parent

string

Required. Resource name of the Chat space in which the attachment is uploaded. Format "spaces/{space}".

Request body

The request body contains data with the following structure:

JSON representation
{
  "filename": string
}
Fields
filename

string

Required. The filename of the attachment, including the file extension.

Response body

If successful, the response body contains data with the following structure:

JSON representation
{
  "attachmentDataRef": {
    object (AttachmentDataRef)
  }
}
Fields
attachmentDataRef

object (AttachmentDataRef)

Reference to the uploaded attachment.

Authorization scopes

Requires one of the following OAuth scopes:

  • https://www.googleapis.com/auth/chat.import
  • https://www.googleapis.com/auth/chat.messages.create
  • https://www.googleapis.com/auth/chat.messages

For more information, see the Authorization guide.