# 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.

Important: For user privacy and security, the RCS for Business platform downloads and processes media and PDF files from the provided URLs before delivering them to the user. This prevents agent tracking by unique URLs. Therefore, do not submit a high volume of unique URLs. The RCS for Business platform does not support this, whether the URLs point to the same or different files. Use the same URL for identical files.

The RCS for Business platform caches the file for 60 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](https://google.aip.dev/127) syntax.

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "fileUrl": string, "thumbnailUrl": string, "agentId": string } ``` |

| Fields ||
|---|---|
| `fileUrl` | `string` Optional. Publicly available URL of the file. The RCS for Business platform determines the MIME type of the file from the content-type field in the HTTP headers when fetching the file. RCS for Business 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. Note: A file URL can have one redirect. Redirected file URLs must be publicly accessible. Redirects are not supported for file URLs in CreateAgentMessageRequest. |
| `thumbnailUrl` | `string` Optional. Publicly available URL of the thumbnail corresponding to the file. If this field is not set, then the RCS for Business platform automatically generates a thumbnail from the file. The RCS for Business 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. |
| `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 for the file resource that agents 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](https://developers.google.com/identity/protocols/OAuth2).