Slack SDK (Python)
raw JSON → 3.41.0 verified Tue May 12 auth: no python install: verified quickstart: verified
Official Slack SDK for Python. Current version is 3.41.0 (Mar 2026). PyPI package is 'slack-sdk', imports as 'slack_sdk'. The predecessor 'slackclient' is in maintenance mode — vast amounts of tutorial code still references it. This is the official replacement.
pip install slack-sdk Common errors
error ModuleNotFoundError: No module named 'slackclient' ↓
cause You've installed `slack-sdk` but are using code or tutorials written for the deprecated `slackclient` library.
fix
Update your code to use
slack-sdk classes and methods (e.g., from slack_sdk.web import WebClient instead of from slackclient import WebClient), or install slackclient if you must use legacy code. error slack_sdk.errors.SlackApiError: The request to the Slack API failed. ↓
cause The API call failed on the Slack server side, often due to an invalid token, missing permissions (scopes), or rate limiting.
fix
Verify your bot token/user token is correct and has the necessary scopes for the API method being called. Check Slack API documentation for endpoint-specific requirements and review the
response property for detailed error information. error from slack_sdk import WebClient ↓
cause The `WebClient` class is located within the `slack_sdk.web` submodule, not directly under the top-level `slack_sdk` package.
fix
Change the import statement to
from slack_sdk.web import WebClient. error slack_sdk.errors.SlackRequestVerificationError: signature verification failed ↓
cause The signature in the incoming Slack event request does not match the signature calculated by the SDK, usually due to an incorrect `SLACK_SIGNING_SECRET` or a modified request body.
fix
Ensure the
SLACK_SIGNING_SECRET environment variable or configuration value exactly matches the 'Signing Secret' found in your Slack app's 'Basic Information' settings. Also, verify that no middleware is altering the raw request body before the SDK processes it. Warnings
breaking slackclient (pip install slackclient) is in maintenance mode. slack-sdk (pip install slack-sdk) is the official successor. They have different import paths: slack vs slack_sdk. ↓
fix pip uninstall slackclient && pip install slack-sdk. Update imports from 'from slack import' to 'from slack_sdk import'.
breaking files.upload API is retired (Nov 12, 2025). New apps blocked from it since May 2024. Calling client.files_upload() on new apps returns method_deprecated error. ↓
fix Use client.files_upload_v2() instead. Parameter change: channels= renamed to channel_id=, no longer accepts multiple channels or channel names.
breaking files_upload_v2 channel parameter is channel_id= (not channels= plural). Passing channels= silently fails or is ignored. ↓
fix client.files_upload_v2(channel_id='C0123456789', file=filepath)
breaking aiohttp is no longer a required dependency in slack-sdk v3. AsyncWebClient and AsyncWebhookClient will raise ImportError if aiohttp is not explicitly installed. ↓
fix Add aiohttp to requirements.txt explicitly when using async clients.
gotcha WebClient.run_async option removed in v3. Use AsyncWebClient for async operations instead of the v2 run_async=True flag. ↓
fix Replace WebClient(token=..., run_async=True) with AsyncWebClient(token=...)
gotcha files_upload_v2 is asynchronous on the Slack server side. Even after a successful response, the file may not immediately appear in channel. Polling files.info or using Events API is required for post-upload processing. ↓
fix Do not assume file is available in channel immediately after upload response.
gotcha Token type matters: Bot tokens (xoxb-) for most operations, User tokens (xoxp-) for user-scoped actions, App-level tokens (xapp-) for Socket Mode only. Mixing them causes invalid_auth or missing_scope errors. ↓
fix Use xoxb- bot tokens for standard bot operations. xapp- tokens are only for Socket Mode handshake.
breaking KeyError: 'SLACK_BOT_TOKEN' occurs when the SLACK_BOT_TOKEN environment variable is not set. The Slack SDK's WebClient and AsyncWebClient require a token for authentication, typically provided via this environment variable. ↓
fix Ensure the SLACK_BOT_TOKEN environment variable is set before running the application (e.g., export SLACK_BOT_TOKEN='xoxb-YOUR-TOKEN' in your shell or Dockerfile) or pass the token directly as a string to the client constructor: client = WebClient(token='xoxb-YOUR-TOKEN').
breaking The SLACK_BOT_TOKEN environment variable is not set. The WebClient constructor (and other client constructors) expects a token, either passed directly as an argument or available via the SLACK_BOT_TOKEN environment variable. ↓
fix Ensure the SLACK_BOT_TOKEN environment variable is set in your environment before running the script, or pass the token explicitly to the client constructor, e.g., `WebClient(token='xoxb-YOUR-BOT-TOKEN')`.
Install
pip install slackclient Install compatibility verified last tested: 2026-05-12
python os / libc variant status wheel install import disk
3.10 alpine (musl) slack-sdk - - 0.23s 21.6M
3.10 alpine (musl) slackclient - - - -
3.10 slim (glibc) slack-sdk - - 0.16s 22M
3.10 slim (glibc) slackclient - - - -
3.11 alpine (musl) slack-sdk - - 0.39s 24.2M
3.11 alpine (musl) slackclient - - - -
3.11 slim (glibc) slack-sdk - - 0.35s 25M
3.11 slim (glibc) slackclient - - - -
3.12 alpine (musl) slack-sdk - - 0.59s 15.9M
3.12 alpine (musl) slackclient - - - -
3.12 slim (glibc) slack-sdk - - 0.54s 16M
3.12 slim (glibc) slackclient - - - -
3.13 alpine (musl) slack-sdk - - 0.58s 15.5M
3.13 alpine (musl) slackclient - - - -
3.13 slim (glibc) slack-sdk - - 0.54s 16M
3.13 slim (glibc) slackclient - - - -
3.9 alpine (musl) slack-sdk - - 0.21s 21.2M
3.9 alpine (musl) slackclient - - - -
3.9 slim (glibc) slack-sdk - - 0.19s 22M
3.9 slim (glibc) slackclient - - - -
Imports
- WebClient wrong
from slack import WebClientcorrectfrom slack_sdk import WebClient - SlackApiError wrong
from slack.errors import SlackApiErrorcorrectfrom slack_sdk.errors import SlackApiError
Quickstart verified last tested: 2026-05-12
import os
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
client = WebClient(token=os.environ['SLACK_BOT_TOKEN'])
try:
response = client.chat_postMessage(
channel='#general',
text='Hello world!'
)
except SlackApiError as e:
print(f"Error: {e.response['error']}")
# File upload (v2 — required for new apps)
client.files_upload_v2(
channel='C0123456789',
file='./report.pdf',
filename='report.pdf'
)