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

# Offer a run

> CliqHub offers a run that only one daemon may take. The daemon races to claim it on
CliqHub with its realm token; the winner is sent Execute a run next. Losing the race is
a normal reply (`claimed: false`), not an error.

No credential is needed from this machine. From another host, send `Authorization: Bearer` with a dispatch token CliqHub signed for this daemon or a `cliq_tok_…` personal token of a user in the daemon's realm; this only works once the daemon is connected to CliqHub. See [Authentication](/daemon-api/overview#authentication).



## OpenAPI

````yaml /openapi/daemon-by-tag/daemon-commands.yaml post /v1/offer_job
openapi: 3.1.0
info:
  title: cliqd API
  version: 1.9.48
  description: >-
    HTTP API of `cliqd`, the local Cliq daemon. Generated from the daemon source
    by `scripts/generate_daemon_openapi.mjs` — do not edit by hand. See the
    [overview](/daemon-api/overview).
servers:
  - url: http://127.0.0.1:4900
    description: Local daemon (default port; `CLIQ_DAEMON_PORT` changes it)
security: []
tags:
  - name: Daemon Hub commands
    description: >-
      How CliqHub hands work to this daemon: start or offer a run, cancel or
      resume one, install

      or uninstall a team, register a workspace and assign teams to it. CliqHub
      sends them when

      someone acts in CliqHub, over the daemon's CliqHub connection with a
      dispatch token. You

      rarely call them yourself; use the Teams, Workspaces and Runs endpoints
      instead.


      Every command carries `tx_id`, CliqHub's command id. A repeated `tx_id`
      returns the first

      reply instead of running the command again, and the daemon acknowledges
      each command back

      to CliqHub (`ok`, or `error` with the reason), including a body that fails
      validation.
