Skip to content
FiveCord Docs

Attachment uploads

Send attachments as files[n] parts in a multipart message, or upload them before creating the message. Pre-uploading has four steps:

  1. Request an upload plan.
  2. Send the bytes to its upload URLs.
  3. Complete the upload if it is multipart.
  4. Include its upload_filename when creating or editing a message.

Request attachment upload URLs accepts up to 10 files. Declare each file’s ID, name, exact byte count and content type. The endpoint reference defines the fields, permissions and file size limits.

Keep the returned plan, including its upload_filename. Use the returned content_type, which FiveCord derives from the file name and which can therefore differ from the declared value. The upload_mode determines the next steps.

ValueSelected forAdded fields
singlepart1A declared file_size of at most 10485760 bytesupload_url
multipart2A declared file_size above 10485760 bytesupload_id, part_size, and parts

1 Stored as soon as its PUT succeeds, so it is never sent to Complete attachment upload

2 Each parts entry has a one-based part_number and its own upload_url, and the array is ordered by ascending part number

Use the part_size and parts returned in the upload plan. Every part must contain exactly part_size bytes except the last, which contains the remainder. Do not calculate a different part layout.

Send PUT requests to the returned upload_url values without an Authorization header. The URLs can target storage or the upload relay. Do not rewrite their paths or query strings.

Send exactly the declared byte count. The relay returns 413 for an oversized body and 401 for a missing, invalid, or expired capability. It also returns 413 for a body above its own limit, which is 500 MiB by default.

A singlepart transfer sends the whole file with the entry’s content_type as its Content-Type header. A multipart transfer sends each part separately.

CapabilityLifetime
Direct singlepart upload URL5 minutes
Direct multipart part URL1 hour
Relay URL of either kind1The relay token lifetime the deployment configures, 900 seconds by default

1 A relay expiry is exclusive, so the capability is already rejected at its expiry second

Complete attachment upload finishes from 1 through 10 multipart uploads. Send the upload_filename and upload_id from each plan after all its parts succeed. Do not send a part list or entity tags.

Completion checks permissions and file size limits again. See the endpoint’s response table for errors. If completion aborts the upload, request a new plan and upload the file again.

Include the upload_filename in a pre-uploaded attachment when calling Create message or Modify message. Uploading alone does not create a message or emit a Gateway event.

An upload is bound to the identity and the channel that planned it, and a key is single use. A key the authenticated identity does not own, a key planned for another channel, and a key an attachment has already consumed each return 400 INVALID_FORM_BODY with UPLOADED_ATTACHMENT_NOT_FOUND on attachments.{index}.upload_filename. Where the object is absent from storage, which is what an untransferred plan leaves behind, the claim returns the same status with FILE_NOT_FOUND on the same path.

A stream preview is a JPEG attached to a voice connection. It uses the user-only Streams API, not the attachment flow. Follow its access rules to read or change a preview.

Use Upload stream preview to send the image as base64 in JSON. Canonical base64 uses the standard alphabet, a length divisible by four and at most two trailing = characters. Decoding and re-encoding must produce the same string. Invalid encoding returns 400 INVALID_STREAM_THUMBNAIL_PAYLOAD.

Alternatively, request an upload URL and send the JPEG with PUT. Use the returned content_type, send at most max_bytes bytes and upload before expires_at. The URL can be reused until it expires.

Send a valid JPEG of at most 1000000 bytes. Get stream preview reads it, and Delete stream preview removes it.

A preview expires one day after an inline upload or the request that issued its upload URL. Reusing the URL does not extend the preview’s lifetime. An expired preview returns an empty 404.

API requests return the standard error response. Relay requests return plain-text media errors. Direct storage errors use the storage provider’s format.

Each API endpoint documents its rate limit. The relay has no request-count rate limit.