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

# Stream build logs

> Follow a template build live over Server-Sent Events.

Streams the build log as [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events). Use it to render a live, Docker-style build console. The stream stays open for the duration of the build. When the build ends (succeeds, fails, or is cancelled), it sends a final `event: end` frame whose data is `{}`, then closes. Closing the connection tears down the upstream subscription.

<Warning>
  The stream only carries a build that runs on the template registry host. Builds started with [Build template](/api-reference/templates/build) or `POST /templates?auto_build=true` are queued for a dedicated build runner, which does not publish to this stream, so for those the call returns `404` with `{ "error": "no build in progress for this template" }`. Poll [Get build status](/api-reference/templates/build-status) instead.
</Warning>

<Note>
  The stream is scoped to your own templates, so a curated (`system/…`) ref returns `404`.
</Note>

Each `data:` frame is a JSON object:

<ResponseField name="ts" type="string">Event timestamp (ISO 8601).</ResponseField>
<ResponseField name="level" type="string">`info`, `success`, `warn`, or `error`.</ResponseField>

<ResponseField name="phase" type="string">
  Build phase, e.g. `compile`, `boot`, `install`, `snapshot`, `record`, `archive`, or `ready`.
</ResponseField>

<ResponseField name="source" type="string">Origin of the line, e.g. `vm`, `orgo-init`, or `builder`. Optional.</ResponseField>
<ResponseField name="line" type="string">A single line of build output.</ResponseField>

## Path parameters

<ParamField path="namespace" type="string" required>Template namespace.</ParamField>
<ParamField path="name" type="string" required>Template name.</ParamField>
<ParamField path="version" type="string" required>Version (semver).</ParamField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -N https://www.orgo.ai/api/templates/default/claude-code/1.0.0/build/events \
    -H "Authorization: Bearer $ORGO_API_KEY"
  ```

  ```python Python theme={null}
  import os, json, requests

  with requests.get(
      "https://www.orgo.ai/api/templates/default/claude-code/1.0.0/build/events",
      headers={"Authorization": f"Bearer {os.environ['ORGO_API_KEY']}"},
      stream=True,
  ) as r:
      for raw in r.iter_lines():
          if raw and raw.startswith(b"data: "):
              event = json.loads(raw[6:])
              if "line" in event:  # the final `event: end` frame carries {}
                  print(f"[{event['phase']}] {event['line']}")
  ```

  ```javascript JavaScript theme={null}
  // Browser: EventSource doesn't send Authorization headers, so stream with fetch.
  const r = await fetch(
    "https://www.orgo.ai/api/templates/default/claude-code/1.0.0/build/events",
    { headers: { Authorization: `Bearer ${process.env.ORGO_API_KEY}` } },
  );
  const reader = r.body.getReader();
  const decoder = new TextDecoder();
  for (;;) {
    const { value, done } = await reader.read();
    if (done) break;
    for (const line of decoder.decode(value).split("\n")) {
      if (line.startsWith("data: ")) {
        const e = JSON.parse(line.slice(6));
        if ("line" in e) console.log(`[${e.phase}] ${e.line}`); // skip the final {} frame
      }
    }
  }
  ```
</CodeGroup>

### Stream

```text theme={null}
data: {"ts":"2026-06-08T17:00:01Z","level":"info","phase":"boot","source":"vm","line":"copying base rootfs"}

data: {"ts":"2026-06-08T17:00:14Z","level":"info","phase":"install","source":"app-install","line":"npm install -g @anthropic-ai/claude-code"}

data: {"ts":"2026-06-08T17:01:50Z","level":"success","phase":"snapshot","source":"vm","line":"snapshot captured"}

data: {"ts":"2026-06-08T17:01:58Z","level":"success","phase":"ready","line":"build complete in 118420ms"}

