Docs

chain_unsubscribeNewHeads - JSON-RPC Method

Cancel a subscription created by chain_subscribeNewHeads (WebSocket-only).

Cancels a WebSocket subscription that was created with chain_subscribeNewHeads. Pass the subscription ID you received from the original call.

Code Examples

This method requires a WebSocket connection and is not available over HTTP.

WebSocket (wscat)

Bash
wscat -c wss://api-bittensor-mainnet.n.dwellir.com/YOUR_API_KEY \
  -x '{
    "jsonrpc": "2.0",
    "method": "chain_unsubscribeNewHeads",
    "params": ["SUBSCRIPTION_ID"],
    "id": 1
  }'

Use Cases

  • Subscription cleanup -- Stop receiving new-head notifications when a consumer shuts down.
  • Resource management -- Release server-side subscription state in long-running dashboards or indexers.

Notes

  • Use the subscription ID returned by chain_subscribeNewHeads.
  • Valid active subscription IDs return true. Invalid or already-closed IDs return false.
  • This method is only available over WebSocket.
  • In Dwellir-hosted Bittensor environments, unsubscribing this way can return -32603 Internal error after a successful subscription flow test; if cleanup is required, close the WebSocket connection to release session state.