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

# Validate a token

> Checks a token someone presented and says whose it is. Daemons use this to accept
`cliq_tok_…` tokens from callers on other hosts. An invalid token is not an error: the
reply has `valid: false`.

Requires a signed-in user token (`Authorization: Bearer cliq_tok_…`). Results are limited to what that user can see. A daemon's realm token (`cliq_dt_…`) from the same realm may also read it. Daemon: resolves a token presented to it.



## OpenAPI

````yaml /openapi/hub-by-tag/hub-auth.yaml post /v1/auth/validate_token
openapi: 3.0.3
info:
  title: 'CliqHub API: Auth'
  version: 1.0.0
  description: >-
    API tokens. Every call to CliqHub carries one as `Authorization: Bearer
    <token>`:


    - **User token** (`cliq_tok_…`): acts as you, optionally limited by
    `permissions` (which
      organizations and realms, and read / write / admin per kind of resource). `cliq login`
      stores one; mint more for scripts and CI.
    - **Realm token** (`cliq_dt_…`): what a daemon uses to join and work in a
    realm. Any
      member of the realm can mint one.
    - **A2A token** (`cliq_a2a_…`): what outside agents send to a realm's A2A
    endpoint. One per
      realm; minting a new one replaces the old.
    - **Dispatch token**: a short-lived signed token CliqHub uses when it sends
    work to a
      daemon; each realm has a dispatch key pair for it.

    A token is shown only when it is minted or rotated. A restricted token
    cannot mint a token

    wider than itself.
servers:
  - url: https://{host}
    variables:
      host:
        default: cliqhub.io
        description: CliqHub host
security: []
tags:
  - name: Auth
    description: >-
      API tokens. Every call to CliqHub carries one as `Authorization: Bearer
      <token>`:


      - **User token** (`cliq_tok_…`): acts as you, optionally limited by
      `permissions` (which
        organizations and realms, and read / write / admin per kind of resource). `cliq login`
        stores one; mint more for scripts and CI.
      - **Realm token** (`cliq_dt_…`): what a daemon uses to join and work in a
      realm. Any
        member of the realm can mint one.
      - **A2A token** (`cliq_a2a_…`): what outside agents send to a realm's A2A
      endpoint. One per
        realm; minting a new one replaces the old.
      - **Dispatch token**: a short-lived signed token CliqHub uses when it
      sends work to a
        daemon; each realm has a dispatch key pair for it.

      A token is shown only when it is minted or rotated. A restricted token
      cannot mint a token

      wider than itself.
paths:
  /v1/auth/validate_token:
    post:
      tags:
        - Auth
      summary: Validate a token
      description: >-
        Checks a token someone presented and says whose it is. Daemons use this
        to accept

        `cliq_tok_…` tokens from callers on other hosts. An invalid token is not
        an error: the

        reply has `valid: false`.


        Requires a signed-in user token (`Authorization: Bearer cliq_tok_…`).
        Results are limited to what that user can see. A daemon's realm token
        (`cliq_dt_…`) from the same realm may also read it. Daemon: resolves a
        token presented to it.
      operationId: POST_v1_auth_validate_token
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                token:
                  type: string
                  minLength: 1
                  description: Plaintext `cliq_tok_…` or `cliq_dt_…` to introspect
              required:
                - token
            examples:
              default:
                value:
                  token: cliq_tok_4f9a…
      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:
                    type: object
                    required:
                      - valid
                    properties:
                      valid:
                        type: boolean
                      type:
                        type: string
                        enum:
                          - user
                          - realm
                          - daemon
                      token_id:
                        type: string
                      user_id:
                        type: string
                        description: User tokens.
                      realm_id:
                        type: string
                        description: Realm tokens.
                      realm_ids:
                        type: array
                        items:
                          type: string
                      permissions:
                        $ref: '#/components/schemas/TokenPermissions'
              examples:
                valid:
                  summary: Valid user token
                  value:
                    ok: true
                    data:
                      valid: true
                      type: user
                      token_id: '42'
                      user_id: 1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d
                      permissions:
                        access:
                          runs:
                            - read
                invalid:
                  summary: Unknown or revoked
                  value:
                    ok: true
                    data:
                      valid: false
                      type: user
        '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
        '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: 'token: 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:
    TokenPermissions:
      type: object
      properties:
        domains:
          type: object
          properties:
            orgs:
              oneOf:
                - type: string
                  enum:
                    - '*'
                - description: >-
                    Unsupported Zod expression `// Org ids are UUIDs; integers
                    kept for legacy clients (B6).
                        z.array(z.union([z.string().min(1), z.number().int(), z`
                  type: object
                  additionalProperties: true
              description: >-
                Org ids where this credential may act, or `*` for all orgs the
                subject can reach
            realms:
              oneOf:
                - type: string
                  enum:
                    - '*'
                - type: array
                  items:
                    oneOf:
                      - type: string
                        minLength: 1
                      - type: string
                        enum:
                          - '*'
                  minItems: 1
              description: Realm ids where this credential may act, or `*`
        access:
          type: object
          properties:
            users:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            orgs:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            scopes:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
              description: >-
                Manage the Hub scopes catalog (create/update/delete package
                namespaces).
            teams:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            drafts:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            tokens:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            realms:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            daemons:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            runs:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            dispatch:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            workspaces:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            agents:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            settings:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            notifications:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            builder:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            hug:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
            reports:
              type: array
              items:
                type: string
                enum:
                  - read
                  - write
                  - admin
              minItems: 1
          description: >-
            Per-entity levels: read (get/list), write (create/update/dispatch),
            admin (destructive tenancy)
        auto_enrolled:
          type: boolean
          description: Set by daemon bootstrap mint — revoked on `cliq logout`.
      description: 'Token grant: domains (where) + access (read|write|admin per entity)'
    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.