---
canonical: https://amplience.com/developers/docs/schema-reference/traits/
title: Traits
description: Traits allow you to add information to a schema to support Amplience specific functionality, for example, to specify a schema can be included in a hierarchy.
audience: Developer
date_published: 2022-07-12
date_modified: 2023-06-12
---

# Traits

Traits allow you to add information to a schema to support some Amplience specific functionality. Currently traits are used to specify that a schema can be included in a hierarchy and to define filtering and sort features.

The schema editor includes shortcuts to make it easier to add traits to your schemas.

## Hierarchy trait

By including `trait:hierarchy` in a schema you can specify that a content item created from this schema can be added to a hierarchy. You also provide a childContentTypes array that defines the type of content items that can be added as child nodes. You can leave this array blank if you want a node created from the schema to be a leaf node with no children.

In the example shown below only content items created from the schema registered with the URL `https://example.com/site-menu-item` can be added as children.

```json

"trait:hierarchy": {
        "childContentTypes": [
            "https://example.com/site-menu-item"

        ]
    }
```

## Sortable trait

`trait:sortable` is added at the top level of the schema and can contain up to 3 sort paths, one of which must have the "default" key.

The example trait below includes a default sort key that is used to sort content using the `readTime` property.

```json
{
  "trait:sortable": {
    "sortBy": [{ "key": "default", "paths": ["/readTime"] }]
  }
}
```

You can specify multiple entries in a sort path, up to a maximum of 5.

In the example below we have specified two sort keys: "default" and "readTime".

The default sort key will sort the content by date and ranking. If the blog post date of two items is the same, then the ranking will be used as a tie breaker.

The "readTime" sort key will sort the content by readTime followed by date and then if those properties are both equal, "ranking" will be used.

```json
{
  "trait:sortable": {
    "sortBy": [
      {
        "key": "default",
        "paths": ["/date", "/ranking"]
      },
      {
        "key": "readTime",
        "paths": ["/readTime", "/date", "/ranking"]
      }
    ]
  }
}
```

## Filterable trait

The filterable trait allows you to specify those properties that can be used to filter a content type.

The trait includes a filterBy array that includes the path for each property that you will use to filter your content. Path entries are specified in JSON Pointer format and can be string, number or boolean types. The filterBy array can contain up to 5 paths, not including the schema id and hierarchy parent id which are included automatically.

The paths that you define in the filterBy array will be used to make a request to the filter API to retrieve content with properties of the specified value.

In the example we are using the `categoryId` property as a filter.

```json
 "trait:filterable":{
      "filterBy":[
         {
            "paths":[
               "/categoryId"
            ]
         }
      ]
   }
```

Note that you can only include properties defined in the schema itself and not in any linked content.

## Related pages

[Hierarchies](https://amplience.com/developers/docs/dev-tools/guides-tutorials/hierarchies)

[Filter API](https://amplience.com/developers/docs/apis/content-delivery/filter-api)
