Send a Notification with Node.js

Use the Ntfy me HTTP endpoint to post a notification with compact Node.js scripts that rely only on built-in modules. Provide your bearer token below to generate the ready-to-run examples.

Tokens must be at least 10 characters and may only include lowercase letters, numbers, and hyphens.

JSON payload with Authorization header

The example below publishes the message Test Message to the topic test using a JSON payload and Authorization header. Save the script to a file (for example send.js) and run it with node send.js on Node.js 16 or later.

The script sends the JSON payload, authenticates with a bearer token, and prints the JSON response in a readable format. JSON unlocks the full feature set of the app because it lets you control topics, message bodies, and optional metadata.

JSON payload with token field

Prefer this variant if you want to place the token inside the JSON payload instead of the Authorization header. The script keeps the request headers minimal and moves authentication into the JSON body.

Plain text payload

You can also send a plain text payload if you only need to publish a quick message.

This shortcut is convenient, but it omits JSON-specific fields. Prefer the JSON format if you want richer notifications.