broadcast — publish events to relays
Publishes one event to the given relays and prints a per-relay result
(OK, REJECTED, or NO-RESPONSE). Accepts three kinds of input:
-
Pre-signed event JSON — sent as-is (no signer needed).
-
Unsigned event JSON or inline build (
--kind+--content) — signed with--privkeyor the activeaccounts loginidentity. -
Build a text note inline —
--kind 1 --content "..."plus a signer.
ndk broadcast [options] <relay> [relay ...]
Event source (exactly one required):
Signing:
Output control:
# publish a text note using the active account
ndk accounts login nsec nsec1... # one-time
ndk broadcast --kind 1 --content "hello from ndk cli" relay.damus.io nos.lol
# publish a text note with an explicit private key
ndk broadcast --kind 1 --content "hello" --privkey nsec1... relay.damus.io
# broadcast a pre-signed event from a file
ndk broadcast --file signed.json relay.damus.io
# broadcast a pre-signed event piped on stdin
cat signed.json | ndk broadcast --stdin relay.damus.io
# custom OK threshold and timeout
ndk broadcast --event '{...}' --consider-done 1.0 --timeout 20 \
relay.damus.io nos.lol relay.nostr.band
Exit code is 0 if at least one relay accepted the event, 1 otherwise.