Skip to content

CLI client

Notifly-CLI is a small command-line utility notifly for sending messages to your channel directly from the terminal, cron jobs, and shell scripts. It stores the token and server URL in a config, can read the message from stdin, and can watch the output of an arbitrary command (watch) and send updates.

The utility is not required to send notifications — the same can be done with curl (see REST API). The CLI simply saves you from repeating the token and URL in every command.

Download the binary for your OS and make it executable:

Окно терминала
# Linux x86-64
curl -Lo notifly https://github.com/notifly/cli/releases/latest/download/notifly-cli-linux-amd64
chmod +x notifly

Check that it works:

Окно терминала
$ notifly version
Version: 2.2.0
Commit: 95cc125e39f805a1369b0c746c8bf3af15797a57
BuildDate: 2025-09-25-16:27:04

If you wish, place the binary in a directory on your $PATH:

Окно терминала
sudo mv notifly /usr/local/bin/notifly

You need Go. In the cli/ directory build the binary directly:

Окно терминала
go build -o notifly cli.go

Or use make build — it will build a set of binaries for all platforms (Linux/macOS/Windows, amd64/386/arm64/arm) into the build/ subdirectory.

There is a Dockerfile included (minimal Alpine image). Build the image and run notifly in a container, mounting the config:

Окно терминала
docker build -t notifly/cli .
docker run -it -v "$PWD/cli.json:/etc/gotify/cli.json" \
notifly/cli:latest push -p 5 "Тест из Notifly CLI"
notifly init # мастер настройки (запишет конфиг)
notifly version # показать версию (алиас: v)
notifly config # показать текущий конфиг
notifly push # отправить сообщение (алиас: p)
notifly watch # следить за выводом команды и слать изменения
notifly help # помощь по командам (алиас: h)

Help for a specific command: notifly help push, notifly help watch.

The easiest way to get started is the init wizard. It will ask for the server URL, token and default priority, check the connection and write the config.

Окно терминала
$ notifly init
Notifly URL: https://notifly.ru
Notifly v2.7.4@2025-09-25-16:27:04
Configure an application token
1. Enter an application-token
2. Create an application token (with user/pass)
Enter 1 or 2: 1
Application Token: A4ZudDRdLT40L5X
Default Priority [0-10]: 6
Written config to: /home/user/.gotify/cli.json

At the token choice step there are two options:

  • 1 — enter an existing App token. Get it from the admin. The token must be exactly 15 characters; the utility will immediately verify it by sending a test message to the channel.
  • 2 — create an App token using a username/password. You enter a username and password (Basic Auth), the CLI creates an application with the specified name and description and saves the returned token. The username and password are not saved — only the resulting token is stored.

The default priority must be a number from 0 to 10.

init will offer to choose a path, and other commands search for the config in these locations (the first found wins):

  1. ./cli.json (next to the current directory);
  2. $XDG_CONFIG_HOME/gotify/cli.json (usually ~/.config/gotify/cli.json);
  3. ~/.gotify/cli.json;
  4. /etc/gotify/cli.json (except on Windows).

The config is just JSON. You can create it manually without running the wizard:

{
"token": "A4ZudDRdLT40L5X",
"url": "https://notifly.ru",
"defaultPriority": 6
}
FieldDescriptionExample
tokenApp token (Client token will not work)A4ZudDRdLT40L5X
urlURL of your Notifly serverhttps://notifly.ru
defaultPriorityDefault priority (0 if not set)6

To see which config is being used now:

Окно терминала
$ notifly config
Used Config: /home/user/.gotify/cli.json
URL: https://notifly.ru
Default Priority: 6
Token: A4ZudDRdLT40L5X

The message text can be provided as an argument or via stdin:

Окно терминала
notifly push my message
notifly push "моё сообщение"
echo "моё сообщение" | notifly push
notifly push < somefile

Title and priority:

Окно терминала
notifly push -t "Deploy" -p 10 "Production deployed"

