Registry / communication / slack-sdk

slack-sdk

JSON →
library3.43.0pypypi✓ verified 26d ago

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
INSTALL
IMPORT
SIG · SLACK-SDK
S
slack-sdk
communicationpythonv3.43.0
Install
3.3s avg
Import
380ms
Disk
51MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.43.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.398s · 81.1MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.3s · import 0.362s · 22MB
51MB installed
● package 51MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

WebClient
from slack_sdk import WebClient
from slack import WebClient
Package installs as slack-sdk but imports as slack_sdk. 'from slack import WebClient' is the old slackclient v2 pattern — raises AttributeError: module 'slack' has no attribute 'WebClient' if slack-sdk is installed instead.
SlackApiError
from slack_sdk.errors import SlackApiError
from slack.errors import SlackApiError
Same package rename issue. Error class moved to slack_sdk.errors in v3.

Minimal message post and file upload using slack-sdk v3.x.

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' )
Debug
Known issues
breakingslackclient (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'.
affects: slackclient all
breakingfiles.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.
affects: all
breakingfiles_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)
affects: all
breakingaiohttp 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.
affects: >= 3.0
gotchaWebClient.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=...)
affects: >= 3.0
gotchafiles_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.
affects: all
gotchaToken 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.
affects: all
breakingKeyError: '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').
affects: all
breakingThe 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')`.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'slackclient'
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.
slack_sdk.errors.SlackApiError: The request to the Slack API failed.
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.
from slack_sdk import WebClient
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`.
slack_sdk.errors.SlackRequestVerificationError: signature verification failed
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.
Upgrade
Version history
3.43.0latest on PyPI · released Jun 30, 2026
Audit
Dependencies
aiohttpoptionalRequired for AsyncWebClient and AsyncWebhookClient. Not auto-installed by slack-sdk v3+. Must be added explicitly.
Agent activity
19 hits · last 30 days
node
14
OpenAI (training)
1
Resources