Uploading files
Files are uploaded separately from whatever will reference them. You send the file, get an ID back, and use that ID where the API asks for a file.
The file service has its own address, published in the discovery document as
features.autumn.url — see Endpoints.
Tags
A tag says what the file is for: an avatar, an attachment, an emoji, a server icon. Each has its own size and type limits, which is why the tag is part of the upload rather than something decided later.
Uploading
POST {endpoint}/{tag} with a multipart/form-data body containing one field,
file. Authenticate exactly as with any other route.
const body = new FormData();
body.append("file", file);
const data = await fetch(`${endpoint}/${tag}`, {
method: "POST",
body,
headers: {
"X-Session-Token": "...", // or X-Bot-Token
},
}).then((res) => res.json());
// use data.id
The response is the ID and nothing else:
{
"id": "0"
}
Serving
There are two paths per file: the original, and a preview where one applies.
/{tag}/{file_id}— the file/{tag}/{file_id}/{file_name}— the file, named
Do not add query parameters to ask for a size. The preview route already serves the size that suits the content type, and a client that picks its own defeats the caching that makes it fast. For anything that is not an image, or is an animated one, the preview route redirects to the original.