Command line

CLI Entry point

Shlink provides a CLI entry point which exposes a set of commands to perform a variety of operations. From creating, updating or listing short URLs, to manage API keys or handle your domains.

You can treat it as an alternative interface to manage your Shlink instance, that will be available out of the box.

The entry point is the bin/cli script, and you will usually run it as bin/cli [command] [arguments]. It is recommended to symlink the bin/cli script to a global shlink script, so that you can run the CLI from anywhere with shlink [command] [arguments].

Commands

Commands in Shlink’s CLI entry point are contextually namespaced in api-key, domain, short-url, tag and visit.

By running the bin/cli script with no arguments, you will see the full list of commands with a description for each one of them.

Running any command with the -h/--help flag will display an extended help for that specific command, showing the list of arguments, and a descriptive explanation on how to use it.

This is the full list of commands exposed by Shlink’s CLI entry point:

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
      --silent          Do not output any message
  -q, --quiet           Only errors are displayed. All other output is suppressed
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  completion                      Dump the shell completion script
  help                            Display help for a command
  list                            List commands
 api-key
  api-key:delete                  Deletes an API key by name
  api-key:disable                 Disables an API key by name or plain-text key (providing a plain-text key is DEPRECATED)
  api-key:generate                Generate a new valid API key.
  api-key:initial                 Tries to create initial API key
  api-key:list                    Lists all the available API keys.
  api-key:rename                  Renames an API key by name
 domain
  domain:list                     List all domains that have been ever used for some short URL
  domain:redirects                Set specific "not found" redirects for individual domains.
  domain:visits                   Returns the list of visits for provided domain.
 integration
  integration:matomo:send-visits  Send existing visits to the configured matomo instance
 short-url
  short-url:create                Generates a short URL for provided long URL and returns it
  short-url:delete                Deletes a short URL
  short-url:delete-expired        Deletes all short URLs that are considered expired, because they have a validUntil date in the past
  short-url:edit                  Edit an existing short URL
  short-url:import                Allows to import short URLs from third party sources
  short-url:list                  List all short URLs
  short-url:manage-rules          Set redirect rules for a short URL
  short-url:parse                 Returns the long URL behind a short code
  short-url:visits                Returns the detailed visits information for provided short code
  short-url:visits-delete         Deletes visits from a short URL
 tag
  tag:delete                      Deletes one or more tags.
  tag:list                        Lists existing tags.
  tag:rename                      Renames one existing tag.
  tag:visits                      Returns the list of visits for provided tag.
 visit
  visit:download-db               Checks if the GeoLite2 db file is too old or it does not exist, and tries to download an up-to-date copy if so.
  visit:locate                    Resolves visits origin locations. It implicitly downloads/updates the GeoLite2 db file if needed.
  visit:non-orphan                Returns the list of non-orphan visits.
  visit:orphan                    Returns the list of orphan visits.
  visit:orphan-delete             Deletes all orphan visits