> ## Documentation Index
> Fetch the complete documentation index at: https://developer.findity.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List departments tree

> Returns the organization's full department hierarchy as a tree. `data` always holds a single element, the organization's root department (`level` 0), and every department reachable from the root is nested under its parent through `children`. Departments not connected to the root (for example, with no parent) are not included, although they can still be retrieved with Get department. Siblings are sorted by `name` ascending (case-sensitive and not locale-aware, so uppercase letters sort before lowercase and accented letters after `z`), with `id` ascending as a tie-breaker.
The whole tree is always returned in one response, so this endpoint does not take `sort`, `max` or `offset`, and ignores them if they are sent. Splitting the tree into pages would give the client an incomplete hierarchy, and since `data` always holds a single root there is nothing to page across. Sibling order is fixed as described above. `meta.total` and `meta.count` are therefore always 1.
Returns 403 when the organization does not exist or the authenticated user is not an administrator of it. Returns 404 when the organization has no valid root department configured.




## OpenAPI

````yaml /openapi/findity-admin-api.json get /organizations/{organizationId}/departments/tree
openapi: 3.1.0
info:
  title: Findity Admin API
  description: Findity Admin API
  version: 1.0.0
servers:
  - url: https://stage-api.findity.com/api/v1/admin
  - url: https://api.findity.com/api/v1/admin
security:
  - bearerAuth: []
paths:
  /organizations/{organizationId}/departments/tree:
    get:
      tags:
        - Departments
      summary: List departments tree
      description: >
        Returns the organization's full department hierarchy as a tree. `data`
        always holds a single element, the organization's root department
        (`level` 0), and every department reachable from the root is nested
        under its parent through `children`. Departments not connected to the
        root (for example, with no parent) are not included, although they can
        still be retrieved with Get department. Siblings are sorted by `name`
        ascending (case-sensitive and not locale-aware, so uppercase letters
        sort before lowercase and accented letters after `z`), with `id`
        ascending as a tie-breaker.

        The whole tree is always returned in one response, so this endpoint does
        not take `sort`, `max` or `offset`, and ignores them if they are sent.
        Splitting the tree into pages would give the client an incomplete
        hierarchy, and since `data` always holds a single root there is nothing
        to page across. Sibling order is fixed as described above. `meta.total`
        and `meta.count` are therefore always 1.

        Returns 403 when the organization does not exist or the authenticated
        user is not an administrator of it. Returns 404 when the organization
        has no valid root department configured.
      operationId: adminListDepartmentsTree
      parameters:
        - name: organizationId
          in: path
          required: true
          description: >
            String. The organization's internal ID (32-character hex string) or
            its `externalSourceId`. When the value matches the format of an
            internal ID, the internal ID takes precedence.
          schema:
            type: string
            example: 11adfe2a080040e3892ffb89c21ec44e
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AdminApiDepartmentTree'
              example:
                meta:
                  count: 1
                  total: 1
                data:
                  - id: 63b7a7802a644e8ca296c9796ffa7074
                    externalSourceId: null
                    name: Acme AB
                    parentId: null
                    vatType: USE_CATEGORY
                    customDimensionPresetValues: []
                    level: 0
                    children:
                      - id: b41d20cf417a4c41a273588bac7c1ffc
                        externalSourceId: DEV-01
                        name: Development
                        parentId: 63b7a7802a644e8ca296c9796ffa7074
                        vatType: USE_CATEGORY
                        customDimensionPresetValues:
                          - id: 4f1c2b7e9a8d4c3b8e6f5a4d3c2b1a09
                            dimensionDefinitionId: d2e3f4a5b6c74d8e9f0a1b2c3d4e5f60
                            presetListValueId: a1b2c3d4e5f64a7b8c9d0e1f2a3b4c5d
                            presetListValueText: Project Phoenix
                            presetStringValue: null
                        level: 1
                        children:
                          - id: 9360d03ad7294220868d67f42a2a144d
                            externalSourceId: null
                            name: Payments
                            parentId: b41d20cf417a4c41a273588bac7c1ffc
                            vatType: DEDUCTABLE_VAT
                            customDimensionPresetValues: []
                            level: 2
                            children: []
                      - id: e7f8a9b0c1d24e3f8a9b0c1d2e3f4a5b
                        externalSourceId: null
                        name: Sales
                        parentId: 63b7a7802a644e8ca296c9796ffa7074
                        vatType: NON_DEDUCTABLE_VAT
                        customDimensionPresetValues: []
                        level: 1
                        children: []
        '403':
          description: Forbidden — organization not found or access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/403Error'
              examples:
                Organization not found or access denied:
                  value:
                    result: error
                    description: Organization not found or access denied
        '404':
          description: Not found — organization has no valid root department configured
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/404Error'
              examples:
                Department not found:
                  value:
                    result: error
                    code: DEPARTMENT_NOT_FOUND
                    description: Department not found
