> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://platform.bctrl.ai/llms.txt.
> For full documentation content, see https://platform.bctrl.ai/llms-full.txt.

# Stream Run Events

GET https://api.bctrl.ai/v2/runs/{id}/events/stream

Stream canonical run events as Server-Sent Events.

Reference: https://platform.bctrl.ai/v2/api/api-reference/runs/stream-events

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: bctrl API
  version: 1.0.0
paths:
  /v2/runs/{id}/events/stream:
    get:
      operationId: v-2-runs-events-stream
      summary: Stream run events
      description: Stream canonical run events as Server-Sent Events.
      tags:
        - subpackage_runs
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: cursor
          in: query
          required: false
          schema:
            type: string
        - name: limit
          in: query
          required: false
          schema:
            type: integer
        - name: type
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/V2RunsIdEventsStreamGetParametersType'
        - name: category
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/V2RunsIdEventsStreamGetParametersCategory'
        - name: connectionId
          in: query
          required: false
          schema:
            type: string
            format: uuid
        - name: Authorization
          in: header
          description: Use Bearer <api-key>.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
        '404':
          description: Run not found or not visible to actor
          content:
            application/json:
              schema:
                description: Any type
servers:
  - url: https://api.bctrl.ai
  - url: http://localhost:8787
components:
  schemas:
    V2RunsIdEventsStreamGetParametersType:
      oneOf:
        - type: string
        - type: array
          items:
            type: string
      title: V2RunsIdEventsStreamGetParametersType
    V2RunsIdEventsStreamGetParametersCategory0:
      type: string
      enum:
        - runtime
        - command
        - network
        - console
        - file
        - tool
        - browser
        - captcha
        - event
      title: V2RunsIdEventsStreamGetParametersCategory0
    V2RunsIdEventsStreamGetParametersCategorySchemaOneOf1Items:
      type: string
      enum:
        - runtime
        - command
        - network
        - console
        - file
        - tool
        - browser
        - captcha
        - event
      title: V2RunsIdEventsStreamGetParametersCategorySchemaOneOf1Items
    V2RunsIdEventsStreamGetParametersCategory1:
      type: array
      items:
        $ref: >-
          #/components/schemas/V2RunsIdEventsStreamGetParametersCategorySchemaOneOf1Items
      title: V2RunsIdEventsStreamGetParametersCategory1
    V2RunsIdEventsStreamGetParametersCategory:
      oneOf:
        - $ref: '#/components/schemas/V2RunsIdEventsStreamGetParametersCategory0'
        - $ref: '#/components/schemas/V2RunsIdEventsStreamGetParametersCategory1'
      title: V2RunsIdEventsStreamGetParametersCategory
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Use Bearer <api-key>.

```

## SDK Code Examples

```python
import requests

url = "https://api.bctrl.ai/v2/runs/id/events/stream"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.bctrl.ai/v2/runs/id/events/stream';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.bctrl.ai/v2/runs/id/events/stream"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.bctrl.ai/v2/runs/id/events/stream")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.bctrl.ai/v2/runs/id/events/stream")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.bctrl.ai/v2/runs/id/events/stream', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.bctrl.ai/v2/runs/id/events/stream");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.bctrl.ai/v2/runs/id/events/stream")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```