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

# Get customer hierarchy

> Returns the full hierarchy tree for the specified customer, starting from the root of the hierarchy. The tree is built recursively with each node containing its children. The `isCurrentCustomer` flag marks which node in the tree is the customer from the request.

This endpoint requires the `customer.hierarchy` feature to be enabled.

<sup>Required permissions: `customer:read`</sup>

Returns the full hierarchy tree for any customer in the organization structure. Regardless of whether a parent or child customer ID is provided, the response always starts from the root of the hierarchy and includes all descendants as a nested tree.

The `isCurrentCustomer` flag on each node indicates which customer in the tree corresponds to the ID specified in the request path.

## Example Response

```json theme={null}
{
    "root": {
        "id": "uuid-100",
        "name": "Klinik Musterstadt",
        "customerNumber": "CUST-100",
        "isCurrentCustomer": false,
        "children": [
            {
                "id": "uuid-101",
                "name": "Radiology",
                "customerNumber": "CUST-101",
                "isCurrentCustomer": true,
                "children": []
            },
            {
                "id": "uuid-102",
                "name": "Orthopedics",
                "customerNumber": "CUST-102",
                "isCurrentCustomer": false,
                "children": []
            }
        ]
    }
}
```

## Feature Flag

This endpoint requires the `customer.hierarchy` feature to be enabled. If the feature is not active, a `501 Not Implemented` response is returned.


## OpenAPI

````yaml get /customers/{customerId}/hierarchy
openapi: 3.1.0
info:
  title: Fynn API
  description: ''
  termsOfService: https://www.fynn.eu/tos
  contact:
    name: Fynn UG (haftungsbeschränkt)
    url: https://www.fynn.eu
    email: hi@fynn.eu
  license:
    name: Proprietary
    url: https://www.fynn.eu/license
  version: 0.0.0
servers:
  - url: https://coreapi.io
    description: Production
  - url: https://preview.coreapi.io
    description: Sandbox
security:
  - JWT: []
tags: []
paths:
  /customers/{customerId}/hierarchy:
    parameters: []
    get:
      tags:
        - Customer
      summary: Get customer hierarchy
      description: >-
        Returns the full hierarchy tree for the specified customer, starting
        from the root of the hierarchy. The tree is built recursively with each
        node containing its children. The `isCurrentCustomer` flag marks which
        node in the tree is the customer from the request.


        This endpoint requires the `customer.hierarchy` feature to be enabled.


        <sup>Required permissions: `customer:read`</sup>
      operationId: getCustomerHierarchy
      parameters:
        - name: customerId
          in: path
          description: >-
            The ID of any customer in the hierarchy (the response always starts
            from the root)
          required: true
          deprecated: false
          schema:
            type: string
            format: uuid
          style: simple
          explode: false
      responses:
        '200':
          description: The full hierarchy tree starting from the root
          content:
            application/json:
              schema:
                type: object
                properties:
                  root:
                    type: object
                    description: The root customer of the hierarchy tree
                    properties:
                      id:
                        type: string
                        format: uuid
                        example: 00000000-0000-0000-0000-000000000000
                      name:
                        type: string
                        example: Klinik Musterstadt
                      customerNumber:
                        type: string
                        example: CUST-100
                      isCurrentCustomer:
                        type: boolean
                        description: >-
                          Indicates whether this node represents the customer
                          specified in the request path
                      children:
                        type: array
                        description: Nested child customer nodes
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              format: uuid
                            name:
                              type: string
                            customerNumber:
                              type: string
                            isCurrentCustomer:
                              type: boolean
                            children:
                              type: array
                              items: {}
        '404':
          description: Customer not found
        '501':
          description: >-
            Feature not enabled — the customer.hierarchy feature flag is not
            active
      deprecated: false
      security:
        - JWT:
            - customer:read
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X GET \
             /customers/{customerId}/hierarchy \
             --header "Authorization: Bearer <token>"
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer

````