> ## Documentation Index
> Fetch the complete documentation index at: https://api-documentation.kare-app.fr/llms.txt
> Use this file to discover all available pages before exploring further.

# Parent units with their children nested, for the patrimonial tree view



## OpenAPI

````yaml /api/rs/openapi.json get /rs/units/v1/tree
openapi: 3.0.3
info:
  title: KARE API
  description: Backend API for the KARE platform
  version: dev
servers:
  - url: http://localhost:3000
    description: Local dev
security: []
tags:
  - name: better-auth
    description: >-
      Better Auth's own endpoints (sign-in, session, MFA, password) - generated
      from the audience's live config via `generateOpenAPISchema()`, not
      hand-written.
paths:
  /rs/units/v1/tree:
    get:
      tags:
        - units
      summary: Parent units with their children nested, for the patrimonial tree view
      operationId: listUnitsTreeRSV1
      parameters:
        - schema:
            default: 1
            type: integer
            minimum: 0
            exclusiveMinimum: true
            maximum: 9007199254740991
          in: query
          name: page
          required: false
        - schema:
            default: 50
            type: integer
            minimum: 0
            exclusiveMinimum: true
            maximum: 1000
          in: query
          name: pageSize
          required: false
        - schema:
            example: true
            anyOf:
              - type: boolean
          in: query
          name: countOnly
          required: false
          description: >-
            When true, answers `totalCount` with an empty `data`: the rows are
            never read, so no extend is selected and no transform runs. For a
            badge or a counter.
        - schema:
            type: array
            items:
              type: string
              enum:
                - qrcode
                - buildings
              description: >-
                Extend options (JSON-encoded array, e.g.
                `?extend=["category"]`):

                - "qrcode": Sticker scan URL for the QR code linked to each
                parent unit (null when none).

                - "buildings": Buildings linked to the coque, flat across the
                parent and its children (`unitId` says which).
          in: query
          name: extend
          required: false
        - schema:
            maxItems: 250
            type: array
            items:
              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)$
            example:
              - 550e8400-e29b-41d4-a716-446655440000
              - 6ba7b810-9dad-11d1-80b4-00c04fd430c8
          in: query
          name: whereUnitIds
          required: false
          description: Narrow the tree to the requested unit ids.
        - schema:
            maxItems: 250
            type: array
            items:
              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)$
            example:
              - 550e8400-e29b-41d4-a716-446655440000
              - 6ba7b810-9dad-11d1-80b4-00c04fd430c8
          in: query
          name: whereITIds
          required: false
          description: >-
            Narrow the tree to units linked to the requested technical
            installations.
        - schema:
            type: string
            maxLength: 200
            example: lobby
          in: query
          name: whereText
          required: false
          description: Free-text search across name, serial number and reference.
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        unit:
                          type: object
                          properties:
                            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)$
                            ref:
                              type: string
                              maxLength: 40
                              pattern: ^[A-Z]+-[1-9]\d*(?:-[A-Z]+-[1-9]\d*)*$
                            name:
                              type: string
                              minLength: 1
                              maxLength: 150
                            type:
                              type: string
                              enum:
                                - parent
                                - child
                            classifications:
                              type: array
                              items:
                                type: string
                                enum:
                                  - erp
                                  - ert
                                  - igh
                                  - icpe
                                  - hab
                                  - other
                            category:
                              nullable: true
                              type: string
                              enum:
                                - '1'
                                - '2'
                                - '3'
                                - '4'
                                - '5'
                            activityTypes:
                              type: array
                              items:
                                type: string
                                enum:
                                  - J
                                  - L
                                  - M
                                  - 'N'
                                  - O
                                  - P
                                  - R
                                  - S
                                  - T
                                  - U
                                  - V
                                  - W
                                  - X
                                  - 'Y'
                                  - PA
                                  - CTS
                                  - SG
                                  - OA
                                  - REF
                                  - PS
                                  - GHA
                                  - GHO
                                  - GHR
                                  - GHS
                                  - GHTC
                                  - GHU
                                  - GHW1
                                  - GHW2
                                  - GHZ
                                  - ITGH
                          required:
                            - id
                            - ref
                            - name
                            - type
                            - classifications
                            - category
                            - activityTypes
                          additionalProperties: false
                        children:
                          type: array
                          items:
                            type: object
                            properties:
                              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)$
                              ref:
                                type: string
                                maxLength: 40
                                pattern: ^[A-Z]+-[1-9]\d*(?:-[A-Z]+-[1-9]\d*)*$
                              name:
                                type: string
                                minLength: 1
                                maxLength: 150
                              type:
                                type: string
                                enum:
                                  - parent
                                  - child
                              sortOrder:
                                nullable: true
                                type: integer
                                minimum: -9007199254740991
                                maximum: 9007199254740991
                              classifications:
                                type: array
                                items:
                                  type: string
                                  enum:
                                    - erp
                                    - ert
                                    - igh
                                    - icpe
                                    - hab
                                    - other
                              category:
                                nullable: true
                                type: string
                                enum:
                                  - '1'
                                  - '2'
                                  - '3'
                                  - '4'
                                  - '5'
                              activityTypes:
                                type: array
                                items:
                                  type: string
                                  enum:
                                    - J
                                    - L
                                    - M
                                    - 'N'
                                    - O
                                    - P
                                    - R
                                    - S
                                    - T
                                    - U
                                    - V
                                    - W
                                    - X
                                    - 'Y'
                                    - PA
                                    - CTS
                                    - SG
                                    - OA
                                    - REF
                                    - PS
                                    - GHA
                                    - GHO
                                    - GHR
                                    - GHS
                                    - GHTC
                                    - GHU
                                    - GHW1
                                    - GHW2
                                    - GHZ
                                    - ITGH
                            required:
                              - id
                              - ref
                              - name
                              - type
                              - sortOrder
                              - classifications
                              - category
                              - activityTypes
                            additionalProperties: false
                        qrcode:
                          nullable: true
                          type: object
                          properties:
                            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)$
                            scanUrl:
                              type: string
                              format: uri
                          required:
                            - id
                            - scanUrl
                          additionalProperties: false
                        buildings:
                          type: array
                          items:
                            type: object
                            properties:
                              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)$
                              name:
                                type: string
                                minLength: 1
                                maxLength: 150
                              unitId:
                                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)$
                            required:
                              - id
                              - name
                              - unitId
                            additionalProperties: false
                      required:
                        - unit
                        - children
                      additionalProperties: false
                  totalCount:
                    type: integer
                    minimum: 0
                    maximum: 9007199254740991
                  pagination:
                    type: object
                    properties:
                      page:
                        type: integer
                        minimum: 0
                        exclusiveMinimum: true
                        maximum: 9007199254740991
                      pageSize:
                        type: integer
                        minimum: 0
                        exclusiveMinimum: true
                        maximum: 9007199254740991
                      totalPages:
                        type: integer
                        minimum: 0
                        maximum: 9007199254740991
                    required:
                      - page
                      - pageSize
                      - totalPages
                    additionalProperties: false
                required:
                  - data
                  - totalCount
                  - pagination
                additionalProperties: false
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  details: {}
                required:
                  - error
                  - message
                  - requestId
                additionalProperties: false
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  details: {}
                required:
                  - error
                  - message
                  - requestId
                additionalProperties: false
        '500':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
                  requestId:
                    type: string
                  details: {}
                required:
                  - error
                  - message
                  - requestId
                additionalProperties: false

````