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

# Read a workspace's logs

> Return completed commands newest first by start time and ID, with their mount calls. JSON started_at values and durations are milliseconds. JSONL exports all retained matching commands oldest first as command, vfs and result records, linked by parent, with timestamp in Unix milliseconds. JSONL ignores limit and after. Empty JSON is {items: [], next: null}; empty JSONL has an empty body. Retention is server-specific. Cursors are opaque and server-specific; pagination is not a snapshot.

> [accordion] Errors
>
> | Status | Meaning |
> | - | - |
> | `400` | Bad request: malformed, a host not allowed, or a browser page from another origin |
> | `401` | The token is missing or wrong |
> | `404` | The workspace, session, job or file does not exist |
> | `422` | Validation Error |
> | `429` | Past a rate limit, or a new session past max\_sessions |
> | `403` | A policy or mount mode refused the call |
>
> See [error examples and recovery steps](https://docs.mirage.strukto.ai/api/errors.md). The [complete OpenAPI contract](https://github.com/strukto-ai/mirage/blob/main/docs/openapi.yaml) includes every response schema.


## OpenAPI

````yaml /openapi.yaml get /v1/workspaces/{workspace_id}/logs
openapi: 3.2.0
info:
  title: Mirage API
  version: '0.1'
servers:
  - url: https://api.strukto.ai
    description: The hosted API
security:
  - bearerAuth: []
tags:
  - name: Workspace operations
    x-group: Workspaces
  - name: Workspaces
    x-group: Lifecycle
    parent: Workspace operations
  - name: Sessions
  - name: Shell
    parent: Workspace operations
  - name: VFS
    parent: Workspace operations
  - name: Tools
  - name: Documents
    parent: Workspace operations
  - name: Snapshots
  - name: Templates
  - name: Saved VFS
    x-group: VFS
    parent: Saved configurations
  - name: Saved CLIs
    x-group: CLIs
    parent: Saved configurations
  - name: Saved runtimes
    x-group: Runtimes
    parent: Saved configurations
  - name: Saved configurations
  - name: Policies
  - name: Asks
    parent: Workspace operations
  - name: Lines
    parent: Workspace operations
  - name: Jobs
    parent: Workspace operations
  - name: Processes
    parent: Workspace operations
  - name: Server
  - name: Auth
paths:
  /v1/workspaces/{workspace_id}/logs:
    get:
      tags:
        - Workspaces
      summary: Read a workspace's logs
      description: >-
        Return completed commands newest first by start time and ID, with their
        mount calls. JSON started_at values and durations are milliseconds.
        JSONL exports all retained matching commands oldest first as command,
        vfs and result records, linked by parent, with timestamp in Unix
        milliseconds. JSONL ignores limit and after. Empty JSON is {items: [],
        next: null}; empty JSONL has an empty body. Retention is
        server-specific. Cursors are opaque and server-specific; pagination is
        not a snapshot.
      operationId: workspace_logs_v1_workspaces__workspace_id__logs_get
      parameters:
        - $ref: '#/components/parameters/workspaceId'
        - name: session
          in: query
          description: Only this session; absent or empty selects all sessions.
          schema:
            type: string
        - name: limit
          in: query
          description: Commands per JSON page. Ignored for JSONL export.
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
        - name: after
          in: query
          description: >-
            Opaque next cursor from the previous page with the same filters.
            Ignored for JSONL export.
          schema:
            type: string
        - name: format
          in: query
          description: >-
            jsonl downloads all retained matching commands; other values select
            JSON.
          schema:
            type: string
            default: json
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogPage'
              example:
                items:
                  - id: c1
                    command: echo hi
                    cwd: /
                    started_at: 1700000000000
                    duration_ms: 8
                    exit_code: 0
                    stdout: |
                      hi
                    stderr: ''
                    user_id: null
                    api_key_id: null
                    mounts: []
                next: null
            application/x-ndjson:
              schema:
                type: string
              example: >
                {"type":"command","session":"s1","timestamp":1700000000000,"id":"c1","command":"echo
                hi"}

                {"type":"result","session":"s1","timestamp":1700000000008,"parent":"c1","duration_ms":8,"exit_code":0,"stdout":"hi\n","stderr":""}
      servers:
        - url: https://api.strukto.ai
          description: Cloud API
        - url: http://127.0.0.1:8765
          description: Local daemon
components:
  parameters:
    workspaceId:
      name: workspace_id
      in: path
      required: true
      description: The workspace's id.
      schema:
        type: string
      example: demo
  schemas:
    LogPage:
      properties:
        items:
          items:
            $ref: '#/components/schemas/CommandLog'
          title: Items
          type: array
        next:
          anyOf:
            - type: string
            - type: 'null'
          title: Next
      required:
        - items
        - next
      title: LogPage
      type: object
    CommandLog:
      properties:
        id:
          title: Id
          type: string
        command:
          title: Command
          type: string
        cwd:
          anyOf:
            - type: string
            - type: 'null'
          title: Cwd
        started_at:
          description: Start time as Unix epoch milliseconds.
          title: Started At
          type: number
        duration_ms:
          title: Duration Ms
          type: number
        exit_code:
          anyOf:
            - type: integer
            - type: 'null'
          title: Exit Code
        stdout:
          title: Stdout
          type: string
        stderr:
          title: Stderr
          type: string
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
        api_key_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Api Key Id
        mounts:
          items:
            $ref: '#/components/schemas/LogMount'
          title: Mounts
          type: array
      required:
        - id
        - command
        - cwd
        - started_at
        - duration_ms
        - exit_code
        - stdout
        - stderr
        - user_id
        - api_key_id
        - mounts
      title: CommandLog
      type: object
    LogMount:
      properties:
        op:
          title: Op
          type: string
        path:
          title: Path
          type: string
        source:
          title: Source
          type: string
        bytes:
          anyOf:
            - type: integer
            - type: 'null'
          title: Bytes
        started_at:
          description: Start time as Unix epoch milliseconds.
          title: Started At
          type: number
        duration_ms:
          title: Duration Ms
          type: number
      required:
        - op
        - path
        - source
        - bytes
        - started_at
        - duration_ms
      title: LogMount
      type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        The server's token (MIRAGE_AUTH_TOKEN) or a JWT. A daemon in the default
        local mode with no token accepts requests without one.

````

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