> ## 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</span>
  <span className="api-tag">cancelAllOrdersAfter</span>
</div>

`cancelAllOrdersAfter` provides a "Dead Man's Switch" mechanism to protect the client from network malfunction, extreme latency or unexpected matching engine downtime. The client can send a request with a timeout (in seconds), that will start a countdown timer which will cancel *all* client orders when the timer expires.

The recommended use is to make a call every 15 to 30 seconds, providing a timeout of 60 seconds.

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

    <ResponseField name="timeout" type="integer" required>
      Timeout specified in seconds. 0 to disable the timer.
    </ResponseField>

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

    <ResponseField name="token" type="string" required>
      Session token from the [GetWebSocketsToken](/api-reference/trading/get-websockets-token) REST endpoint.
    </ResponseField>
  </Tab>

  <Tab title="Response">
    <ResponseField name="event" type="string">
      Value: `cancelAllOrdersAfterStatus`
    </ResponseField>

    <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`

      Timestamp when the request has been handled (second precision, rounded up).
    </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`

      Timestamp at which all open orders will be cancelled, unless the timer is extended or disabled (second precision, rounded up).
    </ResponseField>

    <ResponseField name="status" type="string">
      <span className="field-attr">One of:</span> `ok`, `error`
    </ResponseField>

    <ResponseField name="reqid" type="integer">
      Client originated identifier for the request that initiated this response.
    </ResponseField>

    <ResponseField name="errorMessage" type="string">
      Error message for unsuccessful requests.
    </ResponseField>
  </Tab>
</Tabs>

<Panel>
  <CodeGroup>
    ```json Request theme={null}
    {
        "event": "cancelAllOrdersAfter",
        "reqid": 1608543428050,
        "timeout": 60,
        "token": "0000000000000000000000000000000000000000"
    }
    ```

    ```json Response: Enabled theme={null}
    {
        "currentTime": "2020-12-21T09:37:09Z",
        "event": "cancelAllOrdersAfterStatus",
        "reqid": 1608543428050,
        "status": "ok",
        "triggerTime": "2020-12-21T09:38:09Z"
    }
    ```

    ```json Response: Disabled theme={null}
    {
        "currentTime": "2020-12-21T09:37:09Z",
        "event": "cancelAllOrdersAfterStatus",
        "reqid": 1608543428051,
        "status": "ok",
        "triggerTime": "0"
    }
    ```
  </CodeGroup>
</Panel>
