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

# Set parent customer

> Assigns a parent customer to establish an organizational hierarchy. The hierarchy supports a maximum of 3 levels. Circular references and self-assignment are not permitted. Both the parent and child customer must belong to the same tenant, and the parent customer must be active (not archived).

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

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

Establishes a parent-child relationship between two customers. This is used to model organizational structures such as a company with departments, a clinic with specialized units, or a retail chain with individual stores.

## Validation

The following rules are enforced when assigning a parent customer:

* The parent and child customer must belong to the **same tenant**
* A customer **cannot be its own parent**
* **Circular references** are not permitted (e.g., A → B → A)
* The hierarchy supports a **maximum of 3 levels** (root → child → grandchild)
* The parent customer must be **active** (not archived)

If any validation rule is violated, the API returns a `400 Bad Request` with a descriptive error message.

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

## Webhooks

A successful assignment dispatches the `customer.parent.assigned` webhook event, which includes the full customer and parent customer payloads.


## OpenAPI

````yaml put /customers/{customerId}/set-parent
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}/set-parent:
    parameters: []
    put:
      tags:
        - Customer
      summary: Set parent customer
      description: >-
        Assigns a parent customer to establish an organizational hierarchy. The
        hierarchy supports a maximum of 3 levels. Circular references and
        self-assignment are not permitted. Both the parent and child customer
        must belong to the same tenant, and the parent customer must be active
        (not archived).


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


        <sup>Required permissions: `customer:write`</sup>
      operationId: setCustomerParent
      parameters:
        - name: customerId
          in: path
          description: The ID of the customer to assign a parent to
          required: true
          deprecated: false
          schema:
            type: string
            format: uuid
          style: simple
          explode: false
      requestBody:
        description: The parent customer assignment
        content:
          application/json:
            schema:
              type: object
              required:
                - parentCustomerId
              properties:
                parentCustomerId:
                  type: string
                  format: uuid
                  description: The ID of the customer to set as parent
                  example: 00000000-0000-0000-0000-000000000000
        required: true
      responses:
        '200':
          description: Parent customer assigned successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The ID of the customer
                  parentCustomerId:
                    type: string
                    format: uuid
                    description: The ID of the assigned parent customer
                  parentCustomerName:
                    type: string
                    description: The name of the assigned parent customer
        '400':
          description: >-
            Invalid input — e.g. circular reference, depth limit exceeded, or
            self-assignment
        '404':
          description: Customer or parent customer not found
        '501':
          description: >-
            Feature not enabled — the customer.hierarchy feature flag is not
            active
      deprecated: false
      security:
        - JWT:
            - customer:write
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl -X PUT \
             /customers/{customerId}/set-parent \
             --header "Content-Type: application/json" \
             --header "Authorization: Bearer <token>" \
             --data '{
                "parentCustomerId": "00000000-0000-0000-0000-000000000000"
            }'
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer

````