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

# Build a team with AI

> Builds a team with AI. Choose what to do with `action`:

- `generate` (`intent`): start drafting a whole team from a description. Returns a
  `job_id` at once; poll with `status`.
- `status` (`job_id`): the job's progress (`stage`), then the generated team and its
  validation when `status` is `done`, or `error`.
- `improve_role` (`role_name`, `role_content`, optional `instruction`): a rewritten role prompt.
- `suggest` (`team_name`, optional `description`, `phases`, `roles`): suggestions to improve a team.
- `validate` (`team`): check a team snapshot; returns `valid`, `errors`, `warnings`.
- `chat` (`team`, `message`, `history`): one turn of a conversation about a team; returns a `reply` and proposed `actions`.

Requires a signed-in user token (`Authorization: Bearer cliq_tok_…`). Results are limited to what that user can see.



## OpenAPI

````yaml /openapi/hub-by-tag/hub-teams.yaml post /v1/teams/build
openapi: 3.0.3
info:
  title: 'CliqHub API: Teams'
  version: 1.0.0
  description: >-
    The CliqHub team registry. A team is published under a scope
    (`@acme/code-review`) as

    numbered versions. Create a draft, change it (each change can mint the next
    version),

    publish it to make it installable, then install it on daemons. List teams
    with a

    `realm_id` to see a realm's roster and where each team is installed, or with
    a

    `daemon_id` to see what one daemon has. Build a team with AI drafts a team
    from a

    description.


    Changing a team (update, rename, publish, unpublish, delete) needs its
    author, or the

    publish permission in the organization that owns its scope.
servers:
  - url: https://{host}
    variables:
      host:
        default: cliqhub.io
        description: CliqHub host
security: []
tags:
  - name: Teams
    description: >-
      The CliqHub team registry. A team is published under a scope
      (`@acme/code-review`) as

      numbered versions. Create a draft, change it (each change can mint the
      next version),

      publish it to make it installable, then install it on daemons. List teams
      with a

      `realm_id` to see a realm's roster and where each team is installed, or
      with a

      `daemon_id` to see what one daemon has. Build a team with AI drafts a team
      from a

      description.


      Changing a team (update, rename, publish, unpublish, delete) needs its
      author, or the

      publish permission in the organization that owns its scope.
