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

# Record a new run

> A daemon records a run it has started, so CliqHub shows it. CliqHub also records the
workspace (from `workspace_path`) and links the team. Sending a run that already exists
updates it and marks it running again, so daemons can safely resend. A run name is
generated when none is sent.

Daemon only: requires the daemon's realm token (`cliq_dt_…`); the record is created in that token's realm.



## OpenAPI

````yaml /openapi/hub-by-tag/hub-runs.yaml post /v1/runs/create
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/create:
    post:
      tags:
        - Runs
      summary: Record a new run
      description: >-
        A daemon records a run it has started, so CliqHub shows it. CliqHub also
        records the

        workspace (from `workspace_path`) and links the team. Sending a run that
        already exists

        updates it and marks it running again, so daemons can safely resend. A
        run name is

        generated when none is sent.


        Daemon only: requires the daemon's realm token (`cliq_dt_…`); the record
        is created in that token's realm.
      operationId: POST_v1_runs_create
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                workspace_id:
                  type: string
                  description: The daemon's workspace id.
                team_id:
                  type: string
                  description: The team's id.
                workspace_path:
                  type: string
                  minLength: 1
                  description: >-
                    Absolute workspace folder on the daemon; CliqHub records the
                    workspace by it.
                workspace_name:
                  type: string
                  nullable: true
                  description: Workspace display name.
                run_id:
                  type: string
                  format: uuid
                  description: The daemon's run id. CliqHub generates one when omitted.
                daemon_id:
                  type: string
                  minLength: 1
                  description: The daemon running it (required).
                run_name:
                  type: string
                  description: Display name.
                parent_run_id:
                  type: string
                  description: For a sub-run, the run that started it.
                parent_phase:
                  type: string
                  description: For a sub-run, the phase of the parent that started it.
                inputs:
                  type: object
                  additionalProperties: true
                  description: The run's inputs.
                external_id:
                  type: string
                  maxLength: 256
                  description: The caller's correlation id (`run_context.id`).
                context_labels:
                  type: object
                  additionalProperties:
                    type: string
                  description: Labels sent at start.
                execution_type:
                  type: string
                  description: '`local` or `docker`.'
              required:
                - workspace_id
                - team_id
                - daemon_id
            examples:
              default:
                value:
                  run_id: 0c8d7e6f-5a4b-4c3d-9e2f-1a0b9c8d7e6f
                  workspace_id: 9b2e6f10-4c3a-4e7d-8f21-6a5b4c3d2e1f
                  workspace_path: /home/dev/acme-api
                  team_id: 3f6c2a8e-6b1d-4c1e-9a57-0d2f4b8e91c4
                  daemon_id: 7d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d
                  run_name: fix-login-timeout
                  inputs:
                    pr_url: https://github.com/acme/api/pull/42
      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/RunCreateData'
              example:
                ok: true
                data:
                  run_id: 0c8d7e6f-5a4b-4c3d-9e2f-1a0b9c8d7e6f
        '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`: A user token was used, or the daemon is not in the
            token's realm.


            `forbidden`: `daemon_id` is not a member of the token's realm.
          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
                forbidden (endpoint):
                  summary: forbidden (endpoint)
                  value:
                    ok: false
                    error: >-
                      Daemon '7d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d' is not a
                      member of this realm
                    code: forbidden
        '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: 'workspace_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:
    RunCreateData:
      type: object
      properties:
        run_id:
          type: string
          minLength: 1
          description: Newly created run id
      required:
        - run_id
    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.