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-03 13:49:23 +00:00
* `supported_methods` :
- **params:** `[]`
- **result:** `["<method-name>", "<method-name>", /* rest of method names... */ ]` (Extra fields MAY be sent from relay depending on implementation.)
---
* `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
Extra fields MAY be sent from relay depending on implementation.
---
2025-02-03 13:49:23 +00:00
* `set_nip11` :
- **params:**
```jsonc
[
{
"name": "new name",
"description": "new description",
"icon": null // removes icon.
// and more...
}
]
```
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
The provided input is a potentially incomplete json object of [NIP-11 ](./11.md ) document.
Relay SHOULD replace provides fields with new ones, add non existing fields and remove fields set to null.
---
2025-02-03 13:49:23 +00:00
* `list_events_needing_moderation` :
- **params:** `[]`
- **result:** `[{ "id": "<32-byte-hex>", "reason": "<optional-reason>" }, ...]` (Relay MAY return reported, muted profiles and similar events as result.)
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `ban_pubkey` :
- **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:49:23 +00:00
Relay MAY remove events sent by `pubkey` and prevent new events from them to be written.
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `list_banned_pubkeys` :
- **params:** `[]`
- **result:** `[{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `allow_pubkey` :
- **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:49:23 +00:00
* `list_allowed_pubkeys` :
- **params:** `[]`
- **result:** `[{"pubkey": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `ban_event` :
- **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-03 13:49:23 +00:00
* `list_banned_events` :
- **params:** `[]`
- **result:** `[{"id": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `allow_event` :
- **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-03 13:49:23 +00:00
* `list_allowed_events` :
- **params:** `[]`
- **result:** `[{"id": "<32-byte-hex>", "reason": "<optional-reason>"}, ...]` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `allow_kinds` :
- **params:** `(<kind-number>, <another-kind-number>, /* and more... */)`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `disallow_kinds` :
- **params:** `(<kind-number>, <another-kind-number>, /* and more... */)`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `list_disallow_kinds` :
- **params:** `[]`
- **result:** `(<kind-number>, <another-kind-number>, /* and more... */)` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `list_allowed_kinds` :
- **params:** `[]`
- **result:** `(<kind-number>, <another-kind-number>, /* and more... */)` (an array of objects)
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `bloc_kip` :
- **params:** `["<ip-address>", "<optional-reason>"]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
---
2025-02-03 13:49:23 +00:00
* `unblock_ip` :
- **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-03 13:49:23 +00:00
* `list_blocked_ips` :
- **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-03 13:49:23 +00:00
* `grant_admin` :
- **params:** `["<32-byte-hex-public-key>", { "allowed_methods": [...]}]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
If admin right is already granted, allowed methods list must be rewritten.
---
2025-02-03 13:49:23 +00:00
* `revoke_admin` :
- **params:** `["<32-byte-hex-public-key>", { "disallowed_methods": [...]}]`
- **result:** `true` (a boolean always set to `true` )
2025-02-01 21:58:27 +00:00
If 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-01 21:58:27 +00:00
If `Authorization` is not provided or is invalid, the endpoint should return a response with 401 status code.