LinuxCommandLibrary

ntfy

Send push notifications to devices

TLDR

Send a message to the security topic

$ ntfy pub security "[Front door has been opened.]"
copy

Send with a title, priority and tags
$ ntfy publish --title="[Someone bought your item]" --priority=[high] --tags=[duck] [ebay] "[Someone just bought your item: Platypus Sculpture]"
copy

Send at 8:30am
$ ntfy pub --at=8:30am [delayed_topic] "[Time for school, sleepyhead...]"
copy

Trigger a webhook
$ ntfy trigger [my_webhook]
copy

Subscribe to a topic ( to stop listening)
$ ntfy sub [home_automation]
copy

Display help
$ ntfy --help
copy

SYNOPSIS

The ntfy command-line client provides modes for publishing, subscribing, and listening.

ntfy [OPTIONS] <TOPIC> [MESSAGE]
(Default to publish mode)

ntfy publish [OPTIONS] <TOPIC> [MESSAGE]
(Explicitly publish a message)

ntfy subscribe [OPTIONS] <TOPIC>
(Subscribe to a topic and receive messages)

ntfy listen [OPTIONS]
(Listen to all messages on a server)

PARAMETERS

-t, --topic <TOPIC>
    Specifies the topic to publish to or subscribe from. Topics are case-sensitive.

-m, --message <MESSAGE>
    The message body for a publication. If omitted, ntfy reads from stdin.

-T, --title <TITLE>
    Sets a custom title for the notification.

-p, --priority <LEVEL>
    Sets the notification priority from 1 (min) to 5 (max). Higher priority notifications may alert users more prominently.

-g, --tag <TAG>
    Adds tags to the notification for filtering or grouping. Can be specified multiple times.

-a, --attach <FILE_PATH>
    Attaches a file to the notification. The file content is base64 encoded and sent along with the message.

--filename <NAME>
    Specifies the filename for the attached file, overriding the original filename.

--json <JSON>
    Publishes a message using raw JSON payload, allowing for advanced message customization.

-s, --server <URL>
    Specifies the ntfy server URL to use (e.g., https://ntfy.sh).

-u, --user <USER>
    Provides the username for basic HTTP authentication.

-P, --password <PASS>
    Provides the password for basic HTTP authentication.

-A, --auth <TOKEN>
    Provides a bearer token for authentication.

--config <PATH>
    Specifies a custom configuration file path.

--since <TIME|ID>
    For subscriptions, receive messages since a specific time (e.g., 1h, 2023-01-01) or message ID.

DESCRIPTION

ntfy is a simple HTTP-based publish-subscribe notification service. It allows you to send push notifications to any device via a command-line interface or a web UI. It supports various platforms including Android, iOS, and web browsers, without requiring an account or exposing your private information. You can use a public server or self-host your own. It's ideal for scripting, monitoring, and general alerting, providing a robust and easy-to-use notification solution.

CAVEATS

The ntfy command-line client requires an ntfy server to operate, either a publicly available instance or a self-hosted one. Public servers may enforce rate limits and have data retention policies. While designed for security, sensitive information should still be handled with care, especially when using public servers. Notifications might be subject to network latency and reliability depends on the server's uptime.

<B>AUTHENTICATION</B>

ntfy supports various authentication methods including basic HTTP authentication (using --user and --password) and bearer tokens (with --auth). This allows securing topics and controlling who can publish or subscribe to messages on your ntfy server.

<B>SELF-HOSTING</B>

One of ntfy's core strengths is the ease of self-hosting your own server. This provides complete control over your notifications, data, and privacy, making it particularly suitable for sensitive internal alerts or environments with strict data governance policies.

<B>INTEGRATION</B>

ntfy is designed for easy integration into scripts and applications. Its simple HTTP API and intuitive command-line interface make it an ideal choice for sending alerts from cron jobs, CI/CD pipelines, monitoring systems, or custom applications. It facilitates robust notification capabilities with minimal setup overhead.

HISTORY

ntfy was created by Philipp C. Heckel and released as an open-source project. It quickly gained traction as a simple, privacy-friendly, and self-hostable notification solution, offering an alternative to more complex or proprietary services. Its development is active on GitHub, continuously adding features and improving reliability, making it a popular choice for developers and system administrators seeking a straightforward way to send push notifications.

SEE ALSO

curl(1), notify-send(1), wget(1)

Copied to clipboard