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

# Resume a chat stream

> Reconnect to an in-flight or recently completed chat stream started by `POST /api/chat/v2`. Any events buffered during the disconnect are replayed, then live events continue.

The response uses the same SSE event format as `POST /api/chat/v2`.

### Obtaining `runId`

The run ID is delivered in the original `POST /api/chat/v2` stream as a `workflow-run-id` event:

```json
{"type": "workflow-run-id", "workflowRunId": "wf_01H9Y..."}
```

### Authorization

The caller must present the same API key that started the run. Calls from any other key return **404**.



## OpenAPI

````yaml /docs/api-reference/openapi.json get /api/chat/v2/stream/{runId}
openapi: 3.1.0
info:
  title: Vera Health API
  version: 1.0.0
  description: >-
    Send medical questions and receive evidence-based answers with citations as
    a Server-Sent Events stream.
  contact:
    name: Vera Health
    url: https://www.verahealth.ai
servers:
  - url: https://www.verahealth.ai
    description: Production server
security:
  - apiKeyAuth: []
tags:
  - name: v2
    description: >-
      Send a medical question and receive an evidence-based answer as a
      Server-Sent Events stream.
  - name: v3
    description: >-
      Preview agentic endpoint. Runs Vera's tool-using agent and lets each
      request choose which optional tool groups are available. Testing only.
  - name: v1
    description: Legacy v1 chat endpoint. New integrations should use v2.
paths:
  /api/chat/v2/stream/{runId}:
    get:
      tags:
        - v2
      summary: Resume a chat stream
      description: >-
        Reconnect to an in-flight or recently completed chat stream started by
        `POST /api/chat/v2`. Any events buffered during the disconnect are
        replayed, then live events continue.


        The response uses the same SSE event format as `POST /api/chat/v2`.


        ### Obtaining `runId`


        The run ID is delivered in the original `POST /api/chat/v2` stream as a
        `workflow-run-id` event:


        ```json

        {"type": "workflow-run-id", "workflowRunId": "wf_01H9Y..."}

        ```


        ### Authorization


        The caller must present the same API key that started the run. Calls
        from any other key return **404**.
      operationId: resume-a-chat-stream
      parameters:
        - name: runId
          in: path
          required: true
          description: >-
            Workflow run identifier received from the `workflow-run-id` event of
            the original `POST /api/chat/v2` stream.
          schema:
            type: string
            minLength: 1
          example: wf_01H9YABCDEF0123456789
      responses:
        '200':
          description: >-
            Reconnected. Returns the same SSE event stream as `POST
            /api/chat/v2`, starting with any buffered events followed by live
            events. See the `POST /api/chat/v2` response for the full event
            catalog.
          headers:
            x-thread-id:
              description: UUID of the thread associated with this run
              schema:
                type: string
                format: uuid
            x-message-id:
              description: UUID of the message associated with this run
              schema:
                type: string
                format: uuid
          content:
            text/event-stream:
              schema:
                type: string
                description: >-
                  SSE stream replaying buffered events then continuing live.
                  Same event format as `POST /api/chat/v2`.
        '400':
          description: Missing `runId` path parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Missing runId
        '401':
          description: >-
            Missing or invalid API key, or the key could not be associated with
            a caller identity.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Unauthorized
        '404':
          description: >-
            Workflow run not found, or the run is not associated with this API
            key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Workflow run not found
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - apiKeyAuth: []
      x-codeSamples:
        - lang: curl
          label: cURL
          source: >-
            curl -N https://www.verahealth.ai/api/chat/v2/stream/wf_01H9YABC...
            \
              -H "x-api-key: YOUR_API_KEY"
        - lang: javascript
          label: JavaScript
          source: |-
            async function resumeStream(workflowRunId, apiKey) {
              const response = await fetch(
                `https://www.verahealth.ai/api/chat/v2/stream/${workflowRunId}`,
                { headers: { 'x-api-key': apiKey } },
              );

              if (!response.ok) {
                throw new Error(`Resume failed: ${response.status}`);
              }

              const reader = response.body.getReader();
              const decoder = new TextDecoder();
              let buffer = '';

              while (true) {
                const { done, value } = await reader.read();
                if (done) break;
                buffer += decoder.decode(value, { stream: true });

                const frames = buffer.split('\n\n');
                buffer = frames.pop() ?? '';

                for (const frame of frames) {
                  const line = frame.trim();
                  if (!line.startsWith('data: ')) continue;
                  const event = JSON.parse(line.slice(6));
                  // Same event handling as POST /api/chat/v2
                  console.log(event);
                }
              }
            }
        - lang: python
          label: Python
          source: |-
            import json
            import requests

            def resume_stream(workflow_run_id, api_key):
                url = f'https://www.verahealth.ai/api/chat/v2/stream/{workflow_run_id}'
                headers = {'x-api-key': api_key}

                with requests.get(url, headers=headers, stream=True) as response:
                    response.raise_for_status()
                    for raw in response.iter_lines(decode_unicode=True):
                        if not raw or not raw.startswith('data: '):
                            continue
                        event = json.loads(raw[6:])
                        print(event)  # same event handling as POST /api/chat/v2
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message
        message:
          type: string
          description: Detailed error message
        details:
          type: string
          description: Additional error details
    RateLimitError:
      type: object
      required:
        - error
      description: >-
        Rate-limit error body. Emitted by the auth layer, so it carries no
        `metadata` echo (unlike the ChatError envelope).
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              enum:
                - rate_limited
            message:
              type: string
  responses:
    TooManyRequests:
      description: >-
        Rate limit exceeded for this API key. Retry after the Retry-After
        interval.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            type: integer
        RateLimit-Limit:
          description: Max requests allowed in the current window.
          schema:
            type: integer
        RateLimit-Remaining:
          description: Requests remaining in the current window.
          schema:
            type: integer
        RateLimit-Reset:
          description: Seconds until the window resets.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
          example:
            error:
              code: rate_limited
              message: >-
                Rate limit exceeded. Retry after the interval in the Retry-After
                header.
    InternalServerError:
      description: Internal server error - An unexpected error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: Internal server error
            message: An unexpected error occurred while processing your request
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. Contact support@verahealth.ai to obtain your
        API key.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.