RecoupGet a Free AuditFree Audit

API REFERENCE

Resume Chat Stream

On this page
GET/api/chat/{chatId}/stream

Reconnects to an in-progress chat response — the resume counterpart to POST /api/chat, which never resumes. Returns the live Server-Sent Events stream when a response is still being generated, or 204 No Content when there is nothing to resume. The chat must belong to the authenticated account.

Related endpoints - POST /api/chat — the interactive turn whose stream this resumes. - POST /api/chat/runs — start a headless run, then pass the returned chatId here to watch its output live. - GET /api/chat/runs/{runId} — check whether that run finished (status, not content).

Authentication

x-api-key in header

bearerAuth bearer

Request

cURL
curl --request GET \
  --url 'https://api.recoupable.dev/api/chat/YOUR_CHAT_ID/stream' \
  --header 'x-api-key: YOUR_API_KEY'

Replace the YOUR_ placeholders with your values. Required query parameters are included; optional parameters are listed below.

Parameters

Path parameters

chatIdstringrequired

UUID of the chat to resume.

Query parameters

account_idstring

Act on a chat belonging to another account. Only honoured for a key that is authorised for that account — an organization key may pass a member account's id; a personal key passing anyone else's is rejected with 403 Access denied to specified account_id. Omit it to act as the authenticated account.

startIndexinteger

Zero-based index of the first stream chunk to return, so a client that was already receiving this response resumes where it left off instead of replaying the whole turn.

Pass the number of chunks already received. Omit it to receive the response from the beginning — the right choice for a fresh reader such as a page load, or a client watching a headless POST /api/chat/runs run for the first time.

A long turn's stream can end before the run does; reconnecting with startIndex is how a client keeps rendering without duplicating or skipping chunks.

Responses

200Server-Sent Events stream of UI message parts for the in-progress response, compatible with the Vercel AI SDK. The x-workflow-run-id response header carries the run ID for this response, and x-workflow-stream-tail-index carries the index of the last chunk known when this read was opened — a base for computing absolute positions, not a record of where the response ended.
x-workflow-run-idresponse header

Durable workflow run ID of the resumed run.

x-workflow-stream-tail-indexresponse header

Zero-based index of the last chunk known to the stream at the moment this read was opened. Because headers are sent before the body, a read that stays open past that point will deliver chunks beyond it — so this is a base for computing absolute positions, not a record of where the response ended. A client resuming precisely should count the chunks it receives on top of this value. Omitted if the runtime cannot report it.

text/event-stream

string

204No active stream to resume for this chat.

No response body schema is specified.

400startIndex was provided but is not a non-negative integer.

application/json

statusstring · enumrequired

Status of the request

Values: "error"

errorstringrequired

Error message describing what went wrong

missing_fieldsarray<string>

Present on validation failures (400): the path of the field that failed. Empty for a malformed path parameter.

Item properties for missing_fields

string

401Missing or invalid credentials.

application/json

statusstring · enumrequired

Status of the request

Values: "error"

errorstringrequired

Error message describing what went wrong

missing_fieldsarray<string>

Present on validation failures (400): the path of the field that failed. Empty for a malformed path parameter.

Item properties for missing_fields

string

403The authenticated account does not own the referenced chat.

application/json

statusstring · enumrequired

Status of the request

Values: "error"

errorstringrequired

Error message describing what went wrong

missing_fieldsarray<string>

Present on validation failures (400): the path of the field that failed. Empty for a malformed path parameter.

Item properties for missing_fields

string

404Chat not found.

application/json

statusstring · enumrequired

Status of the request

Values: "error"

errorstringrequired

Error message describing what went wrong

missing_fieldsarray<string>

Present on validation failures (400): the path of the field that failed. Empty for a malformed path parameter.

Item properties for missing_fields

string

Full specification

Download the OpenAPI file for complete schemas, constraints, and examples.

Download research.json
View operation source
json
{
  "summary": "Resume a chat response stream",
  "description": "Reconnects to an in-progress chat response — the resume counterpart to [`POST /api/chat`](/api-reference/chat/workflow), which never resumes. Returns the live Server-Sent Events stream when a response is still being generated, or `204 No Content` when there is nothing to resume. The chat must belong to the authenticated account.\n\n**Related endpoints**\n- [`POST /api/chat`](/api-reference/chat/workflow) — the interactive turn whose stream this resumes.\n- [`POST /api/chat/runs`](/api-reference/chat/runs) — start a **headless** run, then pass the returned `chatId` here to **watch its output live**.\n- [`GET /api/chat/runs/{runId}`](/api-reference/chat/runs-status) — check **whether** that run finished (status, not content).",
  "security": [
    {
      "apiKeyAuth": []
    },
    {
      "bearerAuth": []
    }
  ],
  "parameters": [
    {
      "name": "chatId",
      "in": "path",
      "required": true,
      "description": "UUID of the chat to resume.",
      "schema": {
        "type": "string",
        "format": "uuid"
      }
    },
    {
      "name": "account_id",
      "in": "query",
      "required": false,
      "description": "Act on a chat belonging to another account. Only honoured for a key that is authorised for that account — an organization key may pass a member account's id; a personal key passing anyone else's is rejected with `403 Access denied to specified account_id`. Omit it to act as the authenticated account.",
      "schema": {
        "type": "string",
        "format": "uuid"
      }
    },
    {
      "name": "startIndex",
      "in": "query",
      "required": false,
      "description": "Zero-based index of the first stream chunk to return, so a client that was already receiving this response resumes where it left off instead of replaying the whole turn.\n\nPass the number of chunks already received. Omit it to receive the response from the beginning — the right choice for a fresh reader such as a page load, or a client watching a headless [`POST /api/chat/runs`](/api-reference/chat/runs) run for the first time.\n\nA long turn's stream can end before the run does; reconnecting with `startIndex` is how a client keeps rendering without duplicating or skipping chunks.",
      "schema": {
        "type": "integer",
        "minimum": 0
      }
    }
  ],
  "responses": {
    "200": {
      "description": "Server-Sent Events stream of UI message parts for the in-progress response, compatible with the Vercel AI SDK. The `x-workflow-run-id` response header carries the run ID for this response, and `x-workflow-stream-tail-index` carries the index of the last chunk known when this read was opened — a base for computing absolute positions, not a record of where the response ended.",
      "headers": {
        "x-workflow-run-id": {
          "description": "Durable workflow run ID of the resumed run.",
          "schema": {
            "type": "string"
          }
        },
        "x-workflow-stream-tail-index": {
          "description": "Zero-based index of the last chunk known to the stream **at the moment this read was opened**. Because headers are sent before the body, a read that stays open past that point will deliver chunks beyond it — so this is a base for computing absolute positions, not a record of where the response ended. A client resuming precisely should count the chunks it receives on top of this value. Omitted if the runtime cannot report it.",
          "schema": {
            "type": "integer"
          }
        }
      },
      "content": {
        "text/event-stream": {
          "schema": {
            "type": "string",
            "description": "Server-Sent Events stream containing UI message parts"
          }
        }
      }
    },
    "204": {
      "description": "No active stream to resume for this chat."
    },
    "400": {
      "description": "`startIndex` was provided but is not a non-negative integer.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ChatStreamErrorResponse"
          }
        }
      }
    },
    "401": {
      "description": "Missing or invalid credentials.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ChatStreamErrorResponse"
          }
        }
      }
    },
    "403": {
      "description": "The authenticated account does not own the referenced chat.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ChatStreamErrorResponse"
          }
        }
      }
    },
    "404": {
      "description": "Chat not found.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/ChatStreamErrorResponse"
          }
        }
      }
    }
  }
}