# Stream thread (https://docs.capy.ai/api-reference/streams/stream-thread)

`GET https://api.capy.ai/api/v1/threads/{threadId}/stream`

## Authorization

Send an API key as a bearer token: `Authorization: Bearer $CAPY_API_KEY`. See https://docs.capy.ai/api-reference/authentication.md.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `threadId` | path | string | yes |  |
| `last-event-id` | header | string | no |  |
| `after` | query | string | no |  |
| `until` | query | string | no |  |
| `frames` | query | string | no |  |

## Responses

- `200` Success
- `400` capy/InvalidRequest: `capy_InvalidRequestEncoded`
- `401` capy/Unauthorized: `capy_UnauthorizedEncoded`
- `403` capy/Forbidden: `capy_ForbiddenEncoded \| capy_ForbiddenEncoded`
- `404` capy/ThreadNotFound: `capy_ThreadNotFoundEncoded`
- `429` capy/RateLimited: `capy_RateLimitedEncoded`
- `503` capy/StreamUnavailable: `capy_StreamUnavailableEncoded`

## Example

```bash
curl -X GET "https://api.capy.ai/api/v1/threads/{threadId}/stream" \
  -H "Authorization: Bearer $CAPY_API_KEY"
```

## Referenced schemas

```json
{
  "StreamEvent": {
    "anyOf": [
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "status"
            ]
          },
          "data": {
            "type": "string",
            "contentMediaType": "application/json"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      },
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "transcript"
            ]
          },
          "id": {
            "type": "string",
            "allOf": [
              {
                "minLength": 26
              },
              {
                "maxLength": 26
              }
            ]
          },
          "data": {
            "$ref": "#/components/schemas/MessageEncoded_1"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      },
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "run"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/RunFrameEncoded"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      },
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "turn"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/TurnFrameEncoded"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      },
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "assistant"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/AssistantFrameEncoded"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      },
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "tool_call"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/ToolCallFrameEncoded"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      },
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "subagent"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/SubagentStatusFrameEncoded"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      },
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "task"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/TaskStatusFrameEncoded"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      },
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "heartbeat"
            ]
          },
          "data": {
            "type": "string",
            "contentMediaType": "application/json"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      },
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "error"
            ]
          },
          "data": {
            "$ref": "#/components/schemas/StreamErrorFrameEncoded"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      },
      {
        "type": "object",
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "done"
            ]
          },
          "data": {
            "type": "string",
            "contentMediaType": "application/json"
          }
        },
        "required": [
          "event",
          "data"
        ],
        "additionalProperties": false
      }
    ]
  },
  "MessageEncoded_1": {
    "type": "string",
    "contentMediaType": "application/json"
  },
  "RunFrameEncoded": {
    "type": "string",
    "contentMediaType": "application/json"
  },
  "TurnFrameEncoded": {
    "type": "string",
    "contentMediaType": "application/json"
  },
  "AssistantFrameEncoded": {
    "type": "string",
    "contentMediaType": "application/json"
  },
  "ToolCallFrameEncoded": {
    "type": "string",
    "contentMediaType": "application/json"
  },
  "SubagentStatusFrameEncoded": {
    "type": "string",
    "contentMediaType": "application/json"
  },
  "TaskStatusFrameEncoded": {
    "type": "string",
    "contentMediaType": "application/json"
  },
  "StreamErrorFrameEncoded": {
    "type": "string",
    "contentMediaType": "application/json"
  },
  "capy_InvalidRequestEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/InvalidRequest"
        ]
      },
      "message": {
        "type": "string"
      }
    },
    "required": [
      "_tag",
      "message"
    ],
    "additionalProperties": false
  },
  "capy_UnauthorizedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Unauthorized"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_ForbiddenEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/Forbidden"
        ]
      },
      "mfaRequiredOrgId": {
        "type": "string"
      },
      "ssoRequired": {
        "type": "boolean"
      },
      "passkeyRequired": {
        "type": "boolean"
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  },
  "capy_ThreadNotFoundEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/ThreadNotFound"
        ]
      },
      "threadId": {
        "type": "string"
      }
    },
    "required": [
      "_tag",
      "threadId"
    ],
    "additionalProperties": false
  },
  "capy_RateLimitedEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/RateLimited"
        ]
      },
      "retryAfterSeconds": {
        "type": "integer"
      }
    },
    "required": [
      "_tag",
      "retryAfterSeconds"
    ],
    "additionalProperties": false
  },
  "capy_StreamUnavailableEncoded": {
    "type": "object",
    "properties": {
      "_tag": {
        "type": "string",
        "enum": [
          "capy/StreamUnavailable"
        ]
      }
    },
    "required": [
      "_tag"
    ],
    "additionalProperties": false
  }
}
```

Full document: https://docs.capy.ai/openapi.json