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

# Query hierarchy levels

To query hierarchy levels, use the `hierarchyLevels` query.

**Access policy:**

* The API user context must have permission to view hierarchy levels.
* Results are filtered based on the user's context and permissions.

The query accepts the following arguments:

| Argument           | Type | Description                                                                                   | Default |
| :----------------- | :--- | :-------------------------------------------------------------------------------------------- | :------ |
| `hierarchyLevelId` | `ID` | Optional. Specific hierarchy level ID to retrieve. If omitted, returns all accessible levels. | —       |

**Object description:**

The `hierarchyLevels` query returns `HierarchyLevel` objects with the following structure:

| Field      | Type               | Description                                               |
| :--------- | :----------------- | :-------------------------------------------------------- |
| `id`       | `ID!`              | The unique identifier of the hierarchy level.             |
| `label`    | `String!`          | The display name of the hierarchy level.                  |
| `depth`    | `Int!`             | The depth of this level in the hierarchy tree (root = 0). |
| `parent`   | `HierarchyLevel`   | The parent hierarchy level, if any.                       |
| `children` | `[HierarchyLevel]` | The children hierarchy levels, if any.                    |

<Note>
  When `hierarchyLevelId` is provided, the query returns detailed information about that specific level including its parent relationship.
</Note>

<CodeGroup>
  ```filename GraphQL Query [expandable] theme={null}
  query hierarchyLevels {
    hierarchyLevels(hierarchyLevelId: 8){
      id
      label
      depth
      parent{
        id
      }
      children {
        id
        label
      }
    }
  }
  ```

  ```File Query result [expandable] theme={null}
  {
    "data": {
      "hierarchyLevels": {
        "id": "8",
        "label": "Department Level",
        "depth": 2,
        "parent": {
          "id": "5"
        },
        "children": [
          {
            "id": "12",
            "label": "Sub-department A"
          },
          {
            "id": "13",
            "label": "Sub-department B"
          }
        ]
      }
    }
  }
  ```
</CodeGroup>
