How to retrieve the hierarchy for a customer through the API?
Scope
How do I get the full hierarchy for a customer through the API?
How do I retrieve a subordinate hierarchy for a customer through the API?
How do I get the hierarchy path to the root through the API?
Summary
To retrieve the hierarchy tree for a customer through the API, follow the steps below.
Step 1: Use the Get hierarchy API.
Step 2: Pass the input parameter hierarchy_operation_type and select one of these values:
- complete_hierarchy
- subordinates
- path_to_root
Solution
Step 1: Choose the Get hierarchy API for the product catalog version below.
The API call above is a GET request. If you use a tool such as Postman, set the request type to GET.
Step 2: Pass this parameter. Enter hierarchy_operation_type and select one of the values below.
Possible values are:
- complete_hierarchy: List the nodes of the full hierarchy to which the customer belongs.
- subordinates: List all the nodes of the hierarchy formed by the customer and its subordinates. In other words, fetch the nodes of the tree whose root node is the customer.
- path_to_root: List the nodes along the path from the customer to the root of the full hierarchy.
Here is an example of the Get hierarchy API call in Postman.