Slack. Web. Files
(SlackKit v1.0.0-alpha.0)
View Source
Summary
Functions
Finishes an upload started with files.getUploadURLExternal
Deletes a file.
Gets a URL for an edge external file upload
Gets information about a file.
List files for a team, in a channel, or from a user with applied filters.
Revokes public/external sharing access for a file
Enables a file for public/external sharing.
Uploads or creates a file.
Functions
Finishes an upload started with files.getUploadURLExternal
API reference
Rate limit: Tier 4: 100+ per minute
Scopes:
- Bot token:
files:write - User token:
files:write
Required Params
files- Array of file ids and their corresponding (optional) titles. ex:[{"id":"F044GKUHN9Z", "title":"slack-test", "highlight_type":"png"}]
Optional Params
blocks- A JSON-based array of structured rich text blocks, presented as a URL-encoded string. If theinitial_commentfield is provided, theblocksfield is ignored ex:[{"type": "section", "text": {"type": "plain_text", "text": "Hello world"}}]channel_id- Channel ID where the file will be shared. If not specified the file will be private. ex:C0NF841BKchannels- Comma-separated string of channel IDs or user IDs where the file will be shared. ex:C0NF841BK,C2AW648GHinitial_comment- The message text introducing the file in specified channels.thread_ts- Provide another message'stsvalue to upload this file as a reply. Never use a reply'stsvalue; use its parent instead. Also make sure to provide only one channel when using 'thread_ts' ex:1524523204.000192
Errors the API can return:
channel_not_found- Value passed forchannel_idwas invalid.channels_limit_exceeded- Exceeded the channel limit. A maximum of 100 channels is allowed per request.file_not_found- Could not find the file from the upload ticket.file_type_not_allowed- The file type is not permitted based on the team's allowed_file_upload_types preference.file_update_failed- Failure occurred when attempting to update the file.file_uploads_except_images_disabled- Only image file uploads are permitted for this team.invalid_blocks- Provided blocks are in the incorrect format.invalid_channel- Channel could not be found or channel specified is invalid.not_in_channel- User/bot membership is required for the specified channel.posting_to_channel_denied- User is not authorized to post to channel.
See the Common Errors guide for errors returned by every Web API method.
Deletes a file.
API reference
Rate limit: Tier 3: 50+ per minute
Scopes:
- Bot token:
files:write - User token:
files:write
Required Params
file- ID of file to delete.
Errors the API can return:
cant_delete_file- Authenticated user does not have permission to delete this file.delete_not_allowed- Error returned when the requested file does not support deletion; for example, when attempting to delete a canvas template.file_deleted- The file has already been deleted.file_deleting_disabled- This functionality is disabled.file_not_found- The file does not exist, or is not visible to the calling user.
See the Common Errors guide for errors returned by every Web API method.
Gets a URL for an edge external file upload
API reference
Rate limit: Tier 4: 100+ per minute
Scopes:
- Bot token:
files:write - User token:
files:write
Required Params
filename- Name of the file being uploaded. ex:laughingoutloudcat.jpglength- Size in bytes of the file being uploaded. ex:53072
Optional Params
alt_txt- Description of image for screen-reader. ex:Aerial view of the Bixby Bridge and coastline of the Big Sur area in Californiasnippet_type- Syntax type of the snippet being uploaded. ex:python
Errors the API can return:
alt_txt_too_large- Description for the image is longer than the limit of 1000 characterfile_type_not_allowed- The file type is not allowed.file_upload_size_restricted- The size of provided file is too large, as the team has restricted uploads of large files.file_uploads_disabled- Team has disabled all file uploads.file_uploads_except_images_disabled- File uploads except images are disabled.missing_argument- A required argument was not provided. Typically only occurs when thelengthprovided is 0.snippet_too_large- The providedlengthis too large to create a snippet, which are limited to 1MB.storage_limit_reached- File storage limit has been reached. This occurs when free teams have uploaded 5GB of files.unknown_snippet_type- The providedsnippet_typeis not a supported type.unknown_subtype- The providedsubtypeis not a supported type.
See the Common Errors guide for errors returned by every Web API method.
Gets information about a file.
API reference
Rate limit: Tier 4: 100+ per minute
Scopes:
- Bot token:
files:read - User token:
files:read
Required Params
file- Specify a file by providing its ID. ex:F2147483862
Optional Params
count-cursor- Parameter for pagination. File comments are paginated for a single file. Setcursorequal to thenext_cursorattribute returned by the previous request'sresponse_metadata. This parameter is optional, but pagination is mandatory: the default value simply fetches the first "page" of the collection of comments. See pagination for more details. ex:dXNlcjpVMDYxTkZUVDI=limit- The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached. 0 ex:20page-
Errors the API can return:
canvas_disabled_file_team- Canvas is disabled on file's teamcanvas_disabled_user_team- Canvas is disabled on user's team for connected Channelscanvas_globally_disabled- Canvas is disabled for this teamfile_deleted- The requested file has been deletedfile_not_found- Value passed forfilewas invalidnot_visible- Do not have permission to view the fileslack_connect_canvas_sharing_blocked- Admin has disabled sharing of Canvas links in all Slack Connect communicationstemplate_not_visible- Do not have permissions to view this template
See the Common Errors guide for errors returned by every Web API method.
List files for a team, in a channel, or from a user with applied filters.
API reference
Rate limit: Tier 3: 50+ per minute
Scopes:
- Bot token:
files:read - User token:
files:read
Optional Params
channel- Filter files appearing in a specific channel, indicated by its ID.count-page-show_files_hidden_by_limit- Show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit. ex:trueteam_id- encoded team id to list files in, required if org token is usedts_from- Filter files created after this timestamp (inclusive). ex:123456789ts_to- Filter files created before this timestamp (inclusive). ex:123456789types- Filter files by type (see below). You can pass multiple values in the types argument, liketypes=spaces,snippets.The default value isall, which does not filter the list. ex:imagesuser- Filter files created by a single user.
Errors the API can return:
missing_argument- A required argument is missing.slack_connect_canvas_sharing_blocked- Admin has disabled sharing of Canvas links in all Slack Connect communicationsunknown_type- Value passed fortypeswas invaliduser_not_found- Value passed foruserwas invalid
See the Common Errors guide for errors returned by every Web API method.
Revokes public/external sharing access for a file
API reference
Rate limit: Tier 3: 50+ per minute
Scopes:
- Bot token:
files:write - User token:
files:write
Required Params
file- File to revoke
Errors the API can return:
file_not_found- Value passed forfilewas invalid
See the Common Errors guide for errors returned by every Web API method.
Uploads or creates a file.
API reference
Rate limit: Tier 2: 20+ per minute
Scopes:
- Bot token:
files:write - User token:
files:write
Optional Params
channels- Comma-separated list of channel names or IDs where the file will be shared.content- File contents via a POST variable. If omitting this parameter, you must provide afile. You must provide either afileorcontentparameter. The content of the file can either be posted using anenctypeofmultipart/form-data(with the file parameter namedfile), in the usual way that files are uploaded via the browser, or the content of the file can be sent as a POST var calledcontent. ex:...file- File contents viamultipart/form-data. If omitting this parameter, you must submitcontent. You must provide either afileorcontentparameter. The content of the file can either be posted using anenctypeofmultipart/form-data(with the file parameter namedfile), in the usual way that files are uploaded via the browser, or the content of the file can be sent as a POST var calledcontent. Possiblefiletypevalues can be found in thefileobject definition. ex:...filename- Filename of file. If you only specify afilename, we remove the file extension and populate the file'stitlewith the remaining value. ex:foo.txtfiletype- A file type identifier. Possiblefiletypevalues can be found in thefileobject definition. ex:phpinitial_comment- The message text introducing the file in specifiedchannels. ex:Best!thread_ts- Provide another message'stsvalue to upload this file as a reply. Never use a reply'stsvalue; use its parent instead.title- Title of file. If you only specify afilename, we remove the file extension and populate the file'stitlewith the remaining value. ex:My File
Errors the API can return:
blocked_file_type- Admin has disabled uploading this type of filechannel_not_found- At least one of the values passed forchannelswas invalid.invalid_channel- One or more channels supplied are invalidinvalid_thread_ts- Value passed to thread_ts was invalidmalware_detected- This file may contain a virus or other malware and can't be uploaded to Slacknot_in_channel- Authenticated user is not in the channel.post_contents_too_large- File content is larger than 130kb.posting_to_general_channel_denied- An admin has restricted posting to the #general channel.slack_connect_blocked_file_type- File uploads with certain types are blocked in all Slack Connect communicationsslack_connect_clip_sharing_blocked- Admin has disabled Clip sharing in Slack Connect channelsslack_connect_file_upload_sharing_blocked- Admin has disabled File uploads in all Slack Connect communications
See the Common Errors guide for errors returned by every Web API method.