Get Organization Hierarchy

This endpoint retrieves the Organizations the current user can see, as a flat list or as a nested tree.

Request

To retrieve the Organization Hierarchy visible to the user of the token, make a GET request to the following URL:

HTTP MethodURL
GEThttps://nanoview-api.wellairsolutions.com/api/v2.0/users/me/_/organizations/

Without parent, the response starts at the user's root Organizations: the ones that have no parent, or whose parent the user cannot see. With parent, it starts below that Organization.

Query Parameters

ParameterTypeRequired?DefaultDescription
parentStringNo—ID or label of the Organization to start from. Labels use the prefix ~
depthStringNo0 without parent, 1 with itLevels below the starting point to include: 0 to 6, or all for the whole subtree. depth=0 without parent returns only the roots
formatStringNoflatflat returns a paginated list in which each item has its depth. tree returns a plain array, not paginated, with each node's children nested under children
tags__containsStringNo—Only Organizations whose tags contain this exact tag, for example space
searchStringNo—Case-insensitive partial match on label, name or description
isActiveBooleanNo—true keeps only active Organizations and false only inactive ones. Omit it to get both
pageNumberNo1Page number, only with format=flat
page_sizeNumberNo50Items per page, up to 200, only with format=flat
tokenStringNo—Authentication Token can optionally be sent as a query parameter
  • depth, the roots and hasChildren are computed over the whole visible tree before isActive, tags__contains and search are applied.
  • With format=tree and parent, the array has a single entry: the starting Organization, wrapping its descendants. It is always returned, even when it does not match the other filters.

Header

ParameterRequired?Description
X-Auth-TokenYesAuthentication Token of the user
$ curl -X GET 'https://nanoview-api.wellairsolutions.com/api/v2.0/users/me/_/organizations/?depth=all&format=tree' \
 -H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73'
{
    "count": 2,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": "64a1b2c3d4e5f60001234568",
            "label": "north-tower",
            "description": "North Tower",
            "depth": 0,
            "tags": ["building"],
            "isActive": true,
            "parent": "64a1b2c3d4e5f60001234567",
            "hasChildren": true
        },
        {
            "id": "64a1b2c3d4e5f60001234569",
            "label": "north-tower-floor-1",
            "description": "",
            "depth": 1,
            "tags": ["floor"],
            "isActive": true,
            "parent": "64a1b2c3d4e5f60001234568"
        }
    ]
}
[
    {
        "id": "64a1b2c3d4e5f60001234568",
        "label": "north-tower",
        "description": "North Tower",
        "depth": 0,
        "tags": ["building"],
        "isActive": true,
        "parent": "64a1b2c3d4e5f60001234567",
        "children": [
            {
                "id": "64a1b2c3d4e5f60001234569",
                "label": "north-tower-floor-1",
                "description": "",
                "depth": 1,
                "tags": ["floor"],
                "isActive": true,
                "parent": "64a1b2c3d4e5f60001234568",
                "children": [
                    {
                        "id": "64a1b2c3d4e5f60001234571",
                        "label": "north-tower-room-101",
                        "description": "",
                        "depth": 2,
                        "tags": ["space"],
                        "isActive": false,
                        "parent": "64a1b2c3d4e5f60001234569",
                        "children": []
                    }
                ]
            }
        ]
    }
]
{
    "code": 400001,
    "message": "Validation Error.",
    "detail": {
        "depth": ["\"9\" is not a valid choice."]
    }
}
{
    "code": 401001,
    "message": "Authentication credentials were not provided."
}
{
    "code": 404001,
    "message": "The request was not found."
}

Response

With format=flat, an object with the Organizations in the results key. With format=tree, an array of root nodes with their children. Each node has:

PropertyTypeDescription
idStringID of Organization
labelStringLabel of Organization
descriptionStringDescription of Organization
depthIntegerDepth relative to the starting point of this response: 0 for a root, or for the parent that was sent
tagsString ArrayTags of Organization
isActiveBooleanTrue if Organization is active. Every user, End Users included, also sees the inactive Organizations they have access to
parentStringID of the parent Organization, or null for a root. It is the real parent, even when the user cannot see it and the node is reported as a root
hasChildrenBooleanPresent, and always true, only when the node has children that are not in this response (because of depth, or of a filter). It is never false
childrenArrayOnly with format=tree: the nested nodes
  • 404 Not Found when parent does not match an Organization the user can see.
  • 400 Bad Request when a ~label sent in parent matches several Organizations the user can see and none, or more than one, of them is active; or when depth, format or isActive have a value that is not valid.
  • The nodes do not include name. To read the full Organization object, use Get Organization or Get all Organizations with the descendant_of filter.