You must enable javascript in order to use Slack. You can do this in your browser settings.

Commands

The command line interface allows you to interact with your next generation apps via the command line.

Running slack help will display available commands in your terminal window.

The following is a comprehensive guide to the Slack CLI commands, subcommands, and their respective parameters and flags. Use commands like so (unless otherwise noted):

  slack <command> <subcommand> [flags]

To view global flags and each subcommand's flags, run the following in your terminal:

  slack <subcommand> --help

Overview

Command Subcommands Description
app delete install list Install, uninstall, and list workspaces that installed the app.
auth list login logout revoke token Add and remove local workspace authorizations.
collaborator add list remove Manage app collaborators.
create Create a Slack project.
datastore delete get put query update Query an App Datastore.
deno Run the deno command with workspace auth tokens.
doctor Checks and report on relevant system dependencies.
env add list remove Add, remove, and list environment variables.
external-auth add-secret add remove select-auth Add and remove external authorizations and client secrets for providers in your app.
feedback Share feedback about your experience.
function distribute Manage who can view and use functions.
help Help about any command.
manifest info validate Display app manifest.
platform activity deploy run Deploy and run apps on the Slack Platform.
samples List and create an app from the available samples.
trigger access create delete info list update List details of triggers.
upgrade Check for available updates to the CLI and SDK.
version Print the version number.

Global flags

Flag Description
--app <string> Use a specific app ID or environment.
--config-dir <string> Use a custom path for system config directory.
-e, --experiment <strings> Use the experiment(s) in the command.
-f, --force Ignore warnings and continue executing command.
h, --help Help for slack commands. Use this flag with any command (e.g. slack create --help) for more information about a specific command.
no-color Remove styles and formatting from outputs.
-s, --skip-update Skip checking for the latest version of the CLI.
-t, --token <token> Pass the service token used by requests requiring authentication.
-v, --verbose Print debug logging and additional info.
-w, --workspace <string> Select workspace or organization by domain name or team ID.

App

Install, uninstall, and list workspaces that installed the app.

Subcommand Description
delete Deletes the app.
install Install the app to a workspace or organization.
list List all workspaces or organizations that have installed the app.

delete

Uninstall the app from the workspace or organization and permanently delete the app and all of its data.

Flag Description
-h, --help Help for uninstall

install

Install the app to a workspace.

Flag Description
-h, --help Help for install
--org-workspace-grant <string> Grant access to a specific org workspace ID ('all' grants all workspaces in the org)

list

List all workspaces that have installed the app.

Flag Description
-h, --help Help for list

Auth

Add and remove local workspace authorizations.

Subcommand Description
list List all authorized accounts.
login Log in to a Slack account.
logout Log out of a workspace.
revoke Delete a service token.
token Get the slackauthticket to copy and paste into your workspace to exchange for the service token.

list

List all authorized accounts.

Flag Description
-h, --help Help for list

login

Log in to a Slack account.

Flag Description
--challenge <string> Provide the challenge for the pre-authed login
-h, --help Help for login
--no-prompt Create a ticket for collecting a challenge code
--ticket <string> Provide the auth ticket value
--token <string> Collect a service token

logout

Log out of a workspace.

Flag Description
-a, --all Log out of all workspaces
-h, --help Help for logout

revoke

Delete a service token.

Flag Description
-h, --help Help for logout

token

Get the slackauthticket to copy and paste into your workspace to exchange for the service token.

Flag Description
-h, --help Help for logout

Collaborator

Manage app collaborators.

Subcommand Description
add Add a collaborator to your app
list List all collaborators of an app
remove Remove a collaborator from an app

add

Add a collaborator to your app by Slack email address or user ID.

slack collaborator add <email|user_id> [flags]
Flag Description
-h, --help Help for add

list

List all collaborators of an app.

Flag Description
-h, --help Help for list

remove

Remove a collaborator from an app by Slack email address or user ID.

slack collaborator remove <email|user_id> [flags]
Flag Description
-h, --help Help for remove

Create

Create a Slack project on your local machine with an optional template.

slack create [name] [flags]
Flag Description
-b, --branch <string> Name of git branch to checkout
-h, --help Help for create
-t, --template <string> Template URL for your app

Datastore

Query an App Datastore. Useful for auditing your datastore and testing your queries.

