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

# Assign a team to a workspace

> Assigns an installed team to a registered workspace so it can run there. Name the
workspace by `workspace_dir` or `workspace_id` (the id wins when both are sent) and the
team by `scope` + `slug`. A workspace can have several teams; Start a run then needs
`team_ref` to pick one.

The team's manifest is checked first: every sub-team it calls (`type: team` or `map`
phases) must be installed too, and the tree of teams may not loop or grow too deep or large.
The daemon's current settings are captured with the assignment, and runs of this team
in this workspace use that snapshot. Assigning a team that is already assigned succeeds
and refreshes the snapshot.

From the CLI: `cliq assemble @acme/code-review`.

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-workspaces.yaml post /v1/workspaces/assemble_team
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 Workspaces
    description: >-
      A **workspace** is a project folder registered with this daemon. You
      register it once

      (Register a workspace, `cliq init`), assign one or more installed teams to
      it

      (Assign a team to a workspace, `cliq assemble`), then start runs in it
      (Start a run,

      `cliq run`). Workspaces live in the daemon's own catalog; the only thing
      written into

      the folder is an empty `.cliq/` directory.


      Most endpoints take the absolute folder path as `workspace_dir`; assign
      and remove also

      accept the catalog `workspace_id`. Relative paths are resolved against the
      daemon's

      working directory, so always send absolute paths.
