> ## 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.

# Enable or disable cancel on disconnect

> WebSocket-only method that toggles cancel on disconnect for the authenticated wallet. While enabled, dropping the WebSocket connection cancels the wallet's open orders, trigger and algo orders, and quotes. Pass enabled true or false; omitting it leaves the setting unchanged. Requires a session key with full trade scope; returns "ok".



## AsyncAPI

````yaml websocket.asyncapi.json privateSetCancelOnDisconnect
id: privateSetCancelOnDisconnect
title: Enable or disable cancel on disconnect
description: >-
  WebSocket-only method that toggles cancel on disconnect for the authenticated
  wallet. While enabled, dropping the WebSocket connection cancels the wallet's
  open orders, trigger and algo orders, and quotes. Pass enabled true or false;
  omitting it leaves the setting unchanged. Requires a session key with full
  trade scope; returns "ok".
servers:
  - id: production
    protocol: wss
    host: api.derive.xyz
    bindings: []
    variables: []
  - id: testnet
    protocol: wss
    host: testnet.api.derive.xyz
    bindings: []
    variables: []
address: /v3/ws
parameters: []
bindings: []
operations:
  - &ref_5
    id: send_privateSetCancelOnDisconnect
    title: Send_private set cancel on disconnect
    type: receive
    messages:
      - &ref_7
        id: privateSetCancelOnDisconnectRequest
        payload:
          - name: privateSetCancelOnDisconnectRequest
            type: object
            properties:
              - name: headers
                type: &ref_0
                  - object
                  - 'null'
                description: Non-standard; used by `auth/login`.
                required: false
              - name: id
                type: anyOf
                required: true
              - name: method
                type: string
                description: private/set_cancel_on_disconnect
                required: true
              - name: params
                type: object
                description: >-
                  `private/set_cancel_on_disconnect` params. `wallet` is
                  captured by the auth context.
                required: true
                properties:
                  - name: enabled
                    type: &ref_1
                      - boolean
                      - 'null'
                    description: Whether to enable or disable cancel on disconnect.
                    required: false
                  - name: wallet
                    type: &ref_2
                      - string
                      - 'null'
                    description: Wallet address.
                    required: false
        headers: []
        jsonPayloadSchema:
          type: object
          required:
            - id
            - method
            - params
          properties:
            headers:
              description: Non-standard; used by `auth/login`.
              type: *ref_0
              additionalProperties: true
              x-parser-schema-id: <anonymous-schema-41>
            id: &ref_3
              anyOf:
                - type: string
                  x-parser-schema-id: <anonymous-schema-3>
                - type: number
                  x-parser-schema-id: <anonymous-schema-4>
                - type: 'null'
                  x-parser-schema-id: <anonymous-schema-5>
              x-parser-schema-id: JsonRpcId
            method:
              type: string
              const: private/set_cancel_on_disconnect
              x-parser-schema-id: <anonymous-schema-42>
            params:
              description: >-
                `private/set_cancel_on_disconnect` params. `wallet` is captured
                by the auth context.
              type: object
              properties:
                enabled:
                  description: Whether to enable or disable cancel on disconnect.
                  default: null
                  type: *ref_1
                  x-parser-schema-id: <anonymous-schema-43>
                wallet:
                  description: Wallet address.
                  default: null
                  type: *ref_2
                  x-parser-schema-id: <anonymous-schema-44>
              x-parser-schema-id: SetCancelOnDisconnectRequest
          x-parser-schema-id: <anonymous-schema-40>
        title: Private set cancel on disconnect request
        example: |-
          {
            "method": "<string>",
            "params": {}
          }
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: privateSetCancelOnDisconnectRequest
    bindings: []
    extensions: &ref_4
      - id: x-parser-unique-object-id
        value: privateSetCancelOnDisconnect
  - &ref_6
    id: receive_privateSetCancelOnDisconnect
    title: Receive_private set cancel on disconnect
    type: send
    messages:
      - &ref_8
        id: privateSetCancelOnDisconnectResponse
        payload:
          - name: privateSetCancelOnDisconnectResponse
            type: object
            properties:
              - name: id
                type: anyOf
                required: true
        headers: []
        jsonPayloadSchema:
          type: object
          anyOf:
            - type: object
              required:
                - result
              properties:
                result:
                  description: The literal string `"ok"` returned on success.
                  type: string
                  enum:
                    - ok
                  x-parser-schema-id: SetCancelOnDisconnectResponse
              x-parser-schema-id: <anonymous-schema-46>
            - type: object
              required:
                - error
              properties:
                error:
                  type: object
                  required:
                    - code
                    - message
                  properties:
                    code:
                      type: integer
                      format: int64
                      x-parser-schema-id: <anonymous-schema-15>
                    data:
                      type:
                        - string
                        - 'null'
                      x-parser-schema-id: <anonymous-schema-16>
                    message:
                      type: string
                      x-parser-schema-id: <anonymous-schema-17>
                  x-parser-schema-id: RPCError
              x-parser-schema-id: <anonymous-schema-47>
          required:
            - id
          properties:
            id: *ref_3
          x-parser-schema-id: <anonymous-schema-45>
        title: Private set cancel on disconnect response
        example: '{}'
        bindings: []
        extensions:
          - id: x-parser-unique-object-id
            value: privateSetCancelOnDisconnectResponse
    bindings: []
    extensions: *ref_4
sendOperations:
  - *ref_5
receiveOperations:
  - *ref_6
sendMessages:
  - *ref_7
receiveMessages:
  - *ref_8
extensions:
  - id: x-parser-unique-object-id
    value: privateSetCancelOnDisconnect
securitySchemes: []

````

## Related topics

- [Cancel on Disconnect](/trading/cancel-on-disconnect.md)
- [Market Maker Protection](/trading/market-maker-protection.md)
- [Connecting over WebSocket](/connecting.md)