Subcommand Description
delete Delete an item from a datastore.
get Get an item from a datastore.
put Create or replace an item in a datastore. Will overwrite entire datastore item.
query Query an app's datastore.
update Create or update an item in a datastore. Will only overwrite specified individual fields.

For Windows users
When using Windows PowerShell, you must use a backslash to escape each double quotation mark within the datastore JSON payload, or use Powershell's built-in ConvertTo-Json cmdlet.

delete

Delete an item from a datastore.

slack datastore delete <query> [flags]
Flag Description
-h, --help Help for delete
Example

The delete operation takes a primary key and deletes an item as in the following example.

On MacOS & Linux:

slack datastore delete '{ "datastore": "running_datastore", "id": "50" }'

On Windows:

slack datastore delete ('{"datastore":"running_datastore", "id":"50"}' | ConvertTo-JSON)

You'll see the following in your terminal:

πŸŽ‰  Deleted from datastore: running_datastore

primary_key: 50
To inspect the datastore after updates, run slack datastore query [expression]

get

Get an item from a datastore.

slack datastore get <query> [flags]
Flag Description
-h, --help Help for get
--output <string> Output format: text, json (Default: text) (default "text")
Example

The get command is used to retrieve a single item by its primary key. Below is an example.

On MacOS & Linux:

slack datastore get '{ "datastore": "running_datastore", "id": "50" }'

On Windows:

slack datastore get ('{"datastore":"running_datastore", "id":"50"}' | ConvertTo-JSON)

You'll see the following in your terminal:

πŸŽ‰  Get from Datastore: running_datastore

{
  "distance": 26.2,
  "id": "50",
  "rundate": "2023-03-19",
  "runner": "ABCD1234EFG"
}
To inspect the datastore after updates, run slack datastore get [expression]

put

Create or replace an item in a datastore. Will overwrite entire datastore item.

slack datastore put [item details] [flags]
Flag Description
-h, --help Help for put
Example

Let's use the datastore we defined in the Virtual Running Buddies sample app to add an item to the datastore. Given our datastore definition:

// datastores/run_data.ts
import { DefineDatastore, Schema } from "deno-slack-sdk/mod.ts";

export const RUN_DATASTORE = "running_datastore";

const RunningDatastore = DefineDatastore({
  name: RUN_DATASTORE,
  primary_key: "id",
  attributes: {
    id: {
      type: Schema.types.string,
    },
    runner: {
      type: Schema.slack.types.user_id,
    },
    distance: {
      type: Schema.types.number,
    },
    rundate: {
      type: Schema.slack.types.date,
    },
  },
});

export default RunningDatastore;

The put request can look like:

On MacOS & Linux:

slack datastore put '{ "datastore": "running_datastore", "item": { "id": "50", "runner": "ABCD1234EFG", "distance": "26.2", "rundate": "2023-03-19"} }'

On Windows:

slack datastore put ('{"datastore": "running_datastore", "item": { "id": "50", "runner": "ABCD1234EFG", "distance": "26.2", "rundate": "2023-03-19"} }' | ConvertTo-JSON)

You'll see the following in your terminal:

πŸŽ‰  Stored below record in the datastore: running_datastore

{
  "distance": 26.2,
  "id": "50",
  "rundate": "2023-03-19",
  "runner": "ABCD1234EFG"
}
To inspect the datastore after updates, run slack datastore query [expression]

Be sure to double-check that the item's property names are correct when executing the put command; if they are not, they will be ignored. If the API call is otherwise successful, no error code will be returned, and you'll have some garbage data on your hands.

Replacing data is done in the same way as creating data: simply provide the primary key of the item you'd like to replace.

query

Query an app's datastore.

slack datastore query [expression] [flags]
Flag Description
-h, --help Help for query
--output <string> Output format: text, json (Default: text) (default "text")
Example

Use the query command when you're looking for a number of items, or when you don't know the ID of a particular item.

✨ To learn more about the language used for making queries, check out querying the datastore.

Let's check out what a query for runs logged on a certain date (March 19th, 2023) looks like:

On MacOS & Linux:

slack datastore query '{ "datastore": "running_datastore", "expression": "rundate = :rundate", "expression_values": {":rundate": "2023-03-19"} }'

On Windows:

slack datastore query ('{"datastore":"running_datastore", "expression":"rundate = :rundate", "expression_values":{":rundate":"2023-03-19"} }' | ConvertTo-JSON)

You'll see the following in your terminal:

πŸŽ‰  Retrieved 1 items from datastore: running_datastore

