2024-11-25 16:21:47 +00:00
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:
```json
{
"method": "< method-name > ",
"params": ["< array > ", "< of > ", "< parameters > "]
}
```
2025-02-01 21:58:27 +00:00
Then it should return a response in the below format:
2024-11-25 16:21:47 +00:00
```json
{
"result": {"< arbitrary > ": "< value > "},
"error": "< optional error message , if the call has errored > "
}
```
2025-02-01 21:58:27 +00:00
## Standard Methods
Here is a list of **methods** that MAY be supported:
2025-02-06 06:12:00 +00:00
* `supportedmethods` :
2025-02-03 13:49:23 +00:00
- **params:** `[]`
2025-02-03 13:54:36 +00:00
- **result:** `["<method-name>", "<method-name>", /* rest of method names... */ ]`
Extra fields MAY be sent from the relay depending on implementation.
2025-02-03 13:49:23 +00:00
---
* `stats` :
- **params:** `[]`
- **result:**
```jsonc
{
"num_connections": < number > ,
"uptime": < uptime-in-seconds > ,
"bytes_received": < number > ,
"bytes_sent": < number > ,
"num_events": < number > ,
"event_bytes": < number > ,
"num_files": < number > ,
"file_bytes": < number >
// and more...
}
```
2025-02-01 21:58:27 +00:00
2025-02-03 13:54:36 +00:00
Extra fields MAY be sent from the relay depending on implementation.
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `listeventsneedingmoderation` :
2025-02-03 13:49:23 +00:00
- **params:** `[]`
2025-02-08 12:01:32 +00:00
- **result:** `[{ "id": "<32-byte-hex>", "reason": "<optional-reason>" }, ...]`
Relay MAY return reported, muted profiles, and similar events as a result.
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `banpubkey` :
2025-02-03 13:49:23 +00:00
- **params:** `["<32-byte-hex-public-key>", "<optional-reason>"]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
2025-02-03 13:54:36 +00:00
The relay MAY remove events sent by `pubkey` and prevent new events from being written.
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `listbannedpubkeys` :
2025-02-03 13:49:23 +00:00
- **params:** `[]`
- **result:** `[{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `allowpubkey` :
2025-02-03 13:49:23 +00:00
- **params:** `["<32-byte-hex-public-key>", "<optional-reason>"]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `listallowedpubkeys` :
2025-02-03 13:49:23 +00:00
- **params:** `[]`
- **result:** `[{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `banevent` :
2025-02-03 13:49:23 +00:00
- **params:** `["<32-byte-hex-event-id>", "<optional-reason>"]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
Relay SHOULD delete and prevent re-broadcasting of event.
---
2025-02-06 06:12:00 +00:00
* `listbannedevents` :
2025-02-03 13:49:23 +00:00
- **params:** `[]`
- **result:** `[{"id": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `allowevent` :
2025-02-03 13:49:23 +00:00
- **params:** `["<32-byte-hex-event-id>", "<optional-reason>"]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `listallowedevents` :
2025-02-03 13:49:23 +00:00
- **params:** `[]`
- **result:** `[{"id": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-08 12:01:32 +00:00
* `allowkind` :
2025-02-08 12:02:15 +00:00
- **params:** `[<kind-number>]`
2025-02-03 13:49:23 +00:00
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
---
2025-02-08 12:01:32 +00:00
* `disallowkind` :
2025-02-08 12:02:15 +00:00
- **params:** `[<kind-number>]`
2025-02-03 13:49:23 +00:00
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `listdisallowedkinds` :
2025-02-03 13:49:23 +00:00
- **params:** `[]`
2025-02-08 12:03:36 +00:00
- **result:** `[<kind-number>, <another-kind-number>, /* and more... */]` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `listallowedkinds` :
2025-02-03 13:49:23 +00:00
- **params:** `[]`
2025-02-08 12:03:36 +00:00
- **result:** `[<kind-number>, <another-kind-number>, /* and more... */]` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `blockip` :
2025-02-03 13:49:23 +00:00
- **params:** `["<ip-address>", "<optional-reason>"]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `unblockip` :
2025-02-03 13:49:23 +00:00
- **params:** `["<ip-address>"]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
2025-02-03 13:49:23 +00:00
---
2025-02-01 21:58:27 +00:00
2025-02-06 06:12:00 +00:00
* `listblockedips` :
2025-02-03 13:49:23 +00:00
- **params:** `[]`
- **result:** `[{"ip": "<ip-address>", "reason": "<optional-reason>"}, ...]` (an array of objects)
2025-02-01 21:58:27 +00:00
2025-02-03 13:49:23 +00:00
---
2025-02-01 21:58:27 +00:00
2025-02-06 06:12:00 +00:00
* `grantadmin` :
2025-02-03 13:49:23 +00:00
- **params:** `["<32-byte-hex-public-key>", { "allowed_methods": [...]}]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
2025-02-03 13:54:36 +00:00
If the admin right is already granted, the allowed methods list must be rewritten.
2025-02-01 21:58:27 +00:00
---
2025-02-06 06:12:00 +00:00
* `revokeadmin` :
2025-02-03 13:49:23 +00:00
- **params:** `["<32-byte-hex-public-key>", { "disallowed_methods": [...]}]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
2025-02-03 13:54:36 +00:00
If the resulting `allowed_methods` list for admin was empty, admin can be removed.
2024-11-25 16:21:47 +00:00
2025-02-03 13:49:23 +00:00
---
2024-11-25 16:21:47 +00:00
### Authorization
2025-02-03 13:49:23 +00:00
The 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.
2024-11-25 16:21:47 +00:00
2025-02-03 13:54:36 +00:00
If `Authorization` is not provided or is invalid, the endpoint should return a response with a 401 status code.