Cloud Uploads
You can upload large attachments quickly directly to Discord's Google Cloud storage bucket, using the endpoints below to generate upload URLs, and sending each generated URL a PUT request with the intended attachment as the body.
This allows you to upload up a file up to 500 MiB directly to Google Cloud. Note that file size limits will still apply when sending the attachment in a message.
An example implementation in Python pseudocode would be:
Now, instead of sending the attachment again in a form body in the request, you can just send the upload_filename! For example:
{ "content": "look at my cute cat!", "attachments": [ { "id": "0", "filename": "cat.png", "uploaded_filename": "6a08e58a-265f-485a-8c85-5cd4df0edde0/cat.png" } ]}Upload Attachment Object
Upload Attachment Structure
| Field | Type | Description |
|---|---|---|
| id? | ?snowflake | The ID of the attachment to reference in the response |
| filename | string | The name of the file being uploaded (max 1024 characters) |
| file_size | integer | The size of the file being uploaded in bytes |
| is_clip? 1 2 | boolean | Whether the file being uploaded is a clipped recording of a stream |
| original_content_type? | string | The attachment's original media type |
1 When uploading a clip, an increased default file size limit of 100 MiB applies.
2 Only applicable within Create Message Attachments endpoint.
Cloud Attachment Object
Cloud Attachment Structure
| Field | Type | Description |
|---|---|---|
| id | ?snowflake | The ID of the attachment upload, if provided in the request |
| upload_url | string | The URL to upload the file to |
| upload_filename | string | The name of the uploaded file |
Endpoints
Create Message Attachments
POST/channels/{channel.id}/attachmentsCreates attachment URLs to upload the intended attachments directly to Discord's GCP storage bucket. Returns an array of cloud attachment objects. Requires the same permissions as uploading an attachment inline with a message. See above for more information.
JSON Params
| Field | Type | Description |
|---|---|---|
| files | array[upload attachment object] | The target files to create a URL for, containing the name and size (1-10) |
Example Response
{ "attachments": [ { "id": "23", "upload_url": "https://discord-attachments-uploads-prd.storage.googleapis.com/87e49c99-43f8-4a33-baad-5a834c94424c/cat.png?upload_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "upload_filename": "87e49c99-43f8-4a33-baad-5a834c94424c/cat.png" } ]}Create Guild Product Attachments
POST/guilds/{channel.id}/products/attachmentsCreates attachment URLs to upload the intended attachments directly to Discord's GCP storage bucket. Returns an array of cloud attachment objects. See above for more information.
JSON Params
| Field | Type | Description |
|---|---|---|
| files | array[upload attachment object] | The target files to create a URL for, containing the name and size (1-10) |
Create Gravity Attachments
POST/users/@me/gravity-attachmentsCreates attachment URLs to upload the intended attachments directly to Discord's GCP storage bucket. Returns an array of cloud attachment objects. See above for more information.
JSON Params
| Field | Type | Description |
|---|---|---|
| files | array[upload attachment object] | The target files to create a URL for, containing the name and size (1-10) |
Delete Attachment
DELETE/attachments/{cloud_attachment.upload_filename}Deletes an attachment from Discord's GCP storage bucket. Returns a 204 empty response on success.
This endpoint should be used to delete an uploaded attachment that was not used. See above for more information.
Refresh Attachment URLs
POST/attachments/refresh-urlsRefreshes the URLs of attachments that were uploaded to Discord's CDN. The provided URLs do not have to be valid or signed. Existing query string parameters are preserved.
JSON Params
| Field | Type | Description |
|---|---|---|
| attachment_urls | array[string] | The URLs of the attachments to refresh (1-50) |
Response Body
| Field | Type | Description |
|---|---|---|
| refreshed_urls | array[refreshed attachment object] | The refreshed URLs |
Refreshed Attachment Structure
| Field | Type | Description |
|---|---|---|
| original | string | The provided URL |
| refreshed | string | The refreshed URL |
Example Response
{ "refreshed_urls": [ { "original": "https://cdn.discordapp.com/attachments/1012345678900020080/1234567891233211234/my_image.png?ex=65d903de&is=65c68ede&hm=2481f30dd67f503f54d020ae3b5533b9987fae4e55f2b4e3926e08a3fa3ee24f&", "refreshed": "https://cdn.discordapp.com/attachments/1012345678900020080/1234567891233211234/my_image.png?ex=66143372&is=6601be72&hm=5a90a0ac363d9de3619044102ffe963041517f0e2f78baecabfc2f544a14eace&" } ]}