Method: files.create

Uploads a file for use in media or rich card messages.

The agent provides the URL or binary of the file and (optionally) the URL of the corresponding thumbnail file. The RBM platform caches the file for 30 days and returns a unique name that you can use to identify the file when sending agent messages.

To upload a file binary, make an HTTP POST request to the Upload URI, omit the fileUrl field from the JSON request body, 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.

HTTP request

  • Upload URI, for media upload requests:
    POST https://rcsbusinessmessaging.googleapis.com/upload/v1/files
  • Metadata URI, for metadata-only requests:
    POST https://rcsbusinessmessaging.googleapis.com/v1/files

The URL uses gRPC Transcoding syntax.

Request body

The request body contains data with the following structure:

JSON representation
{
  "fileUrl": string,
  "thumbnailUrl": string,
  "contentDescription": string,
  "agentId": string
}
Fields
fileUrl

string

Optional. Publicly available URL of the file. The RBM platform determines the MIME type of the file from the content-type field in the HTTP headers when fetching the file. RBM supports image, audio, video, and pdf.

Supported image content types: image/jpeg, image/jpg, image/gif, image/png.

Supported audio content types: audio/aac, audio/mp3, audio/mpeg, audio/mpg, audio/mp4, audio/mp4-latm, audio/3gpp, application/ogg, audio/ogg.

Supported video content types: video/h263, video/m4v, video/mp4, video/mpeg, video/mpeg4, video/webm.

Supported pdf content types: application/pdf.

thumbnailUrl

string

Optional. Publicly available URL of the thumbnail corresponding to the file. If this field is not set, then the RBM platform automatically generates a thumbnail from the file. The RBM platform determines the MIME type of the file from the content-type field in the HTTP headers when fetching the file.

Supported image content types: image/jpeg, image/jpg, image/gif, image/png.

contentDescription

string

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

agentId

string

Required. The agent's unique identifier.

Response body

A file resource with a unique name that an agent can use to identify the file when sending messages.

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

JSON representation
{
  "name": string
}
Fields
name

string

Server-assigned unique name of the file resource, which an agent can use to identify the file when sending messages. The format is "files/{uid}", where {uid} is a unique ID.

Authorization scopes

Requires the following OAuth scope:

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

For more information, see the OAuth 2.0 Overview.