event: end
data: {}
```

## Errors

Errors arrive as a JSON body with the status below, not as an event frame. A `200` always carries `Content-Type: text/event-stream`.

| Status | Body | Meaning |
| - | - | - |
| `401` | `{ "error": "Invalid API key" }` | The Bearer token starts with `sk_` but is not a known Orgo key. |
| `401` | `{ "error": "Authentication required" }` | No `Authorization` header, or a Bearer token that is not an `sk_` key. |
| `401` | `{ "error": "This endpoint requires an account-wide credential (workspace_scope_mismatch)." }` | The key is workspace-scoped. Template endpoints need an account-wide key. This route answers with `401`, not `403`. |
| `401` | `{ "error": "Service temporarily unavailable. …" }` | Orgo could not verify the key because of a server-side fault. The key is fine. Retry. |
| `404` | `{ "error": string }` | No such template version in your namespaces, or no build of it is running on the registry host (`"no build in progress for this template"`). Forwarded from the build host. |
| `502` | `{ "error": "upstream fetch failed: …" }` | The build host could not be reached. Retry. |
| `503` | `{ "error": string }` | No fleet host is available to serve the stream. Retry. |


## OpenAPI

````yaml GET /templates/{namespace}/{name}/{version}/build/events
openapi: 3.1.0
info:
  title: Orgo API
  description: >-
    Launch cloud computers that AI agents can control and interact with. Create
    workspaces, provision computers, and control them programmatically.
  version: 2.0.0
  contact:
    name: Orgo Support
    email: spencer@orgo.ai
    url: https://orgo.ai
servers:
  - url: https://www.orgo.ai/api
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Account
    description: >-
      Account capacity: how many computers an account may run, and adding or
      giving back more.
  - name: Clients
    description: >-
      Run Orgo for your clients from your own app: a workspace and scoped key
      each, billed to you or to them.
  - name: Workspaces
    description: Organize computers into named workspaces
  - name: Computers
    description: Provision and manage virtual computers
  - name: Computer Lifecycle
    description: Start, stop, and restart computers
  - name: Computer Actions
    description: Control mouse, keyboard, and execute commands
  - name: Screens
    description: >-
      More than one desktop on a single computer. Each screen is its own X
      server with its own cursor and window manager, so an agent working on one
      cannot disturb another.
  - name: Files
    description: Upload and download files
  - name: Templates
    description: Author, build, and launch reproducible computers from templates
paths:
  /templates/{namespace}/{name}/{version}/build/events:
    get:
      tags:
        - Templates
      summary: Stream build logs
      description: >-
        Server-Sent Events stream of a build running on the template registry
        host. Builds started through the build queue (`POST .../build`, or `POST
        /templates?auto_build=true`) do not publish here, so for those the call
        returns `404`; poll the build status instead. Errors arrive as a JSON
        body, not as an event frame.
      operationId: streamBuildEvents
      parameters:
        - name: namespace
          in: path
          required: true
          schema:
            type: string
        - name: name
          in: path
          required: true
          schema:
            type: string
        - name: version
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: SSE stream of BuildEvent frames
          content:
            text/event-stream:
              schema:
                $ref: '#/components/schemas/BuildEvent'
        '401':
          $ref: '#/components/responses/UnauthorizedTemplates'
        '404':
          description: >-
            No such template version in your namespaces, or no build of it is
            running on the registry host. A curated ref also returns `404`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplateError'
              example:
                error: no build in progress for this template
        '502':
          description: The build host could not be reached. Retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TemplateError'
              example:
                error: 'upstream fetch failed: …'
        '503':
          $ref: '#/components/responses/TemplateHostUnavailable'
components:
  schemas:
    BuildEvent:
      type: object
      description: One frame of the build-events SSE stream.
      properties:
        ts:
          type: string
          format: date-time
        level:
          type: string
          enum:
            - info
            - success
            - warn
            - error
        phase:
          type: string
          enum:
            - queue
            - publish
            - compile
            - boot
            - settle
            - install
            - build
            - snapshot
            - record
            - archive
            - ready
            - cancel
            - timeout
        source:
          type: string
          description: Origin of the line, e.g. apt, pip, npm, builder.
        line:
          type: string
          description: A single line of build output.
    TemplateError:
      type: object
      description: >-
        A failure from the template registry, relayed with the registry's own
        status and code.
      required:
        - error
      properties:
        error:
          type: string
        code:
          type: string
          description: Machine-readable reason, when the registry supplied one.
        details:
          description: >-
            Per-field validation errors, or the raw upstream body when it was
            not JSON.
          oneOf:
            - type: array
              items:
                $ref: '#/components/schemas/ValidationError'
            - type: string
    Error:
      type: object
      description: >-
        The base error body. Every failure carries `error`; individual endpoints
        add the fields named in the schemas below.
      required:
        - error
      properties:
        error:
          type: string
          description: Human-readable message.
          example: Access denied
        code:
          type: string
          description: >-
            Machine-readable reason. Present on the failures that define one,
            absent otherwise.
    ValidationError:
      type: object
      properties:
        field:
          type: string
          description: Dotted path to the offending field.
          example: hardware.cpu
        code:
          type: string
          example: invalid_enum
        message:
          type: string
        hint:
          type: string
  responses:
    UnauthorizedTemplates:
      description: >-
        No usable credential, or a workspace-scoped key. Template endpoints need
        an account-wide key and answer a scoped one with `401`, not `403`. A
        server-side fault while verifying the credential also returns `401`,
        with a `Service temporarily unavailable` message. Retry that one; the
        key is fine.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            invalid-key:
              summary: The key is not one of yours
              value:
                error: Invalid API key
            no-credential:
              summary: No key and no session
              value:
                error: Authentication required
            account-wide-required:
              summary: The API key is workspace-scoped
              value:
                error: >-
                  This endpoint requires an account-wide credential
                  (workspace_scope_mismatch).
            service-unavailable:
              summary: Server-side fault while verifying the credential. Retry.
              value:
                error: >-
                  Service temporarily unavailable. The database is not accepting
                  requests. Retry shortly.
    TemplateHostUnavailable:
      description: >-
        No template-capable host in the fleet could serve the request, or the
        fleet lookup itself failed. Retry.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TemplateError'
          example:
            error: >-
              no template launch host available in env=production: every
              fleet_servers row was excluded (disabled, draining, unhealthy,
              dedicated, legacy/parked, or not accepting user VMs). Check the
              fleet
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key authentication. Get your key at orgo.ai/workspaces

````

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