components:
  schemas:
    AdminApiDepartmentTree:
      type: object
      properties:
        meta:
          type: object
          properties:
            count:
              type: integer
              description: >-
                Number of top-level entries in `data`. Always 1, since the tree
                has a single root.
            total:
              type: integer
              description: >-
                Total number of top-level entries. Always 1, since the tree has
                a single root.
          required:
            - count
            - total
        data:
          type: array
          description: >
            Always contains exactly one element: the organization's root
            department (`level` 0), with every department reachable from it
            nested under it through `children`. Departments not connected to the
            root are not included.
          items:
            $ref: '#/components/schemas/AdminApiDepartmentTreeNode'
      required:
        - meta
        - data
    403Error:
      type: object
      properties:
        result:
          type: string
        code:
          type: string
        description:
          type: string
      example:
        result: error
        description: Not allowed
    404Error:
      type: object
      properties:
        result:
          type: string
        code:
          type: string
        description:
          type: string
      example:
        result: error
        code: ORGANIZATION_NOT_FOUND
        description: 'Failed to get organization for id: {orgId}'
    AdminApiDepartmentTreeNode:
      allOf:
        - $ref: '#/components/schemas/AdminApiDepartment'
        - type: object
          required:
            - children
          properties:
            children:
              type: array
              description: >
                The departments directly under this one. Each element has the
                same shape as this object — every `AdminApiDepartment` field
                plus its own `children` — recursively, down to departments with
                no sub-departments, whose `children` is an empty array. Sorted
                by `name` ascending (case-sensitive and not locale-aware, so
                uppercase letters sort before lowercase and accented letters
                after `z`), with `id` ascending as a tie-breaker.
              items:
                type: object
    AdminApiDepartment:
      type: object
      required:
        - id
        - externalSourceId
        - name
        - parentId
        - vatType
        - customDimensionPresetValues
        - level
      properties:
        id:
          type: string
          description: Unique identifier of the department.
        externalSourceId:
          type:
            - string
            - 'null'
          description: >-
            External source identifier of the department, if set by an
            integration. Null when not set.
        name:
          type: string
          description: Display name of the department.
        parentId:
          type:
            - string
            - 'null'
          description: >
            The `id` of the parent department. Null only for the organization's
            own root unit (level 0). Every other department, including a
            top-level one directly under the root, has this set to its parent's
            id.
        vatType:
          type: string
          description: >-
            VAT deduction handling for this department. Defaults to
            `USE_CATEGORY` when not explicitly set.
          enum:
            - USE_CATEGORY
            - NON_DEDUCTABLE_VAT
            - DEDUCTABLE_VAT
        customDimensionPresetValues:
          type: array
          description: >
            Preset custom dimension values configured for this department, in
            the order they were created. The order is stable, so identical
            requests return the values in the same order. Excludes values
            belonging to deleted dimension definitions.
          items:
            $ref: '#/components/schemas/AdminApiCustomDimensionPresetValue'
        level:
          type: integer
          description: >
            Depth of the department within the organization's unit hierarchy.
            The organization's implicit root unit is level 0; a genuine
            top-level department is level 1.
    AdminApiCustomDimensionPresetValue:
      type: object
      required:
        - id
        - dimensionDefinitionId
      properties:
        id:
          type: string
          description: Unique identifier of the preset value.
        dimensionDefinitionId:
          type: string
          description: >-
            The ID of the custom dimension definition this preset value belongs
            to.
        presetListValueId:
          type:
            - string
            - 'null'
          description: >-
            The ID of the selected list value, when the dimension uses a list of
            values. Null when a free-text preset is used instead.
        presetListValueText:
          type:
            - string
            - 'null'
          description: >-
            Display text of the selected list value. Null when a free-text
            preset is used instead.
        presetStringValue:
          type:
            - string
            - 'null'
          description: >-
            Free-text preset value, when the dimension does not use a list of
            values. Null when a list value is used instead.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````