{
  "distance": 26.3,
  "id": "50",
  "rundate": "2023-03-19",
  "runner": "ABCD1234EFG"
}
To create or update existing items run slack datastore put [item]

If you were to run this command without any expression, as in the following example:

On MacOS & Linux:

slack datastore query '{"datastore": "running_datastore"}'

On Windows:

slack datastore query ('{"datastore": "running_datastore"}' | ConvertTo-JSON)

It would return all of the items in the datastore. Be careful though, as you could end up thinking you've lost data, when it could actually just be on another page.

update

Create or update an item in a datastore. Will only overwrite specified individual fields.

Flag Description
-h, --help Help for update
Example

Unlike the put command, which will overwrite an entire datastore item, the update command will only overwrite the individual fields included in the command. Below is an example.

On MacOS & Linux:

slack datastore update '{ "app_id": "UVW987XYZ65", "datastore": "running_datastore", "item": { "id": "50", "runner": "ABCD1234EFG", "distance": "26.3", "rundate": "2023-03-19"} }'

On Windows:

slack datastore update ('{ "app_id":"UVW987XYZ65", "datastore":"running_datastore", "item": {"id":"50", "runner":"ABCD1234EFG", "distance":"26.3", "rundate":"2023-03-19"} }' | ConvertTo-JSON)

You'll see the following in your terminal:

πŸŽ‰  Stored below record in the datastore: running_datastore

{
  "distance": 26.3,
  "id": "50",
  "rundate": "2023-03-19",
  "runner": "ABCD1234EFG"
}
To inspect the datastore after updates, run slack datastore query [expression]

Deno

Run a deno command, evaluate a script, or create a REPL environment. Workspace tokens will be mapped to the DENO_AUTH_TOKENS environment variable.

The deno command is a bit different than the others listed here. This is how you use it:

    deno [OPTIONS] [SUBCOMMAND]
Option Description
-h, --help Print help information
-q, --quiet Suppress diagnostic output
--unstable Enable unstable features and APIs
-V, --version Print version information

The flags for each subcommand can be found by running the following in your terminal window:

slack deno <subcommand> --help
Subcommand Description
bench Run benchmarks
bundle Bundle module and dependencies into single file
cache Cache the dependencies
check Type-check the dependencies
compile UNSTABLE: Compile the script into a self contained executable
completions Generate shell completions
coverage Print coverage reports
doc Show documentation for a module
eval Eval script
fmt Format source files
help Print this message or the help of the given subcommand(s)
info Show info about cache or info related to source file
init Initialize a new project
install Install script as an executable
lint Lint source files
lsp Start the language server
repl Read Eval Print Loop
run Run a JavaScript or TypeScript program
task Run a task defined in the configuration file
test Run tests
types Print runtime TypeScript declarations
uninstall Uninstall a script previously installed with deno install
upgrade Upgrade deno executable to given version
vendor Vendor remote modules into a local directory

The Slack CLI and Deno support the standard, proxy-related environment variables. Proxy configuration is read from the environment variables HTTP_PROXY, HTTPS_PROXY and NO_PROXY. To use these variables, ensure you have the minimum Deno version of 1.28. You can check which version you have by running slack deno --version in your terminal window. All of the supported environment variables are listed here:

Environment variable Description
DENO_AUTH_TOKENS A semi-colon separated list of bearer tokens and hostnames to use when fetching remote modules from private repositories (e.g. "abcde12345@deno.land;54321edcba@github.com")
DENO_TLS_CA_STORE Comma-separated list of order dependent certificate stores. Possible values: "system", "mozilla". Defaults to "mozilla"
DENO_CERT Load certificate authority from PEM encoded file
DENO_DIR Set the cache directory
DENO_INSTALL_ROOT Set deno install's output directory (defaults to $HOME/.deno/bin)
DENO_NO_PROMPT Set to disable permission prompts on access (alternative to passing --no-prompt on invocation)
DENO_NO_UPDATE_CHECK Set to disable checking if a newer Deno version is available
DENO_WEBGPU_TRACE Directory to use for wgpu traces
DENO_JOBS Number of parallel workers used for the --parallel flag with the test subcommand. Defaults to number of available CPUs.
HTTP_PROXY Proxy address for HTTP requests (module downloads, fetch)
HTTPS_PROXY Proxy address for HTTPS requests (module downloads, fetch)
NPM_CONFIG_REGISTRY URL to use for the npm registry
NO_COLOR Set to disable color
NO_PROXY Comma-separated list of hosts which do not use a proxy (module downloads, fetch)