paths:
  /v1/offer_job:
    post:
      tags:
        - Daemon Hub commands
      summary: Offer a run
      description: >-
        CliqHub offers a run that only one daemon may take. The daemon races to
        claim it on

        CliqHub with its realm token; the winner is sent Execute a run next.
        Losing the race is

        a normal reply (`claimed: false`), not an error.


        No credential is needed from this machine. From another host, send
        `Authorization: Bearer` with a dispatch token CliqHub signed for this
        daemon or a `cliq_tok_…` personal token of a user in the daemon's realm;
        this only works once the daemon is connected to CliqHub. See
        [Authentication](/daemon-api/overview#authentication).
      operationId: daemon_post_offer_job
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                queue_item_id:
                  type: string
                  minLength: 1
                  description: Hub queue item to claim
                daemon_id:
                  description: 'Claiming daemon id (default: this daemon)'
                  type: string
                  minLength: 1
                kind:
                  description: Job kind (logging only)
                  type: string
                payload:
                  description: Job payload (`team_id` is logged)
                  type: object
                  propertyNames:
                    type: string
                  additionalProperties: {}
                tx_id:
                  description: Hub command id (dedup + ack)
                  type: string
              required:
                - queue_item_id
              additionalProperties: {}
            examples:
              default:
                value:
                  queue_item_id: e1d2c3b4-a5f6-4789-8a0b-1c2d3e4f5a6b
                  kind: run
                  payload:
                    team_id: 3f6c2a8e-6b1d-4c1e-9a57-0d2f4b8e91c4
                  tx_id: tx-5d2c9a
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                required:
                  - ok
                  - data
                properties:
                  ok:
                    type: boolean
                    const: true
                  data:
                    $ref: '#/components/schemas/OfferResult'
              examples:
                won:
                  summary: Claimed
                  value:
                    ok: true
                    data:
                      claimed: true
                      daemon_id: 7d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d
                lost:
                  summary: Another daemon won
                  value:
                    ok: true
                    data:
                      claimed: false
                      daemon_id: 7d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d
        '400':
          description: >-
            `PAYLOAD_INVALID` — The body (query string for `GET`) fails the
            request schema. `details` lists each issue.


            `BAD_REQUEST` — The body is not valid JSON or is larger than the
            route allows (10 MB; artifact uploads more).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorReply'
              examples:
                PAYLOAD_INVALID:
                  summary: PAYLOAD_INVALID
                  value:
                    ok: false
                    error:
                      code: PAYLOAD_INVALID
                      message: >-
                        queue_item_id: Invalid input: expected string, received
                        undefined
                      details:
                        - path: queue_item_id
                          message: 'Invalid input: expected string, received undefined'
                BAD_REQUEST:
                  summary: BAD_REQUEST
                  value:
                    ok: false
                    error:
                      code: BAD_REQUEST
                      message: >-
                        Request body could not be read: Unexpected token } in
                        JSON at position 12
        '401':
          description: >-
            `UNAUTHORIZED` — A caller on another host sent no `Authorization:
            Bearer` token, or one that does not verify (expired, wrong
            audience).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorReply'
              examples:
                UNAUTHORIZED:
                  summary: UNAUTHORIZED
                  value:
                    ok: false
                    error:
                      code: UNAUTHORIZED
                      message: Missing or invalid Authorization Bearer token
        '403':
          description: >-
            `WEB_REQUEST_REFUSED` — The request carries an `Origin` header (it
            came from a web page).


            `HOST_NOT_LOCAL` — A loopback caller addressed a `Host` other than
            localhost (DNS rebinding guard).


            `LOCAL_ONLY` — The daemon isn't connected to CliqHub (no dispatch
            key) and the caller is on another host.


            `FORBIDDEN` — A `cliq_tok_…` token's user is not in this daemon's
            realm ACL, or the ACL is not loaded yet.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorReply'
              examples:
                WEB_REQUEST_REFUSED:
                  summary: WEB_REQUEST_REFUSED
                  value:
                    ok: false
                    error:
                      code: WEB_REQUEST_REFUSED
                      message: cliqd doesn't accept requests from web pages
                HOST_NOT_LOCAL:
                  summary: HOST_NOT_LOCAL
                  value:
                    ok: false
                    error:
                      code: HOST_NOT_LOCAL
                      message: cliqd only answers requests addressed to localhost
                LOCAL_ONLY:
                  summary: LOCAL_ONLY
                  value:
                    ok: false
                    error:
                      code: LOCAL_ONLY
                      message: >-
                        This cliqd isn't connected to CliqHub yet, so from
                        another machine it only accepts a local token (minted by
                        tokens/create on the machine running cliqd)
                FORBIDDEN:
                  summary: FORBIDDEN
                  value:
                    ok: false
                    error:
                      code: FORBIDDEN
                      message: Access denied — identity not in realm ACL
        '500':
          description: >-
            `INTERNAL_ERROR` — CliqHub could not be reached, or another
            unexpected fault.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorReply'
              examples:
                INTERNAL_ERROR:
                  summary: INTERNAL_ERROR
                  value:
                    ok: false
                    error:
                      code: INTERNAL_ERROR
                      message: >-
                        cliqd hit an unexpected error (request 7f3a…). Details
                        are in the cliqd log.
        '502':
          description: >-
            `CLAIM_FAILED` — CliqHub refused the claim for a reason other than
            losing the race (the message is CliqHub's).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorReply'
              examples:
                CLAIM_FAILED:
                  summary: CLAIM_FAILED
                  value:
                    ok: false
                    error:
                      code: CLAIM_FAILED
                      message: Hub claim returned 403
        '503':
          description: >-
            `DAEMON_ID_UNKNOWN` — No `daemon_id` was sent and this daemon has no
            id yet (not registered with CliqHub). CliqHub offers the run
            elsewhere.


            `HUB_CREDENTIALS_MISSING` — This daemon has no realm token or
            CliqHub sign-in to claim with.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorReply'
              examples:
                DAEMON_ID_UNKNOWN:
                  summary: DAEMON_ID_UNKNOWN
                  value:
                    ok: false
                    error:
                      code: DAEMON_ID_UNKNOWN
                      message: daemon_id unknown
                HUB_CREDENTIALS_MISSING:
                  summary: HUB_CREDENTIALS_MISSING
                  value:
                    ok: false
                    error:
                      code: HUB_CREDENTIALS_MISSING
                      message: no hub credentials
      security:
        - {}
        - DaemonBearer: []
components:
  schemas:
    OfferResult:
      type: object
      required:
        - claimed
        - daemon_id
      properties:
        claimed:
          type: boolean
          description: >-
            `true` when this daemon won the run (CliqHub sends Execute a run
            next); `false` when another daemon claimed it first.
          example: true
        daemon_id:
          type: string
          description: The daemon id the claim was made for.
          example: 7d1c2b3a-4e5f-4a6b-8c7d-9e0f1a2b3c4d
    ErrorReply:
      type: object
      description: >-
        Every failure. Switch on `error.code` — it is stable; `message` is for
        people and may change.
      required:
        - ok
        - error
      properties:
        ok:
          type: boolean
          const: false
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Stable error code. See [Errors](/daemon-api/errors).
              example: TEAM_NOT_FOUND
            message:
              type: string
              description: What went wrong and, where possible, what to do.
              example: Team 'acme/code-review' not found
            details:
              description: >-
                Structured detail when there is some: the list of schema issues
                for `PAYLOAD_INVALID`, the agent problems for
                `TEAM_AGENT_CONFIG_REQUIRED`, …
  securitySchemes:
    DaemonBearer:
      type: http
      scheme: bearer
      description: >-
        Not needed from the same machine. From another host: a dispatch JWT
        CliqHub signed for this daemon, or a `cliq_tok_…` personal token whose
        user is in the daemon's realm.

````

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