files.upload API method has been deprecated. It will stop functioning and be officially sunset on November 12, 2025.Existing apps and integrations should migrate away from files.upload and instead leverage a combination of two API methods: files.getUploadURLExternal and files.completeUploadExternal. See Uploading files for more details on the process, and read more about the change in this changelog article.
Facts
application/x-www-form-urlencoded application/json Arguments
Required arguments
tokenstringRequiredAuthentication token bearing required scopes. Tokens should be passed as an HTTP Authorization header or alternatively, as a POST parameter.
xxxx-xxxxxxxxx-xxxxOptional arguments
channelsstringOptionalComma-separated list of channel names or IDs where the file will be shared.
contentstringOptionalFile contents via a POST variable. If omitting this parameter, you must provide a file.
...fileOptionalFile contents via multipart/form-data. If omitting this parameter, you must submit content.
...filenamestringOptionalFilename of file.
foo.txtinitial_commentstringOptionalThe message text introducing the file in specified channels.
Best!thread_tsstringOptionalProvide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead.
titlestringOptionalTitle of file.
My FileUsage info
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
Success response after uploading a file to a channel with an initial message
{
"ok": true,
"file": {
"id": "F0TD00400",
"created": 1532293501,
"timestamp": 1532293501,
"name": "dramacat.gif",
"title": "dramacat",
"mimetype": "image/jpeg",
"filetype": "gif",
"pretty_type": "JPEG",
"user": "U0L4B9NSU",
"editable": false,
"size": 43518,
"mode": "hosted",
"is_external": false,
"external_type": "",
"is_public": false,
"public_url_shared": false,
"display_as_bot": false,
"username": "",
"url_private": "https://.../dramacat.gif",
"url_private_download": "https://.../dramacat.gif",
"thumb_64": "https://.../dramacat_64.gif",
"thumb_80": "https://.../dramacat_80.gif",
"thumb_360": "https://.../dramacat_360.gif",
"thumb_360_w": 360,
"thumb_360_h": 250,
"thumb_480": "https://.../dramacat_480.gif",
"thumb_480_w": 480,
"thumb_480_h": 334,
"thumb_160": "https://.../dramacat_160.gif",
"image_exif_rotation": 1,
"original_w": 526,
"original_h": 366,
"permalink": "https://.../dramacat.gif",
"permalink_public": "https://.../More-Path-Components",
"comments_count": 0,
"is_starred": false,
"shares": {
"private": {
"D0L4B9P0Q": [
{
"reply_users": [],
"reply_users_count": 0,
"reply_count": 0,
"ts": "1532293503.000001"
}
]
}
},
"channels": [],
"groups": [],
"ims": [
"D0L4B9P0Q"
],
"has_rich_preview": false
}
}
Uploading a file with the content parameter creates an editable text/plain file by default
{
"ok": true,
"file": {
"id": "F0TD0GUTS",
"created": 1532294750,
"timestamp": 1532294750,
"name": "-.txt",
"title": "Untitled",
"mimetype": "text/plain",
"filetype": "text",
"pretty_type": "Plain Text",
"user": "U0L4B9NSU",
"editable": true,
"size": 11,
"mode": "snippet",
"is_external": false,
"external_type": "",
"is_public": true,
"public_url_shared": false,
"display_as_bot": false,
"username": "",
"url_private": "https://.../.txt",
"url_private_download": "https://...download/-.txt",
"permalink": "https://.../.txt",
"permalink_public": "https://.../.txt",
"edit_link": "https://.../.txt/edit",
"preview": "launch plan",
"preview_highlight": "<div class=\"CodeMirror cm-s-default CodeMirrorServer\" oncopy=\"if(event.clipboardData){event.clipboardData.setData('text/plain',window.getSelection().toString().replace(/\\u200b/g,''));event.preventDefault();event.stopPropagation();}\">\n<div class=\"CodeMirror-code\">\n<div><pre>launch plan</pre></div>\n</div>\n</div>\n",
"lines": 1,
"lines_more": 0,
"preview_is_truncated": false,
"comments_count": 0,
"is_starred": false,
"shares": {
"public": {
"C061EG9SL": [
{
"reply_users": [],
"reply_users_count": 0,
"reply_count": 0,
"ts": "1532294750.000001",
"channel_name": "general",
"team_id": "T061EG9R6"
}
]
}
},
"channels": [
"C061EG9SL"
],
"groups": [],
"ims": [],
"has_rich_preview": false
}
}
Typical error response
{
"ok": false,
"error": "invalid_auth"
}
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
Errors
This table lists the expected errors that this method could return. However, other errors can be returned in the case where the service is down or other unexpected factors affect processing. Callers should always check the value of the ok parameter in the response.
access_deniedAccess to a resource specified in the request is denied.
accesslimitedAccess to this method is limited on the current network
account_inactiveAuthentication token is for a deleted user or workspace when using a bot token.
blocked_file_typeAdmin has disabled uploading this type of file
channel_not_foundAt least one of the values passed for channels was invalid.
deprecated_endpointThe endpoint has been deprecated.
ekm_access_deniedAdministrators have suspended the ability to post a message.
enterprise_is_restrictedThe method cannot be called from an Enterprise.
fatal_errorThe server could not complete your operation(s) without encountering a catastrophic error. It's possible some aspect of the operation succeeded before the error was raised.
internal_errorThe server could not complete your operation(s) without encountering an error, likely due to a transient issue on our end. It's possible some aspect of the operation succeeded before the error was raised.
invalid_arg_nameThe method was passed an argument whose name falls outside the bounds of accepted or expected values. This includes very long names and names with non-alphanumeric characters other than _. If you get this error, it is typically an indication that you have made a very malformed API call.
invalid_argumentsThe method was called with invalid arguments.
invalid_array_argThe method was passed an array as an argument. Please only input valid strings.
invalid_authSome aspect of authentication cannot be validated. Either the provided token is invalid or the request originates from an IP address disallowed from making the request.
invalid_channelOne or more channels supplied are invalid
invalid_charsetThe method was called via a POST request, but the charset specified in the Content-Type header was invalid. Valid charset names are: utf-8 iso-8859-1.
invalid_form_dataThe method was called via a POST request with Content-Type application/x-www-form-urlencoded or multipart/form-data, but the form data was either missing or syntactically invalid.
invalid_post_typeThe method was called via a POST request, but the specified Content-Type was invalid. Valid types are: application/json application/x-www-form-urlencoded multipart/form-data text/plain.
invalid_thread_tsValue passed to thread_ts was invalid
malware_detectedThis file may contain a virus or other malware and can't be uploaded to Slack
method_deprecatedThis API is deprecated. Please refer to https://docs.slack.dev/changelog/2024-04-a-better-way-to-upload-files-is-here-to-stay
method_deprecatedThe method has been deprecated.
missing_post_typeThe method was called via a POST request and included a data payload, but the request did not include a Content-Type header.
missing_scopeThe token used is not granted the specific scope permissions required to complete this request.
no_permissionThe workspace token used in this request does not have the permissions necessary to complete the request. Make sure your app is a member of the conversation it's attempting to post a message to.
not_allowed_token_typeThe token type used in this request is not allowed.
not_authedNo authentication token provided.
not_in_channelAuthenticated user is not in the channel.
org_login_requiredThe workspace is undergoing an enterprise migration and will not be available until migration is complete.
post_contents_too_largeFile content is larger than 130kb.
posting_to_general_channel_deniedAn admin has restricted posting to the #general channel.
ratelimitedThe request has been ratelimited. Refer to the Retry-After header for when to retry the request.
request_timeoutThe method was called via a POST request, but the POST data was either missing or truncated.
service_unavailableThe service is temporarily unavailable
slack_connect_blocked_file_typeFile uploads with certain types are blocked in all Slack Connect communications
slack_connect_clip_sharing_blockedAdmin has disabled Clip sharing in Slack Connect channels
slack_connect_file_upload_sharing_blockedAdmin has disabled File uploads in all Slack Connect communications
team_access_not_grantedThe token used is not granted the specific workspace access required to complete this request.
team_added_to_orgThe workspace associated with your request is currently undergoing migration to an Enterprise Organization. Web API and other platform operations will be intermittently unavailable until the transition is complete.
token_expiredAuthentication token has expired
token_revokedAuthentication token is for a deleted user or workspace or the app has been removed when using a user token.
two_factor_setup_requiredTwo factor setup is required.