---
title: "Upsert hierarchy"
method: POST
path: "/api/hierarchy/upsert"
tags: ["Hierarchy"]
---

# Upsert hierarchy

`POST /api/hierarchy/upsert`

## Request

- Base URL: `https://indexing-dev.hawksearch.net`
- URL: `https://indexing-dev.hawksearch.net/api/hierarchy/upsert`
- Auth: none declared. Required headers: `X-HawkSearch-ApiKey`
- TypeScript: <https://skmtc.dev/hawksearch/apis/hawksearch-elasticsearch-indexingapi/docs/api/hierarchy/upsert/post.ts> (a function with typed inputs; its response is checked against the schema)

The upsert method is used to insert hierarchy records.  The hierarchy records are often categories or departments. There is a limit of 125 hierarchy objects that can be sent in a request.  This method can be called multiple times to accommodate more than 125.  After all hierarchy objects have been sent, the hierarchy/rebuild method can be used.

## Headers

- `X-HawkSearch-ApiKey` string, required

## Request body

- CreateHierarchyParams: Create hierarchy params
  - `IndexName` string: Index used for operation
  - `Hierarchies` HierarchyModel[]: Array of categories
    - `HierarchyId` string: Id of a category
    - `Name` string: Category Name
    - `ParentHierarchyId` string: Id of parent category
    - `IsActive` boolean: Is Active ?
    - `SortOrder` integer: Sort order of a category
    - `Url` string: Url of hierarchy
    - `ImageUrl` string: Image Url
    - `Custom` string: Custom field

## Response `200`

OK

- object

---

[API](https://skmtc.dev/hawksearch/apis/hawksearch-elasticsearch-indexingapi.md) - [All operations](https://skmtc.dev/hawksearch/apis/hawksearch-elasticsearch-indexingapi/llms.txt) - [OpenAPI document](https://skmtc.dev/hawksearch/apis/hawksearch-elasticsearch-indexingapi/revisions/24cba7bf3468?raw)
