chat

Cancel Chat Turn

Changed on

Stop a running turn, as the Stop button in the app does. Chat keeps what it wrote, its searches stop, and the turn ends cancelled, charged for the work done. A finished turn is returned as it is. latest stops whatever the chat is working on.

post/v1/chat/{chat_id}/turns/{turn_id}/cancel

Request

  • Base URL
    https://api.happenstance.ai (the document declares no server; this is the origin it was published from)
  • Auth
    HTTP bearer

Path parameters

chat_idstring required
turn_idstring required

A turn ID from POST /v1/chat or /messages, or latest for the chat's newest turn

Response

Successful Response

idstring required

The turn's id

chat_idstring required

The chat's id

status'queued' | 'running' | 'completed' | 'failed' | 'cancelled' required

queued (not started), running, completed, failed (not charged) or cancelled

stop_reason'done' | 'needs_input' | 'stopped' | 'error' nullable

Why a finished turn ended: done; needs_input (Chat asked questions and waits for the answers, see reply.questions); stopped (cancelled); error. Null while running.

started_by'message' | 'schedule'

message: a message or answers started the turn. schedule: one of the chat's scheduled tasks ran, and nobody sent a message (only a chat started in the app has scheduled tasks).

messagestring required

The message that started the turn, or for a scheduled run the task's instruction

messagesstring[] required

Every message in the turn: the first started it, any later one was sent while it ran and joined it. A scheduled run's turn has none.

created_atstring required

When the turn started (ISO 8601)

completed_atstring nullable

When the turn finished (ISO 8601)

last_activity_atstring nullable

When Chat last made progress on the turn (a reply, a search starting or finishing). A running turn with no progress for several minutes is stuck or slow and can be cancelled.

elapsed_secondsinteger required

Seconds since the turn started, or how long it took once finished

next_turn_idstring nullable

The chat's next turn, once one was started

Changes