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

# Get a run

> Returns one run with its detail: the control command waiting for its daemon
(`pending_control`), whether it may be force-terminated (`force_terminate`), and, with
`with_history: true`, its history (started, resume requested and by whom, resumed, ended).

Requires a realm member (or higher) with the `runs.view` permission on the realm that owns the run given by `run_id`.



## OpenAPI

````yaml /openapi/hub-by-tag/hub-runs.yaml post /v1/runs/get_by_id
openapi: 3.0.3
info:
  title: 'CliqHub API: Runs'
  version: 1.0.0
  description: >-
    Runs of a team on a daemon. People start runs (Start a run), follow them
    (Get a run, Stream

    run activity, Search run logs, Get run telemetry), and control them (Cancel
    a run, Resume a

    run, Supply run inputs). CliqHub hands each control to the run's daemon,
    which must be

    online: when it is not, the call fails with a `run/daemon_offline` or
    `run/daemon_stranded`

    conflict (cancel instead marks the run cancelled on CliqHub).


    Daemons report what happens during a run through the other endpoints here,
    with their realm

    token: Record a new run, Update run status, Complete a run, and three
    separate channels for

    run activity (the live timeline), run telemetry (token usage and traces) and
    run logs (text).
servers:
  - url: https://{host}
    variables:
      host:
        default: cliqhub.io
        description: CliqHub host
security: []
tags:
  - name: Runs
    description: >-
      Runs of a team on a daemon. People start runs (Start a run), follow them
      (Get a run, Stream

      run activity, Search run logs, Get run telemetry), and control them
      (Cancel a run, Resume a

      run, Supply run inputs). CliqHub hands each control to the run's daemon,
      which must be

      online: when it is not, the call fails with a `run/daemon_offline` or
      `run/daemon_stranded`

      conflict (cancel instead marks the run cancelled on CliqHub).


      Daemons report what happens during a run through the other endpoints here,
      with their realm

      token: Record a new run, Update run status, Complete a run, and three
      separate channels for

      run activity (the live timeline), run telemetry (token usage and traces)
      and run logs (text).
paths:
  /v1/runs/get_by_id:
    post:
      tags:
        - Runs
      summary: Get a run
      description: >-
        Returns one run with its detail: the control command waiting for its
        daemon

        (`pending_control`), whether it may be force-terminated
        (`force_terminate`), and, with

        `with_history: true`, its history (started, resume requested and by
        whom, resumed, ended).


        Requires a realm member (or higher) with the `runs.view` permission on
        the realm that owns the run given by `run_id`.
      operationId: POST_v1_runs_get_by_id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                run_id:
                  type: string
                  description: The run's id.
                with_history:
                  type: boolean
                  description: >-
                    Also return `history`: started / resume requested (by whom)
                    / resumed / failed / completed, oldest first
              required:
                - run_id
            examples:
              default:
                value:
                  run_id: 0c8d7e6f-5a4b-4c3d-9e2f-1a0b9c8d7e6f
                  with_history: true
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                required:
                  - ok
                  - data
                properties:
                  ok:
                    type: boolean
                    enum:
                      - true
                    description: Always `true` on success.
                  data:
                    $ref: '#/components/schemas/RunData'
              example:
                ok: true
                data:
                  run_id: 0c8d7e6f-5a4b-4c3d-9e2f-1a0b9c8d7e6f
                  workspace_id: 9b2e6f10-4c3a-4e7d-8f21-6a5b4c3d2e1f
                  team_id: 3f6c2a8e-6b1d-4c1e-9a57-0d2f4b8e91c4
                  daemon_id: 7d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d
                  realm_id: 5b0c3a7e-2f4d-4b8e-9a51-7c1d2e3f4a5b
                  parent_run_id: null
                  parent_phase: null
                  root_run_id: null
                  call_path: null
                  call_depth: 0
                  iteration_key: null
                  run_name: brave-otter
                  state: awaiting_input
                  inputs:
                    pr_url: https://github.com/acme/api/pull/42
                  error: null
                  execution_type: local
                  current_pid: null
                  current_phase: approve
                  external_id: null
                  context_labels: null
                  reviewers:
                    approve:
                      - sshah
                  notify_channels: null
                  lease_expires_at: 1759920600000
                  started_at: 1759834200000
                  completed_at: null
                  pending_control: null
                  force_terminate:
                    already_terminated: false
                    terminated_at: null
                    terminated_by_user_id: null
                    terminated_reason: null
                    eligible: false
                    trigger: null
                    blocker: >-
                      daemon is heartbeating and no cancel has been queued long
                      enough
                  state_lost_at: null
                  team_version_id: 61e2d3c4-b5a6-4789-8c0d-1e2f3a4b5c6d
                  history:
                    - type: run.started
                      at: 1759834200000
                      from_phase: null
                      phase: null
                      error: null
                      actor: null
        '401':
          description: >-
            `unauthorized`: No `Authorization` header, or the token is
            malformed, expired or revoked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                unauthorized:
                  summary: unauthorized
                  value:
                    ok: false
                    error:
                      code: unauthorized
                      message: Authentication required
        '403':
          description: >-
            `forbidden`: You can see the record but your role in its realm is
            too low or lacks the required permission.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                forbidden:
                  summary: forbidden
                  value:
                    ok: false
                    error:
                      code: forbidden
                      message: You do not have access to do this
        '404':
          description: >-
            `not_found`: The run does not exist or is in a realm you cannot see
            (404 rather than 403, so its existence is not revealed).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                not_found:
                  summary: not_found
                  value:
                    ok: false
                    error:
                      code: not_found
                      message: Not found
        '422':
          description: >-
            `invalid_params`: The body fails the request schema: a required
            field is missing or a value has the wrong type or format. The
            message lists every issue as `field: problem`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                invalid_params:
                  summary: invalid_params
                  value:
                    ok: false
                    error: 'run_id: Required'
                    code: invalid_params
        '500':
          description: >-
            `internal_error`: An unexpected server fault. Retry later; if it
            persists, report it with the time of the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                internal_error:
                  summary: internal_error
                  value:
                    ok: false
                    error: Internal server error
                    code: internal_error
      security:
        - BearerAuth: []
