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

# Partial upsert of hierarchies

> Imports hierarchy's nodes (upserts existing and adds new leaf nodes or leaf subtrees). Usually performed via direct integration with Data Import service



## OpenAPI

````yaml openapi/product-catalog-v1.json PATCH /v1/Hierarchies/import
openapi: 3.0.4
info:
  title: ProductCatalog.Api 1.0
  version: '1.0'
servers:
  - url: https://{host}/product-catalog
    description: Your Lobyco environment
    variables:
      host:
        default: your-environment.lobyco.net
        description: >-
          The API host for your Lobyco environment. Replace it with the host you
          were given — this placeholder does not resolve.
security: []
paths:
  /v1/Hierarchies/import:
    patch:
      tags:
        - Hierarchies
      summary: Partial upsert of hierarchies
      description: >-
        Imports hierarchy's nodes (upserts existing and adds new leaf nodes or
        leaf subtrees). Usually performed via direct integration with Data
        Import service
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/ProductCatalog.Contracts.Common.Hierarchy'
            examples:
              Update existing hierarchies:
                value:
                  - name: Bakery
                    id: '1002'
                    parentId: '1001'
                    imageLink: https://example.com/images/Bakery.png
                  - name: Bread
                    id: '1003'
                    parentId: '1002'
                    imageLink: https://example.com/images/Bread.png
              Upsert existing with additional sub-hierarchies:
                value:
                  - name: Bakery
                    id: '1002'
                    parentId: '1001'
                    imageLink: https://example.com/images/Bakery.png
                  - name: Bread
                    id: '1003'
                    parentId: '1002'
                    imageLink: https://example.com/images/Bread.png
                  - name: Whole Grain Breadf
                    id: '1004'
                    parentId: '1003'
                    imageLink: https://example.com/images/WholeGrainBread.png
                  - name: Rye Bread
                    id: '1005'
                    parentId: '1003'
                    imageLink: https://example.com/images/RyeBread.png
                  - name: Seeded Rye Bread
                    id: '1006'
                    parentId: '1005'
                    imageLink: https://example.com/images/SeededRyeBread.png
          text/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/ProductCatalog.Contracts.Common.Hierarchy'
            examples:
              Update existing hierarchies:
                value:
                  - name: Bakery
                    id: '1002'
                    parentId: '1001'
                    imageLink: https://example.com/images/Bakery.png
                  - name: Bread
                    id: '1003'
                    parentId: '1002'
                    imageLink: https://example.com/images/Bread.png
              Upsert existing with additional sub-hierarchies:
                value:
                  - name: Bakery
                    id: '1002'
                    parentId: '1001'
                    imageLink: https://example.com/images/Bakery.png
                  - name: Bread
                    id: '1003'
                    parentId: '1002'
                    imageLink: https://example.com/images/Bread.png
                  - name: Whole Grain Breadf
                    id: '1004'
                    parentId: '1003'
                    imageLink: https://example.com/images/WholeGrainBread.png
                  - name: Rye Bread
                    id: '1005'
                    parentId: '1003'
                    imageLink: https://example.com/images/RyeBread.png
                  - name: Seeded Rye Bread
                    id: '1006'
                    parentId: '1005'
                    imageLink: https://example.com/images/SeededRyeBread.png
          application/*+json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/ProductCatalog.Contracts.Common.Hierarchy'
            examples:
              Update existing hierarchies:
                value:
                  - name: Bakery
                    id: '1002'
                    parentId: '1001'
                    imageLink: https://example.com/images/Bakery.png
                  - name: Bread
                    id: '1003'
                    parentId: '1002'
                    imageLink: https://example.com/images/Bread.png
              Upsert existing with additional sub-hierarchies:
                value:
                  - name: Bakery
                    id: '1002'
                    parentId: '1001'
                    imageLink: https://example.com/images/Bakery.png
                  - name: Bread
                    id: '1003'
                    parentId: '1002'
                    imageLink: https://example.com/images/Bread.png
                  - name: Whole Grain Breadf
                    id: '1004'
                    parentId: '1003'
                    imageLink: https://example.com/images/WholeGrainBread.png
                  - name: Rye Bread
                    id: '1005'
                    parentId: '1003'
                    imageLink: https://example.com/images/RyeBread.png
                  - name: Seeded Rye Bread
                    id: '1006'
                    parentId: '1005'
                    imageLink: https://example.com/images/SeededRyeBread.png
        required: true
      responses:
        '200':
          description: OK
          content:
            text/plain:
              schema:
                $ref: >-
                  #/components/schemas/ProductCatalog.Contracts.Results.EmptyResult
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/ProductCatalog.Contracts.Results.EmptyResult
            text/json:
              schema:
                $ref: >-
                  #/components/schemas/ProductCatalog.Contracts.Results.EmptyResult
        '400':
          description: Bad Request
          content:
            text/plain:
              schema:
                $ref: >-
                  #/components/schemas/ProductCatalog.Contracts.Results.DataImportErrorResult
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/ProductCatalog.Contracts.Results.DataImportErrorResult
            text/json:
              schema:
                $ref: >-
                  #/components/schemas/ProductCatalog.Contracts.Results.DataImportErrorResult
components:
  schemas:
    ProductCatalog.Contracts.Common.Hierarchy:
      type: object
      properties:
        name:
          type: string
          description: Name of the hierarchy node
        id:
          type: string
          description: Id of the hierarchy node
        parentId:
          type: string
          description: Id of the parent hierarchy node
          nullable: true
        imageLink:
          type: string
          description: Image link of the hierarchy node
          nullable: true
      additionalProperties: false
    ProductCatalog.Contracts.Results.EmptyResult:
      type: object
      additionalProperties: false
    ProductCatalog.Contracts.Results.DataImportErrorResult:
      type: object
      properties:
        errors:
          type: array
          items:
            $ref: >-
              #/components/schemas/LoopFoundation.Commons.Contracts.WebServiceError
      additionalProperties: false
      description: Class for integration with Data import service.
    LoopFoundation.Commons.Contracts.WebServiceError:
      required:
        - message
        - name
      type: object
      properties:
        name:
          minLength: 1
          type: string
        message:
          minLength: 1
          type: string
        details:
          nullable: true
      additionalProperties: false

````