Send a Notification with Go

Use the Ntfy me HTTP endpoint to post a notification with concise Go programs that only depend on the standard library. 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 program to send.go and execute it with GO111MODULE=off go run send.go so it runs outside a module.

The program 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 program 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.