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

# Cancel on Disconnect

> Dead Man's Switch mechanism to cancel all orders after a timeout

<div className="api-banner">
  <span className="api-protocol ws">WSS</span>
  <span className="api-detail">ws-auth.kraken.com/v2</span>
  <span className="api-tag">cancel\_all\_orders\_after</span>
</div>

`cancel_all_orders_after` provides a "Dead Man's Switch" mechanism to protect from network malfunction, extreme latency or unexpected matching engine downtime.

* The client sends request with a timeout (in seconds), that will start a countdown timer in the trading engine which will cancel all client orders when the timer expires.
* The client must keep sending new requests to reset the trigger time, or deactivate the mechanism by specifying a timeout of 0.
* If the timer expires, all orders in the account are cancelled and the feature is disabled until the next `cancel_all_orders_after` request.
* The recommended use is to make a call every 15 to 30 seconds, providing a timeout of 60 seconds. This allows the client to keep the orders in place in case of a brief disconnection or transient delay, while keeping them safe in case of a network breakdown.

<Info>
  It is recommended to disable the timer ahead of scheduled trading engine maintenance (if the timer is enabled, all orders will be cancelled when the trading engine comes back from downtime).
</Info>

<Tabs>
  <Tab title="Request">
    <ResponseField name="method" type="string" required>
      Value: `cancel_all_orders_after`
    </ResponseField>

    <ResponseField name="params" type="object">
      <Expandable title="properties" defaultOpen>
        <ResponseField name="timeout" type="integer" required>
          Duration (in seconds) to set/extend the timer, it should be less than `86400` seconds.
        </ResponseField>

        <ResponseField name="token" type="string" required>
          Authentication token. See [authentication guide](/exchange/guides/websockets/authentication) for details.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="req_id" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>
  </Tab>

  <Tab title="Response">
    <ResponseField name="method" type="string">
      Value: `cancel_all_orders_after`
    </ResponseField>

    <ResponseField name="result" type="object">
      <span className="field-attr">Condition:</span> if `success` is `true`

      <Expandable title="properties" defaultOpen>
        <ResponseField name="currentTime" type="string">
          <span className="field-attr">Format:</span> RFC3339<br />
          <span className="field-attr">Example:</span> `2022-12-25T09:30:59.123456Z`

          The current engine time.
        </ResponseField>

        <ResponseField name="triggerTime" type="string">
          <span className="field-attr">Format:</span> RFC3339<br />
          <span className="field-attr">Example:</span> `2022-12-25T09:30:59.123456Z`

          The time the orders will be expired in the engine.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="error" type="string">
      Error message. Condition: if `success` is `false`.
    </ResponseField>

    <ResponseField name="success" type="boolean">
      Indicates if the request was successfully processed by the engine. One of: `true`, `false`
    </ResponseField>

    <ResponseField name="req_id" type="integer">
      Optional client originated request identifier sent as acknowledgment in the response.
    </ResponseField>

    <ResponseField name="time_in" type="string">
      The timestamp when the request was received on the wire, just prior to parsing data. Format: RFC3339. Example: `2022-12-25T09:30:59.123456Z`
    </ResponseField>

    <ResponseField name="time_out" type="string">
      The timestamp when the response was sent on the wire, just prior to transmitting data. Format: RFC3339. Example: `2022-12-25T09:30:59.123456Z`
    </ResponseField>
  </Tab>
</Tabs>

<Panel>
  <CodeGroup>
    ```json Request theme={null}
    {
        "method": "cancel_all_orders_after",
        "params": {
            "timeout": 100,
            "token": "zwpdzWUe18Bn6h4TAMorh26+QbcMeST2B5tamfe+pgQ"
        },
        "req_id": 1234567890
    }
    ```

    ```json Response theme={null}
    {
        "method": "cancel_all_orders_after",
        "req_id": 1234567890,
        "result": {
            "currentTime": "2023-09-21T15:49:29Z",
            "triggerTime": "2023-09-21T15:51:09Z"
        },
        "success": true,
        "time_in": "2023-09-21T15:49:28.627900Z",
        "time_out": "2023-09-21T15:49:28.649057Z"
    }
    ```
  </CodeGroup>
</Panel>