paths:
  /v1/teams/build:
    post:
      tags:
        - Teams
      summary: Build a team with AI
      description: >-
        Builds a team with AI. Choose what to do with `action`:


        - `generate` (`intent`): start drafting a whole team from a description.
        Returns a
          `job_id` at once; poll with `status`.
        - `status` (`job_id`): the job's progress (`stage`), then the generated
        team and its
          validation when `status` is `done`, or `error`.
        - `improve_role` (`role_name`, `role_content`, optional `instruction`):
        a rewritten role prompt.

        - `suggest` (`team_name`, optional `description`, `phases`, `roles`):
        suggestions to improve a team.

        - `validate` (`team`): check a team snapshot; returns `valid`, `errors`,
        `warnings`.

        - `chat` (`team`, `message`, `history`): one turn of a conversation
        about a team; returns a `reply` and proposed `actions`.


        Requires a signed-in user token (`Authorization: Bearer cliq_tok_…`).
        Results are limited to what that user can see.
      operationId: POST_v1_teams_build
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: string
                  enum:
                    - generate
                    - status
                    - improve_role
                    - suggest
                    - validate
                    - chat
                  description: >-
                    `generate`, `status`, `improve_role`, `suggest`, `validate`
                    or `chat`.
                intent:
                  type: string
                  maxLength: 5000
                  description: 'generate: what the team should do (up to 5000 characters).'
                job_id:
                  type: string
                  description: 'status: the job from `generate`.'
                role_name:
                  type: string
                  description: 'improve_role: the phase whose role to rewrite.'
                role_content:
                  type: string
                  maxLength: 50000
                  description: >-
                    improve_role: the current role prompt (up to 50000
                    characters).
                team_name:
                  type: string
                  description: 'improve_role, suggest: the team''s name.'
                team_description:
                  type: string
                  description: 'improve_role: the team''s description.'
                phases:
                  type: array
                  items:
                    type: object
                    additionalProperties: true
                  description: 'improve_role, suggest: the team''s phase names.'
                instruction:
                  type: string
                  description: 'improve_role: what to focus on.'
                description:
                  type: string
                  description: 'suggest: the team''s description.'
                roles:
                  type: array
                  items:
                    type: object
                    additionalProperties: true
                  description: 'suggest: the team''s roles.'
                team:
                  type: object
                  additionalProperties: true
                  description: >-
                    validate, chat: the team snapshot (as the console's builder
                    holds it).
                message:
                  type: string
                  maxLength: 5000
                  description: 'chat: your message (up to 5000 characters).'
                history:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - assistant
                      content:
                        type: string
                    required:
                      - role
                      - content
                  description: >-
                    chat: earlier turns, each `{ role: user | assistant, content
                    }`.
              required:
                - action
            examples:
              generate:
                value:
                  action: generate
                  intent: >-
                    Review each pull request for security issues and open a Jira
                    ticket for every finding.
              status:
                value:
                  action: status
                  job_id: 2b3c4d5e-6f70-4812-9a3b-4c5d6e7f8091
      responses:
        '200':
          description: Depends on `action`.
          content:
            application/json:
              schema:
                type: object
                required:
                  - ok
                  - data
                properties:
                  ok:
                    type: boolean
                    enum:
                      - true
                    description: Always `true` on success.
                  data:
                    type: object
                    additionalProperties: true
                    properties:
                      job_id:
                        type: string
                        description: generate, status.
                      status:
                        type: string
                        enum:
                          - queued
                          - running
                          - done
                          - error
                        description: generate, status.
                      stage:
                        type: string
                        description: 'generate, status: the step running now.'
                      team:
                        type: object
                        additionalProperties: true
                        description: 'status (done), chat: the generated or updated team.'
                      validation:
                        type: object
                        additionalProperties: true
                        description: 'status (done): the generated team''s validation.'
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                          message:
                            type: string
                        description: status (error).
                      improved_content:
                        type: string
                        description: improve_role.
                      changes_summary:
                        type: string
                        description: improve_role.
                      suggestions:
                        type: array
                        items:
                          type: object
                          additionalProperties: true
                        description: suggest.
                      valid:
                        type: boolean
                        description: validate.
                      errors:
                        type: array
                        items:
                          type: object
                          additionalProperties: true
                        description: validate.
                      warnings:
                        type: array
                        items:
                          type: object
                          additionalProperties: true
                        description: validate.
                      reply:
                        type: string
                        description: chat.
                      actions:
                        type: array
                        items:
                          type: object
                          additionalProperties: true
                        description: 'chat: proposed changes to the team.'
              examples:
                generate:
                  summary: generate
                  value:
                    ok: true
                    data:
                      job_id: 2b3c4d5e-6f70-4812-9a3b-4c5d6e7f8091
                      status: queued
                      stage: queued
                validate:
                  summary: validate
                  value:
                    ok: true
                    data:
                      valid: false
                      errors:
                        - path: phases.1.agent
                          message: Unknown agent 'jira-syncc'
                      warnings: []
        '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 daemon token was used; this route needs a user token.'
          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`: `status`: the job does not exist or has expired.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                not_found:
                  summary: not_found
                  value:
                    ok: false
                    error: >-
                      Generate job '2b3c4d5e-6f70-4812-9a3b-4c5d6e7f8091' not
                      found or expired
                    code: not_found
        '422':
          description: >-
            `invalid_params`: `action` is unknown or a field it needs is missing
            or too long (for example `intent` for `generate`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                invalid_params:
                  summary: invalid_params
                  value:
                    ok: false
                    error: intent is required for generate action
                    code: invalid_params
        '500':
          description: >-
            `internal_error`: An unexpected server fault. Retry later; if it
            persists, report it with the time of the request.


            `generation_failed`: The AI model failed or returned something
            unusable. Try again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HubErr'
              examples:
                internal_error:
                  summary: internal_error
                  value:
                    ok: false
                    error: Internal server error
                    code: internal_error
                generation_failed:
                  summary: generation_failed
                  value:
                    ok: false
                    error: 'Failed to generate roles for phases: review'
                    code: generation_failed
      security:
        - BearerAuth: []
components:
  schemas:
    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.