Slack Chat API CLI is a lightweight command-line interface designed to provide direct access to the Slack Web API for automation and scripting. This tool enables users to perform tasks such as sending messages, managing channels, listing users, viewing message history, and searching through messages and files directly from the terminal.
Key features of Slack Chat API CLI include:
Direct API Access: Offers programmatic interaction with Slack's Web API.
Message Management: Send, update, or delete messages in public or private channels.
Channel Management: Create, archive, or modify channels, including setting topics and purposes.
User Interaction: List users and retrieve user information.
Search Capabilities: Search through messages and files using Slack's search functionality.
Ideal for developers, system administrators, and automation enthusiasts, this tool streamlines workflow integration by enabling automated tasks such as notifications from CI/CD pipelines or managing channel configurations. It can be installed via winget, making it accessible across various platforms with ease of use and straightforward credential management.
README
slack-chat-cli
A lightweight command-line interface for interacting with the Slack Web API.
Not the Official Slack CLI
This project is not affiliated with Slack or Salesforce. If you're looking to build Slack apps with workflows, triggers, and datastores, check out the official Slack CLI.
Note: On Linux and Windows, credentials are stored in a file with restricted permissions (0600). While not as secure as macOS Keychain, this is standard practice for CLI tools.
slck config set-token
# Paste your token when prompted
Your token is stored securely in macOS Keychain, or in a config file on Linux and Windows.
NOTE: If you plan on sending messages or taking actions using your user token (See: Choosing Between Bot and User Tokens), you'll need to adjust the manifest above to have all the same scopes configured for your user as your bot (with the exception of the "channels:manage" scope, which only applies to bots).
Alternative: Environment Variable
export SLACK_API_TOKEN=xoxb-your-token-here
Alternative: 1Password Integration
Use a shell function to lazy-load your token from 1Password on first use:
# Add to ~/.zshrc or ~/.bashrc
slack-chat() {
if [[ -z "$SLACK_API_TOKEN" ]]; then
export SLACK_API_TOKEN="$(op read 'op://Personal/slck/api_token')"
fi
command slck "$@"
}
Or create an alias that always fetches fresh:
alias slack-chat='SLACK_API_TOKEN="$(op read '\''op://Personal/slck/api_token'\'')" slck'
Replace op://Personal/slck/api_token with your 1Password secret reference.
Required Scopes
The manifest above includes these scopes:
Scope
Purpose
channels:read
List public channels, get channel info
channels:history
Read message history from public channels
channels:manage
Create, archive, set topic/purpose, invite users
chat:write
Send, update, delete messages
groups:read
List private channels
groups:history
Read message history from private channels
reactions:write
Add/remove reactions
team:read
Get workspace info
users:read
List users, get user info
search:read
Search messages and files (user token only)
Token Types
This CLI supports two types of Slack tokens:
Token Type
Prefix
Commands
How to Get
Bot token
xoxb-
channels, users, messages, workspace
OAuth & Permissions → Bot User OAuth Token
User token
xoxp-
search
OAuth & Permissions → User OAuth Token
Most commands use the bot token. Search commands require a user token.
Setting up both tokens:
# Set bot token (for channels, users, messages, workspace)
slck config set-token xoxb-your-bot-token
# Set user token (for search)
slck config set-token xoxp-your-user-token
The set-token command automatically detects the token type and stores it appropriately.
OAuth & Permissions → User Token Scopes → Add search:read
Reinstall app to workspace (if already installed)
Copy the User OAuth Token (starts with xoxp-)
Environment variables:
Variable
Token Type
Description
SLACK_API_TOKEN
Bot
Bot token for most commands
SLACK_USER_TOKEN
User
User token for search commands
Global Flags
These flags are available on all commands:
Flag
Short
Default
Description
--output
-o
text
Output format: text, json, or table
--no-color
false
Disable colored output
--as-user
false
Use user token
--as-bot
false
Use bot token
--version
-v
Show version information
--help
-h
Show help for any command
Choosing Between Bot and User Tokens
By default, all commands other than search use your bot token. You can set the SLCK_AS_USER env var to true to make your user token the default. You can also use flags to specify which token to use for any specific command (and this will override the default behavior set by your env var).
# Send a message as yourself (using user token)
slck messages send --as-user C1234567890 "Hey team!"
# Set default to user token via environment variable
export SLCK_AS_USER=true
slck messages send C1234567890 "Uses user token by default"
# If the default is user token, you can override back to bot token for a specific command
export SLCK_AS_USER=true
slck messages send --as-bot C1234567890 "Uses bot token"
Usage
Channels
# List all channels
slck channels list
# List with options
slck channels list --types public_channel,private_channel # Include private channels
slck channels list --limit 50 # Limit results
slck channels list --exclude-archived=false # Include archived channels
# Get channel info
slck channels get C1234567890
# Create a channel
slck channels create my-new-channel
slck channels create private-channel --private
# Archive/unarchive
slck channels archive C1234567890
slck channels unarchive C1234567890
# Set topic/purpose
slck channels set-topic C1234567890 "New topic"
slck channels set-purpose C1234567890 "Channel purpose"
# Invite users
slck channels invite C1234567890 U1111111111 U2222222222
Channels Command Reference
Command
Flags
Description
list
--types, --limit, --exclude-archived
List channels
get
Get channel details
create
--private
Create a channel
archive
--force
Archive a channel (prompts for confirmation)
unarchive
Unarchive a channel
set-topic
Set channel topic
set-purpose
Set channel purpose
invite ...
Invite users to channel
Users
# List all users
slck users list
slck users list --limit 50
# Get user info
slck users get U1234567890
# Search users
slck users search "john"
slck users search "john@company.com" --field email
slck users search "John Smith" --field display_name
slck users search "bot" --include-bots
Users Command Reference
Command
Flags
Description
list
--limit
List all users
get
Get user details
search
--limit, --field, --include-bots
Search users by name, email, or display name
Users Search Flags
Flag
Default
Description
--limit
1000
Maximum users to search through
--field
all
Search field: all, name, email, display_name
--include-bots
false
Include bot users in results
Messages
# Send a message (uses Block Kit formatting by default)
slck messages send C1234567890 "Hello, *world*!"
# Send from stdin (use "-" as text argument)
echo "Hello from stdin" | slck messages send C1234567890 -
cat message.txt | slck messages send C1234567890 -
# Send plain text (no formatting)
slck messages send C1234567890 "Plain text" --simple
# Send with custom Block Kit blocks
slck messages send C1234567890 "Fallback" --blocks '[{"type":"section","text":{"type":"mrkdwn","text":"*Bold*"}}]'
# Reply in a thread
slck messages send C1234567890 "Thread reply" --thread 1234567890.123456
# Update a message
slck messages update C1234567890 1234567890.123456 "Updated text"
slck messages update C1234567890 1234567890.123456 "Plain update" --simple
# Delete a message
slck messages delete C1234567890 1234567890.123456
# Get channel history
slck messages history C1234567890
slck messages history C1234567890 --limit 50
slck messages history C1234567890 --oldest 1234567890.000000 # After this time
slck messages history C1234567890 --latest 1234567890.000000 # Before this time
# Get thread replies
slck messages thread C1234567890 1234567890.123456
slck messages thread C1234567890 1234567890.123456 --limit 50
# Add/remove reactions
slck messages react C1234567890 1234567890.123456 thumbsup
slck messages unreact C1234567890 1234567890.123456 thumbsup
Messages Command Reference
Command
Flags
Description
send
--thread, --blocks, --simple
Send a message (use - for stdin)
update
--blocks, --simple
Update a message
delete
--force
Delete a message (prompts for confirmation)
history
--limit, --oldest, --latest
Get channel history
thread
--limit
Get thread replies
react
Add reaction
unreact
Remove reaction
Search
> Note: Search requires a user token (xoxp-*). See Token Types.
These flags provide an alternative to using modifiers in the query string:
Flag
Description
--scope
Search scope: all, public, private, dm, mpim
--in
Filter by channel (e.g., #general or general)
--from
Filter by user (e.g., @alice or alice)
--after
Content after date (YYYY-MM-DD)
--before
Content before date (YYYY-MM-DD)
--has-link
Messages containing links
--has-reaction
Messages with reactions
--type
File type filter (files only, e.g., pdf, image)
--has-pin
Files that are pinned (files only)
Workspace
# Get workspace info
slck workspace info
Config
# Set API token (interactive prompt)
slck config set-token
# Set API token directly
slck config set-token xoxb-your-token-here
# Show current config status
slck config show
# Delete stored token
slck config delete-token
Config Command Reference
Command
Flags
Description
set-token [token]
Set API token (auto-detects bot/user type)
show
Show current configuration status
delete-token
--force, --type
Delete stored token(s)
test
Test authentication for configured tokens
The delete-token command accepts a --type flag:
--type bot - Delete only the bot token
--type user - Delete only the user token
--type all - Delete both tokens (default)
Output Formats
All commands support multiple output formats via the --output (or -o) flag:
# Default text output
slck channels list
# JSON output (for scripting)
slck channels list --output json
slck users get U1234567890 -o json
# Table output (aligned columns)
slck channels list --output table
User token for search (overrides stored user token)
SLCK_AS_USER
Set to true or 1 to default to user token instead of bot token
NO_COLOR
Disable colored output when set
XDG_CONFIG_HOME
Custom config directory (default: ~/.config)
Known Limitations
Unarchiving Channels
Bot tokens (xoxb-) cannot unarchive channels due to a Slack API limitation. When a channel is archived, the bot is automatically removed from it, and bot tokens require membership to unarchive.