Method: attachments.create

Creates an attachment for an RCS for Business agent. This method supports direct media uploads and multipart uploads.

The agent developer provides the binary of the file to be uploaded.

To upload a file binary, make an HTTP POST request to the Upload URI and specify the binary as the POST request body. For example, use the --upload-file cURL flag with the fully qualified file path of the binary file.

Parameters
Parameter Type Description Required?
uploadType string Specifies the type of upload. Supported values are media for direct file upload and multipart for uploading file and metadata together. Yes
attachmentOperationSource enum Required if uploadType=media. Specifies the reason for the upload. See AttachmentOperationSource for possible values. Only for media
Request body

The structure of the request body depends on the uploadType query parameter.

If uploadType=media:

  • The request body must contain only the raw file bytes.
  • The Content-Type header must be set to the MIME type of the file. Note: Only PDFs are supported.
  • The attachmentOperationSource must be provided as a query parameter.

If uploadType=multipart:

  • The request body must be formatted as multipart/form-data.
  • The request must contain two parts:
    • Metadata: A JSON object containing the upload metadata. This part must include the attachmentOperationSource.
    • File: The raw file bytes.

HTTP request

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

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
parent

string

Required. The unique identifier of the agent. If the brand identifier is "1234" and the agent identifier is "5678", this parameter resolves to "brands/1234/agents/5678".

Request body

The request body contains data with the following structure:

JSON representation
{
  "attachmentOperationSource": enum (AttachmentOperationSource)
}
Fields
attachmentOperationSource

enum (AttachmentOperationSource)

Required. The source that triggered the attachment upload.

Response body

An attachment resource with a unique name that an agent can use to identify the attachment.

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

JSON representation
{
  "name": string,
  "gcsUrl": string,
  "displayName": string,
  "description": string,
  "contentType": string,
  "sizeBytes": string,
  "attachmentOperationSource": enum (AttachmentOperationSource),
  "uploadTime": string,
  "uploadError": {
    object (Status)
  }
}
Fields
name

string

Output only. The unique identifier of the attachment. Read-only. Defined by the platform.

gcsUrl

string

Output only. The GCS URL of the attachment. This is the publicly accessible URL that is used to fetch the attachment from GCS.

displayName

string

Optional. Display name of the attachment.

description

string

Optional. Text description of the attachment's content. Screen readers use this description to help users with disabilities understand what the attachment contains.

contentType

string

Optional. The content type of the attachment.

sizeBytes

string (int64 format)

Output only. Size in bytes of the attachment.

attachmentOperationSource

enum (AttachmentOperationSource)

Required. The source that triggered the attachment upload. Specifies the reason for the upload. See AttachmentOperationSource for possible values.

uploadTime

string (Timestamp format)

Output only. The time when the attachment was uploaded to GCS.

Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: "2014-10-02T15:01:23Z", "2014-10-02T15:01:23.045123456Z" or "2014-10-02T15:01:23+05:30".

uploadError

object (Status)

Output only. Error result, if any, that occurred during the attachment upload.

Authorization scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/businesscommunications

For more information, see the OAuth 2.0 Overview.

AttachmentOperationSource

List of Attachment Operation Sources.

Enums
ATTACHMENT_OPERATION_SOURCE_UNSPECIFIED Attachment Operation is unspecified
VERIFICATION_PAGE Console verification page.
VERIFICATION_ATTACHMENT_VIA_BC_API Supporting attachment for agent verification, uploaded using the Business Communications API.