Doctor

Check and report on relevant system (and sometimes app) dependencies.

Flag Description
-h, --help Help for doctor

Env

Add, remove, and list environment variables.

This command is for deployed apps only. To store local environment variables, use the .env file.

Subcommand Description
add Add an environment variable to the app.
list List all environment variables for the app.
remove Remove an environment variable from the app.

add

Add an environment variable to the app, prompting for a name or value if none is provided.

slack env add [name] [value] [flags]
Flag Description
-h, --help Help for add

list

List all environment variables for the app.

Flag Description
-h, --help Help for list

remove

Remove an environment variable from the app, selecting from set variables if none is provided.

slack env remove [name] [flags]
Flag Description
-h, --help Help for remove

External-auth

Add and remove external authorizations and client secrets for providers in your app.

Subcommand Description
add Initiate the OAuth2 flow for a provider in your app.
add-secret Add the client secret for a provider in your app.
remove Remove provider token(s) from your app.
select-auth Select a unique auth for each of the workflows in your app.

add

Initiate the OAuth2 flow for a provider in your app.

Flag Description
-h, --help Help for add
-p, --provider <string> External Auth Provider Key

add-secret

Add the client secret for a provider in your app. This secret will be used when initiating the OAuth2 flow

slack external-auth add-secret --provider provider_key --secret client_secret [flags]
Flag Description
-h, --help Help for add-secret
-p, --provider <string> Specifies an external auth provider to add a secret
-x, --secret <string> External auth client secret for the specified provider

remove

Remove provider token(s) stored by your app.

Note: Existing tokens are only removed from your app, but not revoked! Tokens may be revoked from the provider's developer console or via APIs.

Flag Description
-a, --all Remove tokens for all providers
-h, --help Help for remove
-p, --provider <string> External Auth Provider Key

select-auth

Select a unique auth for each of the workflows in your app.

Flag Description
-h, --help Help for remove

Feedback

Help us make the Slack Platform better by completing the feedback survey.

Flag Description
-h, --help Help for feedback

Function

Manage who can view and use functions.

Subcommand Description
distribute Manage who can view functions published by your app

distribute

Manage who can view functions published by your app.

Flag Description
-A, --app-collaborators Grant permission to only those collaborating on your app
-E, --everyone Grant permission to everyone in your workspace
-G, --grant Grant permission to --users to use the function identified by --name
-h, --help Help for distribute
-I, --info Check who has access to the function identified by --name
-R, --revoke Revoke permission for --users to use the function identified by --name
-U, --users <string> A comma-separated list of one or more Slack user IDs

Help

Help provides help for any command in the application. Use slack help [path to command] for full details.

Flag Description
-h, --help Help for help

Manifest

Displays app manifest when run in a valid project directory.

Subcommand Description
info Displays the app manifest when run in a project directory.
validate Validates the app manifest generated from a valid project directory.

info

Displays the app manifest when run in a valid project directory.

Flag Description
-h, --help Help for info

validate

Validates the app manifest generated from a valid project directory.

Flag Description
-h, --help Help for validate

Platform

Deploy and run apps on the Slack Platform.

Subcommand Description
activity Display the app activity logs from the Slack Platform.
deploy Deploy the app to the Slack Platform.
run Start a local server to develop and run the app locally.

activity

Display the app activity logs from the Slack Platform.

Flag Description
--component <string> Component type to filter
--component-id <string> Component ID (function ID, or workflow ID) to filter
--event <string> Event type to filter
-h, --help Help for activity
--idle <int> Time in minutes to continue without results before exiting (default 5)
-i, --interval <int> Polling interval in seconds (default 3)
--level <string> Minimum level to display (trace, debug, info, warn, error, fatal) (default "info")
--limit <int> Limit the amount of logs retrieved (default 100)
--max-date-created <int> Maximum timestamp to filter (Unix timestamp in microseconds)
--min-date-created <int> Minimum timestamp to filter (Unix timestamp in microseconds)
--source <string> Source (slack or developer) to filter
-t, --tail Continuously poll for new activity
--trace-id <string> Trace ID to filter

deploy

Deploy the app to the Slack Platform.

