Nostr Book of NIPs

NIP-86

Relay Management API

draft optional

Relays may provide an API for performing management tasks. This is made available as a JSON-RPC-like request-response protocol over HTTP, on the same URI as the relay’s websocket.

When a relay receives an HTTP(s) request with a Content-Type header of application/nostr+json+rpc to a URI supporting WebSocket upgrades, it should parse the request as a JSON document with the following fields:

{
  "method": "<method-name>",
  "params": ["<array>", "<of>", "<parameters>"]
}

Then it should return a response in the format

{
  "result": {"<arbitrary>": "<value>"},
  "error": "<optional error message, if the call has errored>"
}

This is the list of methods that may be supported:

supportedmethods

Lists the methods supported by the relay. May be customized to match permissions assigned to the authenticated user.

banpubkey

Bans a pubkey from the relay. Should automatically remove the pubkey from the allow list.

unbanpubkey

Removes a pubkey from the relay’s ban list. Should not automatically add the pubkey to the allow list.

listbannedpubkeys

Lists pubkeys banned from the relay.

allowpubkey

Adds a pubkey to the relay’s allow list. Should automatically remove the pubkey from the ban list.

unallowpubkey

Removes a pubkey from the relay’s allow list. Should not automatically add the pubkey to the ban list.

listallowedpubkeys

Lists pubkeys on the relay’s allow list.

createrole

Creates a new role.

editrole

Updates an existing role.

deleterole

Deletes a role.

assignrole

Assigns a role to a pubkey.

unassignrole

Removes a role from a pubkey.

listclaims

Lists NIP 43 invite codes currently accepted by the relay.

createclaim

Creates a new NIP 43 invite code.

deleteclaim

Revokes a NIP 43 invite code.

listeventsneedingmoderation

Lists events awaiting moderation.

allowevent

Adds an event to the relay’s allow list. Should automatically remove the event from the ban list.

unallowevent

Removes an event from the relay’s allow list. Should not automatically add the event to the ban list.

banevent

Bans an event from the relay. Should automatically remove the event from the allow list.

unbanevent

Removes an event from the relay’s ban list. Should not automatically add the event to the allow list.

listbannedevents

Lists events banned from the relay.

listallowedevents

Lists events on the relay’s allow list.

changerelayname

Changes the relay’s name.

changerelaydescription

Changes the relay’s description.

changerelayicon

Changes the relay’s icon.

allowkind

Adds an event kind to the relay’s allow list.

disallowkind

Disallows an event kind.

listallowedkinds

Lists event kinds on the relay’s allow list.

listdisallowedkinds

Lists event kinds the relay disallows.

blockip

Adds an IP address to the relay’s block list.

unblockip

Removes an IP address from the relay’s block list.

listblockedips

Lists IP addresses blocked by the relay.

Authorization

The request must contain an Authorization header with a valid NIP-98 event, except the payload tag is required. The u tag is the relay URL.

If Authorization is not provided or is invalid, the endpoint should return a 401 response.