1NIP-862======34Relay Management API5--------------------67`draft` `optional`89Relays 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.1011When 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:1213```json14{15 "method": "<method-name>",16 "params": ["<array>", "<of>", "<parameters>"]17}18```1920Then it should return a response in the format2122```json23{24 "result": {"<arbitrary>": "<value>"},25 "error": "<optional error message, if the call has errored>"26}27```2829This is the list of **methods** that may be supported:3031* `supportedmethods`:32 - params: `[]`33 - result: `["<method-name>", "<method-name>", ...]` (an array with the names of all the other supported methods)34* `banpubkey`:35 - params: `["<32-byte-hex-public-key>", "<optional-reason>"]`36 - result: `true` (a boolean always set to `true`)37* `unbanpubkey`:38 - params: `["<32-byte-hex-public-key>", "<optional-reason>"]`39 - result: `true` (a boolean always set to `true`)40* `listbannedpubkeys`:41 - params: `[]`42 - result: `[{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]`, an array of objects43* `allowpubkey`:44 - params: `["<32-byte-hex-public-key>", "<optional-reason>"]`45 - result: `true` (a boolean always set to `true`)46* `unallowpubkey`:47 - params: `["<32-byte-hex-public-key>", "<optional-reason>"]`48 - result: `true` (a boolean always set to `true`)49* `listallowedpubkeys`:50 - params: `[]`51 - result: `[{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]`, an array of objects52* `createrole`:53 - params: `[id, label, description, color, order]`54 - result: `true` (boolean true)55* `editrole`:56 - params: `[id, label, description, color, order]`57 - result: `true` (boolean true)58* `deleterole`:59 - params: `[id]`60 - result: `true` (boolean true)61* `assignrole`:62 - params: `["<32-byte-hex-public-key>", "<role-id>"]`63 - result: `true` (a boolean always set to `true`)64* `unassignrole`:65 - params: `["<32-byte-hex-public-key>", "<role-id>"]`66 - result: `true` (a boolean always set to `true`)67* `listeventsneedingmoderation`:68 - params: `[]`69 - result: `[{"id": "<32-byte-hex>", "reason": "<optional-reason>"}]`, an array of objects70* `allowevent`:71 - params: `["<32-byte-hex-event-id>", "<optional-reason>"]`72 - result: `true` (a boolean always set to `true`)73* `banevent`:74 - params: `["<32-byte-hex-event-id>", "<optional-reason>"]`75 - result: `true` (a boolean always set to `true`)76* `listbannedevents`:77 - params: `[]`78 - result: `[{"id": "<32-byte hex>", "reason": "<optional-reason>"}, ...]`, an array of objects79* `changerelayname`:80 - params: `["<new-name>"]`81 - result: `true` (a boolean always set to `true`)82* `changerelaydescription`:83 - params: `["<new-description>"]`84 - result: `true` (a boolean always set to `true`)85* `changerelayicon`:86 - params: `["<new-icon-url>"]`87 - result: `true` (a boolean always set to `true`)88* `allowkind`:89 - params: `[<kind-number>]`90 - result: `true` (a boolean always set to `true`)91* `disallowkind`:92 - params: `[<kind-number>]`93 - result: `true` (a boolean always set to `true`)94* `listallowedkinds`:95 - params: `[]`96 - result: `[<kind-number>, ...]`, an array of numbers97* `blockip`:98 - params: `["<ip-address>", "<optional-reason>"]`99 - result: `true` (a boolean always set to `true`)100* `unblockip`:101 - params: `["<ip-address>"]`102 - result: `true` (a boolean always set to `true`)103* `listblockedips`:104 - params: `[]`105 - result: `[{"ip": "<ip-address>", "reason": "<optional-reason>"}, ...]`, an array of objects106107### Authorization108109The request must contain an `Authorization` header with a valid [NIP-98](./98.md) event, except the `payload` tag is required. The `u` tag is the relay URL.110111If `Authorization` is not provided or is invalid, the endpoint should return a 401 response.