> ## Documentation Index
> Fetch the complete documentation index at: https://v3.docs.derive.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON-RPC Envelope

> The JSON-RPC 2.0 request/response envelope and the WebSocket and HTTP transports shared by every method.

The Derive v3 API is **JSON-RPC 2.0**. Every method — market data, trading, account, vaults — shares one
request/response envelope and is reachable over **two transports**: a persistent **WebSocket** connection or
a **single HTTP POST**. The method name and its `params` are identical across both; only the framing differs.

## The envelope

A request carries an `id`, the protocol version, the `method` path, and a `params` object.

```json theme={null}
{
  "id": "1",
  "jsonrpc": "2.0",
  "method": "private/cancel",
  "params": {
    "subaccount_id": 12345,
    "instrument_name": "ETH-PERP",
    "order_id": "b7e6...c2a1"
  }
}
```

A response is **either** a `result` **or** an `error` — never both — and echoes the request `id`.

<CodeGroup>
  ```json Success theme={null}
  {
    "id": "1",
    "jsonrpc": "2.0",
    "result": {
      "order_id": "b7e6...c2a1",
      "instrument_name": "ETH-PERP",
      "order_status": "cancelled"
    }
  }
  ```

  ```json Error theme={null}
  {
    "id": "1",
    "jsonrpc": "2.0",
    "error": {
      "code": -32602,
      "message": "Invalid params",
      "data": "order_id not found"
    }
  }
  ```
</CodeGroup>


## Related topics

- [Error Codes](/error-codes.md)
- [Connecting over WebSocket](/connecting.md)
- [Get perpetual funding history for a subaccount](/api-reference/history/get-perpetual-funding-history-for-a-subaccount.md)
