files.upload
method
We're still building and not all features are available quite yet. Enjoy this peek into the future!
Not ready for the future? Return to the past at api.slack.com.
Usage info
files.upload
is deprecated and will stop functioning on March 11, 2025.Use files.getUploadURLExternal
and files.completeUploadExternal
to upload files instead. Newly created apps will be unable to use files.upload
beginning May 8, 2024. See Uploading files for more details on the process and this changelog for more on the deprecation.
This method allows you to create or upload an existing file.
You must provide either a file
or content
parameter.
The content of the file can either be posted using an enctype
of multipart/form-data
(with the file parameter named file
), in the usual way that files are uploaded via the browser, or the content of the file can be sent as a POST var called content
. The latter should be used for creating a "file" from a long message/paste and forces "editable" mode.
In both cases, the type of data in the file will be intuited from the filename and the magic bytes in the file, for supported formats.
Sending a valid filetype
parameter will override this behavior. Possible filetype
values can be found in the file
object definition.
Files uploaded via multipart/form-data
will be stored either in hosted or editable mode, based on certain heuristics (determined
type, file size).
The file can also be shared directly into channels on upload, by specifying an optional argument channels
. If there's more than one channel name or ID in the channels
string, they should be comma-separated. The owner of the token used to upload the file must also be a member of any channel you wish to post to this way.
There is a 1 megabyte file size limit for files uploaded as snippets.
Upload files and images into message threads by providing the thread parent's ts
value with the thread_ts
parameter.
The initial_comment
field is used in messages to introduce the file in conversation.
If you only specify a filename
, we remove the file extension and populate the file's title
with the remaining value. So, if you want the file's extension to be shown in Slack, you must include it in the title
argument when uploading it.
Response
By default all newly-uploaded files are private and only visible to the owner.
They become public once they are shared into a public channel (which can
happen at upload time via the channels
argument).
If successful, the response will include a file object.
Examples
Upload "dramacat.gif" from the current directory and share it in two channels, using multipart/form-data
:
curl -F file=@dramacat.gif -F "initial_comment=Shakes the cat" -F channels=C024BE91L,D032AC32T -H "Authorization: Bearer xoxb-xxxxxxxxx-xxxx" https://slack.com/api/files.upload
Create an editable text file containing the text "launch plan":
curl -F "content=launch plan" -H "Authorization: Bearer xoxb-xxxxxxxxx-xxxx" https://slack.com/api/files.upload
Upload another image to an existing message thread:
curl -F file=@drworm.gif -F "initial_comment=I play the drums." -F channels=C024BE91L -F thread_ts=1532293503.000001 -H "Authorization: Bearer xoxp-xxxxxxxxx-xxxx" https://slack.com/api/files.upload