Flags for the push command:

FlagPurposeDefault
-p, --priorityMessage priorityfrom defaultPriority
-t, --titleTitle (if empty — application name is used)application name
--tokenOverride App token (env: GOTIFY_TOKEN)from config
--urlOverride server URLfrom config
-q, --quietPrint nothing on successoff
--contentTypeMessage content-type, e.g. text/markdown (see msgextras)
--clickUrlURL opened when the notification is clicked (see msgextras)
--bigImageUrlURL of an image shown in the notification (see msgextras)
--disable-unescape-backslashDo not unescape \n and \t (leave them as literal text)unescapes

If -p is not specified, defaultPriority from the config is used; if that is absent — priority 0 is used.

You don’t have to keep a config — you can pass the token and URL directly on the command line or via the GOTIFY_TOKEN environment variable:

Окно терминала
notifly push --url https://notifly.ru --token A4ZudDRdLT40L5X "without config"
GOTIFY_TOKEN=A4ZudDRdLT40L5X notifly push --url https://notifly.ru "from env"

By default notifly unescapes \n and \t into real line breaks and tabs. This is convenient for multi-line messages provided as a single-line argument:

Окно терминала
notifly push -t "Report" "Line 1\nLine 2\twith tab"

To keep \n and \t as literal text — add --disable-unescape-backslash.

Markdown is enabled via --contentType:

Окно терминала
notifly push --contentType text/markdown -t "Release" "**v2.0** is ready — [changelog](https://notifly.ru)"
Окно терминала
notifly push -t "Build failed" \
--clickUrl https://ci.example.com/build/42 \
--bigImageUrl https://ci.example.com/build/42/graph.png \
"Job #42 finished with an error"

More about these fields — see the Message extras page.

watch periodically runs the given command and as soon as its output has changed compared to the previous run, sends the new output to the channel. Useful for simple ad-hoc monitoring without a separate service.

Окно терминала
notifly watch "curl -s https://api.example.com/status | jq '.state'"

By default the command runs every 2 seconds via sh -c. The title, if not set, defaults to the command itself.

Flags for the watch command:

FlagPurposeDefault
-n, --intervalPolling interval in seconds (fractional allowed)2
-p, --priorityPriorityfrom defaultPriority
-x, --execWhat to use to execute the commandsh -c
-t, --titleTitle (if empty — the command text is used)command
--tokenOverride App token (env: GOTIFY_TOKEN)from config
--urlOverride server URLfrom config
-o, --outputDetail level of the message body: short, default, longdefault

--output modes:

  • short — only the new output, without wrappers;
  • default — the new output wrapped in == BEGIN NEW OUTPUT == … == END NEW OUTPUT ==;
  • long — both old and new output (full diff in OLD/NEW blocks).

Example: watch the number of containers every 30 seconds and send a long diff:

Окно терминала
notifly watch -n 30 -o long -t "docker ps" "docker ps -q | wc -l"

If the server uses a self-signed certificate, there are environment variables:

Окно терминала
# completely disable TLS verification (insecure)
export NOTIFLY_SKIP_VERIFY_TLS=True
# or specify a custom root CA / pinned certificate
export SSL_CERT_FILE=/path/to/cert.pem

Any send performed by the CLI can be reproduced with plain curl — it’s the same REST API:

Окно терминала
curl -X POST "$NOTIFLY_URL/message" \
-H "X-Notifly-Key: A4ZudDRdLT40L5X" \
-F "title=Деплой" \
-F "priority=10" \
-F "message=Прод выкатился"

The CLI works over the same public API as everything else. Authorization — the X-Notifly-Key header with an App token (A…).

MethodPathPurposeToken
POST/messageSend a message to the channelApp token
GET/versionServer version (used by the init wizard)

Body for POST /message (JSON or form-data): message (required), title, priority (0–10), extras (for example client::display.contentType, client::notification.click.url, client::notification.bigImageUrl). Details — on the Sending messages and Message extras pages.