1. Parameters

Relations

When filtering on a relation, use the relation name, which is the system name of a relation member defined on an entity definition. The syntax for a relation name is ParentDefinitionToChildDefinition (for example, CategoryToAsset,FinalLifeCycleStatusToAsset). You can retrieve a relation name using a GET /api/entitydefinitions/{definitionName} and examining member_groups[*].members for entries where "type": "Relation". The name field of each such entry is what goes in a filter. The .id is the numeric primary key of the specific entity instance on the other side of the relation (that is, the entity whose children (or parents) you want to retrieve). In the following example, you are filtering assets by Type = Archive and excluding assets where the status (M.Final.LifeCycle.Status) is Approved.

{
    "query": {
      "filter": {
        "type": "Composite",
        "operator": "AND",
        "children": [
          {
            "type": "Definition",
            "operator": "Equals",
            "name": "M.Asset"
          },
          {
            "type": "Relation",
            "relation": "AssetTypeToAsset",
            "parent_id": 7070
          },
           {
            "type": "Not",
            "child": {
                "type": "Relation",
                "relation": "FinalLifeCycleStatusToAsset",
                "parent_id": 544
            }
            }
        ]
      },
      "skip": 0,
      "take": 10,
      "sorting": [
        {
          "field_type": "Property",
          "field": "created_on",
          "culture": "en-us",
          "order": "Desc"
        }
      ]
    },
    "load_configuration": {
      "load_entities": true,
      "property_option": {
        "load_option": "None",
        "properties": []
      },
      "relation_option": {
        "load_option": "Custom",
        "relations": [
          {
            "name": "AssetToAssociatedCollections"
          }
        ]
      },
      "culture_option": {
        "load_option": "All",
        "cultures": []
      }
    }
  }

Parents

You can query for named parent relationships by using a specific ID.

For instance, to query for all assets linked to a certain brand ID:

GET http://<hostname>/api/entities/query?query=Definition.Name=='M.Asset' AND Parent('BrandToAsset').id==331
Note

This property only supports the == operator, but can be negated.

Children

You can query for named child relationships by using a specific ID.

For instance, to query for all assets that have another specific asset as child:

GET http://<hostname>/api/entities/query?query=Definition.Name=='M.Asset' AND Child('RelatedAssetsToAsset').id==407
Note

This property only supports the == operator, but can be negated.

Ancestors

You can query for named ancestors (secured and unsecured) by using a specific ID.

For instance, to query for all assets that belong to M.AssetMedia:

GET http://<hostname>/api/entities/query?query=Definition.Name=='M.Asset' AND Ancestor('AssetMediaToAsset').id==317
Note

This property only supports the == operator, but can be negated.

Exists

You can query for named relationships which have a parent entity.

For instance, to query for all assets which have a brand:

GET http://<hostname>/api/entities/query?query=Definition.Name=='M.Asset' AND Exists('BrandToAsset')

Missing

You can query for named relationships which do not have a parent entity.

For instance, to query for all assets which do not have a brand:

GET http://<hostname>/api/entities/query?query=Definition.Name=='M.Asset' AND Missing('BrandToAsset')
If you have suggestions for improving this article, let us know!