components:
  schemas:
    RunData:
      type: object
      properties:
        run_id:
          type: string
          description: Hub run id (primary key)
        workspace_id:
          type: string
          description: Workspace UUID
        team_id:
          type: string
          description: Team UUID
        daemon_id:
          type: string
          nullable: true
          description: Daemon id executing the run, or null
        realm_id:
          type: string
          nullable: true
          description: Realm id snapshotted at create
        realm_slug:
          type: string
          nullable: true
          description: Slug of that realm (runs/get list rows)
        org_slug:
          type: string
          nullable: true
          description: Slug of the realm\
        parent_run_id:
          type: string
          nullable: true
          description: Parent run id for nested runs
        parent_phase:
          type: string
          nullable: true
          description: Parent phase that spawned this run
        root_run_id:
          type: string
          nullable: true
          description: Top-level ancestor run id
        call_path:
          type: string
          nullable: true
          description: JSON array of parent phase names
        call_depth:
          type: number
          description: Length of call_path
        iteration_key:
          type: string
          nullable: true
          description: Map iteration key, or null
        run_name:
          type: string
          nullable: true
          description: Optional display name
        state:
          type: string
          description: Lifecycle state (running, completed, failed, …)
        inputs:
          type: object
          additionalProperties: true
          nullable: true
          description: Run inputs (parsed JSON or raw)
        error:
          type: string
          nullable: true
          description: Terminal error message when failed/crashed
        execution_type:
          type: string
          description: Execution type (e.g. local)
        current_pid:
          type: number
          nullable: true
          description: OS pid of current agent process
        current_phase:
          type: string
          nullable: true
          description: Phase currently executing
        external_id:
          type: string
          nullable: true
          description: External correlation id
        context_labels:
          type: object
          additionalProperties: true
          nullable: true
          description: Context labels map or JSON string
        reviewers:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          nullable: true
          description: Reviewers per human phase chosen at run start, or null
        notify_channels:
          type: array
          items:
            type: string
          nullable: true
          description: >-
            Notification channels chosen at run start for its lifecycle events,
            or null
        lease_expires_at:
          type: number
          nullable: true
          description: Action lease expiry (unix ms)
        started_at:
          type: number
          description: Start time (unix ms)
        completed_at:
          type: number
          nullable: true
          description: Completion time (unix ms)
        team_label:
          type: string
          nullable: true
          description: Canonical @scope/team label
        workspace_name:
          type: string
          nullable: true
          description: Workspace display name
        workspace_dir:
          type: string
          nullable: true
          description: Workspace absolute path
        last_updated_at:
          type: number
          nullable: true
          description: Best-effort last activity (unix ms)
        pending_control:
          type: object
          properties:
            tx_id:
              type: string
              description: Command outbox transaction id
            endpoint:
              type: string
              description: Outbox path of the pending control command
            enqueued_at:
              type: number
              description: When the command was queued (unix ms)
            attempts:
              type: number
              description: Delivery attempts so far
            max_attempts:
              type: number
              description: Max delivery attempts before permanent failure
            delivered_at:
              type: number
              nullable: true
              description: When last delivered to daemon (unix ms)
            last_error:
              type: string
              nullable: true
              description: Last delivery error message
            ack_status:
              type: string
              nullable: true
              description: Ack status when partially acked
          required:
            - tx_id
            - endpoint
            - enqueued_at
            - attempts
            - max_attempts
            - delivered_at
            - last_error
            - ack_status
          description: In-flight control command for the detail banner
          nullable: true
        force_terminate:
          type: object
          properties:
            already_terminated:
              type: boolean
              description: True when force_terminated_at is set
            terminated_at:
              type: number
              nullable: true
              description: Force-terminate time (unix ms)
            terminated_by_user_id:
              type: string
              nullable: true
              description: User id who force-terminated
            terminated_reason:
              type: string
              nullable: true
              description: Reason string stamped on force-terminate
            eligible:
              type: boolean
              description: Whether force-terminate may be offered now
            trigger:
              type: string
              enum:
                - stale_cancel
                - daemon_offline
                - lease_expired
              nullable: true
              description: Which condition tripped eligibility
            blocker:
              type: string
              nullable: true
              description: Human message when not eligible
          required:
            - already_terminated
            - terminated_at
            - terminated_by_user_id
            - terminated_reason
            - eligible
            - trigger
            - blocker
          description: Force-terminate eligibility / outcome
          nullable: true
        state_lost_at:
          type: number
          nullable: true
          description: When daemon reported run_not_found (unix ms)
        team_version_id:
          type: string
          nullable: true
          description: Published team version id when known
        history:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                description: >-
                  run.started, run.resume_requested, run.resumed, run.completed,
                  run.failed, run.crashed or run.cancelled
              at:
                type: number
                description: Unix ms
              from_phase:
                type: string
                nullable: true
                description: Phase a resume started from
              phase:
                type: string
                nullable: true
                description: Phase current at the time
              error:
                type: string
                nullable: true
              actor:
                type: object
                properties:
                  id:
                    type: string
                  username:
                    type: string
                    nullable: true
                  display_name:
                    type: string
                    nullable: true
                required:
                  - id
                  - username
                  - display_name
                nullable: true
                description: Who did it, when a person did (resume requests)
            required:
              - type
              - at
              - from_phase
              - phase
              - error
              - actor
          description: 'Only with `with_history: true`'
      required:
        - run_id
        - workspace_id
        - team_id
        - daemon_id
        - realm_id
        - parent_run_id
        - parent_phase
        - root_run_id
        - call_path
        - call_depth
        - iteration_key
        - run_name
        - state
        - inputs
        - error
        - execution_type
        - current_pid
        - current_phase
        - external_id
        - context_labels
        - lease_expires_at
        - started_at
        - completed_at
      description: Run resource on the wire
    HubErr:
      type: object
      required:
        - ok
        - error
      description: >-
        Every failure. Route-policy denials (401/403/404, and 400 when neither
        realm_id nor org_id was sent) answer `error` as `{ code, message }`;
        errors raised by the endpoint answer `error` as the message with the
        code beside it in `code`. Every error has a code. See
        [Errors](/hub-api/errors).
      properties:
        ok:
          type: boolean
          description: Always false on error
        error:
          description: The message, or `{ code, message }` for an access denial.
          oneOf:
            - type: string
            - type: object
              required:
                - code
                - message
              properties:
                code:
                  type: string
                message:
                  type: string
        code:
          type: string
          description: Stable error code of an endpoint error.
        details:
          type: object
          additionalProperties: true
          description: Structured detail, when there is some.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: cliq_tok_* | cliq_dt_*
      description: >-
        User PAT (`cliq_tok_…`, including session-scoped) or realm token
        (`cliq_dt_…`).

````

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