Session Management
Public
WebSocket Only

Signals the WebSocket connection to send and request heartbeats. Heartbeats are used to detect stale or broken connections.

Heartbeat & Disconnect Lifecycle:

  • When no message has been sent to the client for interval seconds, the server sends a heartbeat notification ("params": {"type": "heartbeat"}).
  • When no message has been received from the client for interval seconds (plus 500 ms), the server sends a heartbeat notification with "params": {"type": "test_request"}. Respond by sending a /api/v2/public/test request.
  • Any JSON text message from the client counts as activity and restarts this timer; WebSocket-level ping/pong frames and the plain-text ping / PING messages do not.
  • If the connection stays silent until (2 * interval) + 500 ms after the last client message, the server closes the WebSocket with close code 4000 (heartbeat close).
  • If Cancel on Disconnect is enabled for the connection (connection or account scope), orders created over this connection are cancelled when it is closed.
  • Calling this method again replaces the previous interval.

Validation: interval must be an integer between 10 and 300 seconds inclusive. Any other value (including fractional numbers) returns JSON-RPC error -32602.

WebSocket Only: This method is designed exclusively for WebSocket connections. Calling it over REST/HTTP returns error 10030 (must_be_websocket_request).

Try in API console

get/public/set_heartbeat

Request

  • Base URL
    https://test.deribit.com/api/v2
  • URL
    https://test.deribit.com/api/v2/public/set_heartbeat
  • Auth
    none declared

Query parameters

intervalinteger required
Example:30

The heartbeat interval in seconds (allowed range: 10 to 300)

Response

Success response

jsonrpc'2.0' required

The JSON-RPC version (2.0)

idinteger

The id that was sent in the request

result'ok' required

Result of method execution. ok in case of success

Changes

    • breaking

      for the query request parameter interval, the type changed from number to integer

    • warning

      for the query request parameter interval, the max was set to 300.00

    • warning

      for the query request parameter interval, the min was set to 10.00