---
title: "Cancel Turn Stream"
method: POST
path: "/api/chats/{chat_id}/turn-stream/cancel"
tags: ["chats"]
---

# Cancel Turn Stream

`POST /api/chats/{chat_id}/turn-stream/cancel`

## Request

- Base URL: `https://app.thinqos.com` (the document declares no server; this is the origin it was published from)
- URL: `https://app.thinqos.com/api/chats/{chat_id}/turn-stream/cancel`
- Auth: none declared

Cancel (or steer) the chat's currently-running turn (TOS-2269).

A deliberate Stop or steer is distinguishable from an ambient disconnect
only because the frontend calls this endpoint before aborting the fetch.
The endpoint writes ``cancel_requested = true`` (plus ``redirect_text``
when present) onto every live ``chat_stream_progress`` row for this chat
(kept for ``_should_detach_stream_on_cancel``'s end-of-stream check, and
as the ``{"canceled": bool}`` liveness signal below) AND, as of TOS-3574,
onto ``chat_turn_state`` stamped with the chat's CURRENT turn generation.
The running turn's ``TurnCancelWatcher`` only honors the latter: it
polls for a signal matching the exact generation it was started with, so
a signal that arrives after this turn has already ended (and a new one
has begun) can never be mistaken for a cancel aimed at the new turn -
the race TOS-3568 narrowed but could not fully close on
``chat_stream_progress`` alone, because that row's identity depends on
which agent ends up responding, not known until routing completes.

Returns ``{"canceled": bool}`` - ``True`` if a live turn was found and
flagged, ``False`` if nothing was running (idempotent: a double-click on
Stop, or a steer after the turn already finished, is a safe no-op).

## Path parameters

- `chat_id` string, uuid, required

## Headers

- `x-impersonate-identity-id` string, nullable

## Request body

- CancelTurnStreamRequest: Body for ``POST /{chat_id}/turn-stream/cancel`` (TOS-2269). ``redirect_text`` is present for a steer (the new message the user wants to send instead), absent for a plain Stop. The endpoint writes the cancel signal onto every live ``chat_stream_progress`` row for this chat; the running turn's ``TurnCancelWatcher`` observes it and cancels.
  - `redirect_text` string, nullable

## Response `200`

Successful Response

- object

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/thinqos/apis/thinqos-api.md) · [All operations](https://skmtc.dev/thinqos/apis/thinqos-api/llms.txt) · [OpenAPI document](https://skmtc.dev/thinqos/apis/thinqos-api/revisions/ce2c2ce318b1?raw)
