CategoryHierarchy Resource
Use the CategoryHierarchy
resource to fetch the hierarchy of categories and subcategories in the site catalog.
Resources:
Schema type
Use category-hierarchy
to reference this resource in the template schema.
Querying
Filters nullable
-
parent string
id
of a parentCategory
, the children of which will be returned as a sub-hierarchy.{ "filters": { "parent": "II4VPMMREFDLJ27TKULXOVMS" } }
-
location_id string
- Default: Catalog Shipping Location ID
id
ofLocation
to scope a category hierarchy to. The category hierarchy data received will be based off of the hierarchy configuration at the given location.{ "filters": { "location_id": "location_id" } }
Output
[
{
"__SO_RESOURCE_TYPE__": "category_hierarchy", // internally used resource property. do not modify.
"id": "II4VPMMREFDLJ27TKULXOVMS",
"square_online_id": "II4VPMMREFDLJ27TKULXOVMS",
"resource_type": "CATEGORY_HIERARCHY",
"name": "Toplevel Category",
"children": [
{
"__SO_RESOURCE_TYPE__": "category_hierarchy", // internally used resource property. do not modify.
"id": "DL6EJVKRZVFNM6DG4ISZNKWU",
"square_online_id": "DL6EJVKRZVFNM6DG4ISZNKWU",
"resource_type": "CATEGORY_HIERARCHY",
"name": "First-level Subcategory",
"children": [
{
"square_online_id": "10",
"resource_type": "CATEGORY_HIERARCHY",
"name": "Second-level Subcategory",
"children": []
}
]
},
{
"__SO_RESOURCE_TYPE__": "category_hierarchy", // internally used resource property. do not modify.
"id": "BKGIQDWMNKHARMYB2KGA7IUF",
"square_online_id": "BKGIQDWMNKHARMYB2KGA7IUF",
"resource_type": "CATEGORY_HIERARCHY",
"name": "First-level Subcategory 2",
"children": []
},
{
"__SO_RESOURCE_TYPE__": "category_hierarchy", // internally used resource property. do not modify.
"id: "TEXF7U55ZIV7KA7UJLQIHY64",
"square_online_id": "TEXF7U55ZIV7KA7UJLQIHY64",
"resource_type": "CATEGORY_HIERARCHY",
"name": "First-level Subcategory 3",
"children": [
{
"__SO_RESOURCE_TYPE__": "category_hierarchy", // internally used resource property. do not modify.
"id": "UGETC67K5B6TCI52HHEUTZ57",
"square_online_id": "UGETC67K5B6TCI52HHEUTZ57",
"resource_type": "CATEGORY_HIERARCHY",
"name": "Second-level Subcategory",
"children": [
{
"__SO_RESOURCE_TYPE__": "category_hierarchy", // internally used resource property. do not modify.
"id": "NIJIIMAJJX4LZ4KF2MKHTGNY",
"square_online_id": "NIJIIMAJJX4LZ4KF2MKHTGNY",
"resource_type": "CATEGORY_HIERARCHY",
"name": "Third-level Subcategory",
"children": []
}
]
}
]
}
]
},
{
"id": "R5BAHKT5DRE7ZQCXMZYIBQBF",
"square_online_id": "R5BAHKT5DRE7ZQCXMZYIBQBF",
"resource_type": "CATEGORY_HIERARCHY",
"name": "Toplevel Category",
"children": []
},
{
"id": "UESIBGB644YFKBREPL7ZG6YZ",
"square_online_id": "UESIBGB644YFKBREPL7ZG6YZ",
"resource_type": "CATEGORY_HIERARCHY",
"name": "Toplevel Category",
"children": []
},
{
"id": "R5BAHKT5DRE7ZQCXMZYIBQBF",
"square_online_id": "R5BAHKT5DRE7ZQCXMZYIBQBF",
"resource_type": "CATEGORY_HIERARCHY",
"name": "Toplevel Category",
"children": []
}
]
CategoryHierarchy
A category hierarchy in the site catalog.
Field | Type | Description |
---|---|---|
children | CategoryHierarchy[] | List of child categories |
name | String | The category’s name |
resource_type | String | The resource type identifier. |
id | String | ID of the category |
square_online_id | String | ID of the category in Square Online |