Sample - Slack Web API
POST/files.upload

Upload or create a file

Uploads or creates a file and can share it with channels or attach it to a message thread. Provide either file or content, then use filename, title, channels, or thread_ts to control how the file is presented and shared. Include an initial message with initial_comment when introducing the file in specified channels.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

9 body fields

Form data containing file content or a file upload and optional sharing and message details.

tokenstringoptional
Authentication token. Requires scope: `files:write:user`
filestringoptional
File contents via `multipart/form-data`. If omitting this parameter, you must submit `content`.
contentstringoptional
File contents via a POST variable. If omitting this parameter, you must provide a `file`.
filetypestringoptional
A [file type](/types/file#file_types) identifier.
filenamestringoptional
Filename of file.
titlestringoptional
Title of file.
initial_commentstringoptional
The message text introducing the file in specified `channels`.
channelsstringoptional
Comma-separated list of channel names or IDs where the file will be shared.
thread_tsnumberoptional
Provide another message's `ts` value to upload this file as a reply. Never use a reply's `ts` value; use its parent instead.

2 status codes
200Returns an object with `ok` set to true and the created `file` object.
fileobjectrequired
okbooleanrequired
Allowed:true
defaultReturned when the upload, file source, channel, authentication, permission, or request argument is invalid; the response includes `ok` set to false and an `error` reason.
callstackstringoptional
Note: PHP callstack is only visible in dev/qa
errorstringrequired
Allowed:posting_to_general_channel_deniedinvalid_channelfile_uploads_disabledfile_uploads_except_images_disabledstorage_limit_reachednot_authedinvalid_authaccount_inactiveno_permissioninvalid_arg_nameinvalid_array_arginvalid_charset
okbooleanrequired
Allowed:false

Error handling

Provide either file or content as the file source, and do not omit both. If thread_ts is supplied, it must identify the parent message rather than a reply; channels accepts a comma-separated list of channel names or IDs.