> ## 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.

# Start a run

> Starts a run of a team, in one of two ways:

- **On a realm** (`realm_id`): CliqHub offers the run to every online daemon of the realm
  and the first to claim it runs it. The reply is the queue item, already `claimed`.
- **On one daemon** (`daemon_id`, with `workspace_id` and `team_id`): CliqHub sends the run
  to that daemon. The reply has the new `run_id`.

Before sending, CliqHub checks the team's required inputs, that the `reviewers` name
phases the team has, that `notify_channels` exist in the realm, and that every custom
agent the team uses is registered in the organization. Inputs can be sent as `inputs`
or `run_context.inputs`; `run_context.id` is your own correlation id.

Requires a realm operator (or higher) with the `teams.run` permission on the realm given by `realm_id`. When you target daemons with `daemon_id` instead, you need that role on each daemon's realm. Token scope dispatch.



## OpenAPI

````yaml /openapi/hub-by-tag/hub-runs.yaml post /v1/runs/enqueue
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/enqueue:
    post:
      tags:
        - Runs
      summary: Start a run
      description: >-
        Starts a run of a team, in one of two ways:


        - **On a realm** (`realm_id`): CliqHub offers the run to every online
        daemon of the realm
          and the first to claim it runs it. The reply is the queue item, already `claimed`.
        - **On one daemon** (`daemon_id`, with `workspace_id` and `team_id`):
        CliqHub sends the run
          to that daemon. The reply has the new `run_id`.

        Before sending, CliqHub checks the team's required inputs, that the
        `reviewers` name

        phases the team has, that `notify_channels` exist in the realm, and that
        every custom

        agent the team uses is registered in the organization. Inputs can be
        sent as `inputs`

        or `run_context.inputs`; `run_context.id` is your own correlation id.


        Requires a realm operator (or higher) with the `teams.run` permission on
        the realm given by `realm_id`. When you target daemons with `daemon_id`
        instead, you need that role on each daemon's realm. Token scope
        dispatch.
      operationId: POST_v1_runs_enqueue
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                realm_id:
                  type: string
                  minLength: 1
                  description: >-
                    Start the run on whichever online daemon of this realm
                    claims it. Send this or `daemon_id`.
                daemon_id:
                  type: string
                  minLength: 1
                  description: >-
                    Start the run on this daemon. Send this or `realm_id`; needs
                    `workspace_id` and `team_id`.
                team_id:
                  type: string
                  minLength: 1
                  description: The team to run (id, or `scope/slug` on the realm path).
                workspace_id:
                  type: string
                  minLength: 1
                  description: 'Workspace to run in (daemon path: required).'
                workspace_path:
                  type: string
                  description: >-
                    Absolute folder on the daemon, when the workspace is not
                    known to CliqHub yet.
                manifest_yaml:
                  type: string
                  description: Run this manifest instead of the installed team's.
                run_name:
                  type: string
                  description: Display name. A name is generated when omitted.
                execution_type:
                  type: string
                  enum:
                    - local
                    - docker
                  description: '`local` (default) or `docker`.'
                priority:
                  type: integer
                  description: Higher numbers are offered first when the realm has a queue.
                inputs:
                  type: object
                  additionalProperties:
                    type: object
                    additionalProperties: true
                  description: Team inputs by name.
                run_context:
                  type: object
                  properties:
                    id:
                      type: string
                      maxLength: 256
                    labels:
                      type: object
                      additionalProperties:
                        type: string
                    inputs:
                      type: object
                      additionalProperties:
                        type: object
                        additionalProperties: true
                  description: >-
                    Correlation `id`, `labels` stored with the run, and
                    `inputs`.
                payload:
                  type: object
                  additionalProperties: true
                  description: Older form of the realm request; prefer the fields above.
                reviewers:
                  type: object
                  additionalProperties:
                    type: array
                    items:
                      type: string
                      minLength: 1
                      maxLength: 100
                    minItems: 1
                    maxItems: 100
                  description: >-
                    Reviewers per human phase for this run: { phase: [username]
                    }; replaces the team defaults for those phases
                notify_channels:
                  type: array
                  items:
                    type: string
                    minLength: 1
                    maxLength: 200
                  minItems: 1
                  maxItems: 200
                  description: >-
                    Notification channels (name or id in the run's realm) that
                    receive this run's lifecycle events instead of the realm
                    rules
            examples:
              realm:
                summary: Any daemon of the realm
                value:
                  realm_id: 5b0c3a7e-2f4d-4b8e-9a51-7c1d2e3f4a5b
                  team_id: 3f6c2a8e-6b1d-4c1e-9a57-0d2f4b8e91c4
                  inputs:
                    pr_url: https://github.com/acme/api/pull/42
                  reviewers:
                    approve:
                      - sshah
              daemon:
                summary: One daemon and workspace
                value:
                  daemon_id: 7d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d
                  workspace_id: 9b2e6f10-4c3a-4e7d-8f21-6a5b4c3d2e1f
                  team_id: 3f6c2a8e-6b1d-4c1e-9a57-0d2f4b8e91c4
                  run_name: fix-login-timeout
                  run_context:
                    id: github-run-9876543210
                    inputs:
                      pr_url: https://github.com/acme/api/pull/42
      responses:
        '200':
          description: >-
            Realm path: `{ item }`, the claimed queue item. Daemon path: `{
            run_id, daemon_id, accepted }`.
          content:
            application/json:
              schema:
                type: object
                required:
                  - ok
                  - data
                properties:
                  ok:
                    type: boolean
                    enum:
                      - true
                    description: Always `true` on success.
                  data:
                    oneOf:
                      - $ref: '#/components/schemas/RunEnqueueData'
                      - $ref: '#/components/schemas/RunDispatchData'
              examples:
                realm:
                  summary: Realm path
                  value:
                    ok: true
                    data:
                      item:
                        id: e1d2c3b4-a5f6-4789-8a0b-1c2d3e4f5a6b
                        realm_id: 5b0c3a7e-2f4d-4b8e-9a51-7c1d2e3f4a5b
                        kind: run
                        payload:
                          team_id: 3f6c2a8e-6b1d-4c1e-9a57-0d2f4b8e91c4
                        priority: 0
                        status: claimed
                        claimed_by: 7d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d
                        claimed_at: 1759834200500
                        run_id: 0c8d7e6f-5a4b-4c3d-9e2f-1a0b9c8d7e6f
                        results: null
                        submitted_by: 1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d
                        submitted_at: 1759834200000
                        error: null
                        created_at: 1759834200000
                        updated_at: 1759834200500
                daemon:
                  summary: Daemon path
                  value:
                    ok: true
                    data:
                      run_id: 0c8d7e6f-5a4b-4c3d-9e2f-1a0b9c8d7e6f
                      daemon_id: 7d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d
                      accepted: true
        '400':
          description: >-
            `bad_request`: Required team inputs are missing, the team uses
            custom agents not registered in the organization, the realm has no
            online daemon, or no daemon claimed the run in time.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                bad_request:
                  summary: bad_request
                  value:
                    ok: false
                    error: >-
                      No online daemons in this realm — enroll a daemon and
                      retry
                    code: bad_request
        '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 realm but your role there 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 realm does not exist, was deleted, or you are not a
            member of it (404 rather than 403, so its existence is not
            revealed).


            `not_found`: The daemon or team does not exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                not_found:
                  summary: not_found
                  value:
                    ok: false
                    error:
                      code: not_found
                      message: Not found
                not_found (endpoint):
                  summary: not_found (endpoint)
                  value:
                    ok: false
                    error: Daemon '7d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d' not found
                    code: not_found
        '422':
          description: >-
            `invalid_params`: Both or neither of `realm_id` and `daemon_id` were
            sent, `workspace_id` or `team_id` is missing, `reviewers` names
            unknown users or phases the team does not have, or `notify_channels`
            names channels not in the realm. `details.field` says which.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                invalid_params:
                  summary: invalid_params
                  value:
                    ok: false
                    error: 'Reviewers set for phases the team does not have: aprove'
                    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:
    RunEnqueueData:
      type: object
      properties:
        item:
          type: object
          properties:
            id:
              type: string
              format: uuid
              description: Queue item UUID
            realm_id:
              type: string
              description: Realm that owns the queue
            kind:
              type: string
              description: Queue kind (run, install, …)
            payload:
              type: object
              additionalProperties:
                type: object
                additionalProperties: true
              description: Kind-specific payload
            priority:
              type: number
              description: Higher wins claim order
            status:
              type: string
              description: queued | offered | claimed | …
            claimed_by:
              type: string
              nullable: true
              description: Daemon id that claimed, or null
            claimed_at:
              type: number
              nullable: true
              description: Claim time (unix ms)
            run_id:
              type: string
              nullable: true
              description: Linked run id when set
            results:
              type: object
              additionalProperties: true
              nullable: true
              description: Terminal results payload
            submitted_by:
              type: string
              description: User id that enqueued
            submitted_at:
              type: number
              description: Enqueue time (unix ms)
            error:
              type: string
              nullable: true
              description: Error message when failed
            created_at:
              type: number
              description: Row create time (unix ms)
            updated_at:
              type: number
              description: Row update time (unix ms)
          required:
            - id
            - realm_id
            - kind
            - payload
            - priority
            - status
            - claimed_by
            - claimed_at
            - run_id
            - results
            - submitted_by
            - submitted_at
            - error
            - created_at
            - updated_at
          description: Created or offered queue item
      required:
        - item
      additionalProperties: true
    RunDispatchData:
      type: object
      properties:
        run_id:
          type: string
          description: Run id dispatched
        daemon_id:
          type: string
          description: Target daemon id
        accepted:
          type: boolean
          description: Whether the daemon accepted the execute outbox
      required:
        - run_id
        - daemon_id
        - accepted
    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.