paths:
  /v1/workspaces/assemble_team:
    post:
      tags:
        - Daemon Workspaces
      summary: Assign a team to a workspace
      description: >-
        Assigns an installed team to a registered workspace so it can run there.
        Name the

        workspace by `workspace_dir` or `workspace_id` (the id wins when both
        are sent) and the

        team by `scope` + `slug`. A workspace can have several teams; Start a
        run then needs

        `team_ref` to pick one.


        The team's manifest is checked first: every sub-team it calls (`type:
        team` or `map`

        phases) must be installed too, and the tree of teams may not loop or
        grow too deep or large.

        The daemon's current settings are captured with the assignment, and runs
        of this team

        in this workspace use that snapshot. Assigning a team that is already
        assigned succeeds

        and refreshes the snapshot.


        From the CLI: `cliq assemble @acme/code-review`.


        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_workspaces_assemble_team
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                workspace_dir:
                  type: string
                  minLength: 1
                  description: Absolute workspace path
                workspace_id:
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  description: Catalog workspace id
                scope:
                  type: string
                  minLength: 1
                  description: Team scope
                slug:
                  type: string
                  minLength: 1
                  description: Team slug
                version:
                  description: Specific version to assemble
                  type: string
                  minLength: 1
                latest:
                  description: When multiple versions exist, pick the latest
                  type: boolean
              required:
                - scope
                - slug
            examples:
              by_path:
                summary: By folder path
                value:
                  workspace_dir: /home/dev/acme-api
                  scope: acme
                  slug: code-review
              by_id:
                summary: By workspace id
                value:
                  workspace_id: 9b2e6f10-4c3a-4e7d-8f21-6a5b4c3d2e1f
                  scope: acme
                  slug: code-review
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                required:
                  - ok
                  - data
                properties:
                  ok:
                    type: boolean
                    const: true
                  data:
                    $ref: '#/components/schemas/WorkspaceAssembleResult'
              example:
                ok: true
                data:
                  workspace_dir: /home/dev/acme-api
                  workspace_id: 9b2e6f10-4c3a-4e7d-8f21-6a5b4c3d2e1f
                  scope: acme
                  slug: code-review
                  team_id: 3f6c2a8e-6b1d-4c1e-9a57-0d2f4b8e91c4
                  already_assembled: false
                  team_count: 1
        '400':
          description: >-
            `PAYLOAD_INVALID` — Neither `workspace_dir` nor `workspace_id` was
            sent, `scope` or `slug` is missing, or `workspace_id` is not a UUID.


            `TEAM_PHASE_REF_INVALID` — A `type: team` phase has a missing or
            malformed team reference.


            `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: 'workspace_dir: workspace_dir or workspace_id is required'
                      details:
                        - path: workspace_dir
                          message: workspace_dir or workspace_id is required
                TEAM_PHASE_REF_INVALID:
                  summary: TEAM_PHASE_REF_INVALID
                  value:
                    ok: false
                    error:
                      code: TEAM_PHASE_REF_INVALID
                      message: A type:team phase has a missing or malformed team ref
                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
        '404':
          description: >-
            `WORKSPACE_NOT_REGISTERED` — The path or id is not a registered
            workspace. Register it first.


            `SCOPE_NOT_FOUND` — This daemon has no team in that scope.


            `TEAM_NOT_FOUND` — The team is not installed here, or a sub-team one
            of its phases calls is not installed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorReply'
              examples:
                WORKSPACE_NOT_REGISTERED:
                  summary: WORKSPACE_NOT_REGISTERED
                  value:
                    ok: false
                    error:
                      code: WORKSPACE_NOT_REGISTERED
                      message: >-
                        Workspace '/home/dev/acme-api' is not registered. Run
                        'cliq init' first.
                SCOPE_NOT_FOUND:
                  summary: SCOPE_NOT_FOUND
                  value:
                    ok: false
                    error:
                      code: SCOPE_NOT_FOUND
                      message: Scope 'acme' not found
                TEAM_NOT_FOUND:
                  summary: TEAM_NOT_FOUND
                  value:
                    ok: false
                    error:
                      code: TEAM_NOT_FOUND
                      message: >-
                        Phase 'fix' references team 'acme/fixer', which is not
                        in the catalog
        '422':
          description: >-
            `TEAM_MANIFEST_INVALID` — The installed manifest no longer parses or
            validates.


            `TEAM_TREE_CYCLE` — The team calls itself, directly or through its
            sub-teams.


            `TEAM_TREE_TOO_DEEP` — Sub-teams nest deeper than the daemon allows.


            `TEAM_TREE_TOO_LARGE` — The team and its sub-teams together are more
            teams than the daemon allows.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorReply'
              examples:
                TEAM_MANIFEST_INVALID:
                  summary: TEAM_MANIFEST_INVALID
                  value:
                    ok: false
                    error:
                      code: TEAM_MANIFEST_INVALID
                      message: Team manifest failed validation
                TEAM_TREE_CYCLE:
                  summary: TEAM_TREE_CYCLE
                  value:
                    ok: false
                    error:
                      code: TEAM_TREE_CYCLE
                      message: Recursive team tree contains a cycle
                TEAM_TREE_TOO_DEEP:
                  summary: TEAM_TREE_TOO_DEEP
                  value:
                    ok: false
                    error:
                      code: TEAM_TREE_TOO_DEEP
                      message: Recursive team tree exceeds the maximum allowed depth
                TEAM_TREE_TOO_LARGE:
                  summary: TEAM_TREE_TOO_LARGE
                  value:
                    ok: false
                    error:
                      code: TEAM_TREE_TOO_LARGE
                      message: Recursive team tree exceeds the maximum allowed size
        '500':
          description: >-
            `INTERNAL_ERROR` — An unexpected daemon fault. The message names the
            request id; the cause is in the cliqd log.
          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.
      security:
        - {}
        - DaemonBearer: []
components:
  schemas:
    WorkspaceAssembleResult:
      type: object
      required:
        - workspace_dir
        - workspace_id
        - scope
        - slug
        - team_id
        - already_assembled
        - team_count
      properties:
        workspace_dir:
          type: string
          example: /home/dev/acme-api
        workspace_id:
          type: string
          format: uuid
          example: 9b2e6f10-4c3a-4e7d-8f21-6a5b4c3d2e1f
        scope:
          type: string
          example: acme
        slug:
          type: string
          example: code-review
        team_id:
          type: string
          format: uuid
          example: 3f6c2a8e-6b1d-4c1e-9a57-0d2f4b8e91c4
        already_assembled:
          type: boolean
          description: >-
            The team was already assigned. The call still succeeds and refreshes
            the team's settings snapshot.
          example: false
        team_count:
          type: integer
          description: Teams assigned to the workspace after this call.
          example: 1
    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.