Flag Description
-f, --force Ignore warnings and continue deploying
-h, --help Help for deploy
--org-workspace-grant <string> Grant access to a specific org workspace ID ('all' grants all workspaces in the org)

run

Start a local server to develop and run the app locally while watching for file changes.

Flag Description
--activity-level <string> Activity level to display (trace, debug, info, warn, error, fatal) (default "info")
--cleanup Uninstall the local app after exiting
-h, --help Help for run
--hide-triggers Do not list triggers and skip trigger creation prompts
--no-activity Hide Slack Platform log activity
--org-workspace-grant Allow users in the org workspace to access the app ('all' to grant access to all workspaces in the org)

Samples

List and create an app from the available samples.

Flag Description
-h, --help Help for samples

Trigger

List details of existing triggers.

Subcommand Description
access Manage who can run your triggers.
create Create a trigger for a workflow.
delete Deletes an existing trigger.
info Get details for a specific trigger.
list List details of existing triggers.
update Updates an existing trigger.

access

Manage who can run your triggers

slack trigger access --trigger-id <id> [flags]
Flag Description
-A, --app-collaborators Grant permission to only those collaborating on your app
-C, --channels <string> A comma-separated list of one or more Slack channel IDs
-E, --everyone Grant permission to everyone in your workspace
-G, --grant Grant permission to --users or --channels to run the trigger identified by --trigger-id
-h, --help Help for access
-I, --info Check who has access to the trigger identified by --trigger-id
-O, --organizations <string> A comma-separated list of one or more Slack organization IDs
-R, --revoke Revoke permission for --users or --channels to run the trigger identified by --trigger-id
-T, --trigger-id <string> The ID of the trigger
-U, --users <string> A comma-separated list of one or more Slack user IDs
-W, --workspaces <string> A comma-separated list of one or more Slack workspace IDs

create

Creates a trigger which can be used to initiate a workflow execution.

slack trigger create --workflow <reference> [flags]
Flag Description
--description <string> The description of this trigger
-h, --help Help for create
--interactivity slack#/types/interactivity When used with --workflow, adds a slack#/types/interactivity parameter to the trigger with the name specified by --interactivity-name
--interactivity-name <string> When used with --interactivity, specifies the name of the interactivity parameter to use (default "interactivity")
--title <string> The title of this trigger (default "My Trigger")
--trigger-def <string> Path to a JSON file containing the trigger definition. If provided, other flags setting trigger properties are ignored.
--workflow #/workflows/<workflow callback id> A reference to the workflow to execute, formatted like #/workflows/

delete

Deletes an existing trigger.

slack trigger delete --trigger-id <id> [flags]
Flag Description
-h, --help Help for delete
--trigger-id <string> The ID of the trigger

info

Get details for a specific trigger.

slack trigger info --trigger-id <id> [flags]
Flag Description
-h, --help Help for info
--trigger-id <string> The ID of the trigger

list

List details of existing triggers.

Flag Description
-h, --help Help for list
--limit <n> Enter a number to limit paginated results (default is 4).
--type=<string> Specifies which type of triggers will be listed. Input can be all, shortcut, event, webhook, scheduled, and external types.

update

Updates an existing trigger with the provided definition. Only supports full replacement, no partial update.

slack trigger update --trigger-id <id> --workflow <reference> [flags]
Flag Description
--description <string> The description of this trigger
-h, --help Help for update
--interactivity slack#/types/interactivity When used with --workflow, adds a slack#/types/interactivity parameter to the trigger with the name specified by --interactivity-name
--interactivity-name <string> When used with --interactivity, specifies the name of the interactivity parameter to use (default "interactivity")
--title <string> The title of this trigger (default "My Trigger")
--trigger-def <string> Path to a JSON file containing the trigger definition. If provided, other flags setting trigger properties are ignored.
--trigger-id <string> The ID of the trigger to update
--workflow #/workflows/<workflow callback id> A reference to the workflow to execute, formatted like #/workflows/

Upgrade

Checks for available updates to the CLI or the SDKs of a project. If there are any, then you will be prompted to upgrade.

Changes between versions are logged at the Slack next generation changelog.

Flag Description
-h, --help Help for upgrade

Version

All software has versions. This is ours.

Flag Description
-h, --help Help for version

✨ To start creating an app, check out the create or remove an app page.


Have 2 minutes to provide some feedback?

We'd love to hear about your experience building modular Slack apps. Please complete our short survey so we can use your feedback to improve.