Entity Relationships


An Entity Relationship record is a connection between two Entity records. It can be used to retrieve a hierarchy of records, draw the connections between records in 3D, and to view the hierarchy as a 2D diagram.

It's recommended to read the Relationship Type docs here first.


When requesting Entity records using v3/entity/{entity_id} or v3/entity/entities, you can include the query param ?$expand=relation to include child Relationship records for the returned Entity records in the response. They will be inside Bruce/Relations in the response JSON.

Relationship requests

Below are the basic requests for managing Relationships.

Get Entity Relationships

Response
interface IResponse {
    Items: {
        // ID of the parent Entity.
        "Principal.Entity.ID": string;
        // ID of the child Entity.
        "Related.Entity.ID": string;
        // Relationship Type ID.
        "Relation.Type.ID": string;

        // (Optional) ID of the data Entity.
        // The data Entity is where the Relationship attribute data is stored.
        "Data.Entity.ID"?: string;
    }[];
}
Javascript example

Get Entity Relationships by Type

Response
// Same response body as the above get-list.
Javascript example

Update Relationship

Request body
interface IBody {
    // (Optional) ID of the data Entity.
    // The data Entity is where the Relationship attribute data is stored.
    "Data.Entity.ID"?: string;
}
Response
// Body is a JSON object with the same properties as a single item from the get-list above.
// It returns a single Relationship record directly.

Update Relationship

Request body
interface IBody {
    // ID of the data entity.
    // The data Entity is where the Relationship attribute data is stored.
    "Data.Entity.ID"?: string;
}
Response
// Body is a JSON object with the same properties as a single item from the get-list above.
// It returns a single Relationship record directly.

Create Relationships

Request body
interface IBody {
    // Array of child Entity IDs to create Relationships with.
    // If an existing Relationship exists, nothing occurs for that child.
    "Related.Entity.ID": string[];
}

Update Relationship

Request body
interface IBody {
    // ID of the data entity.
    // The data Entity is where the Relationship attribute data is stored.
    "Data.Entity.ID"?: string;
}
Response
// Body is a JSON object with the same properties as a single item from the get-list above.
// It returns a single Relationship record directly.

Delete Relationships

Request body
interface IBody {
    // Array of the child Entity IDs to delete Relationships with.
    "Related.Entity.ID": string[];
}

Experimental requests

To get the top-level Entity for for a given Entity ID and Relationship Type, you can perform the below request.

Get top-level Entity for Entity and Relationship Type

Response
interface IResponse {
    // ID of the top-level Entity for the provided Relationship information.
    // Legacy naming as this is related to a deprecated prototype/instance feature.
    "InstanceEntityID": string;

    // Path of Entity IDs from the top-level Entity to the provided Entity.
    // Currently, circular paths can cause issues in other requests.
    // So if this has recurring IDs (or is very long, eg: >30 length),
    // then it's recommended to avoid requesting a tree diagram for this Relationship.
    "Path": string[];
}
Javascript example

Here is how you can request a full Entity tree from a given starting Entity. Avoid calling this request for circular paths, which can be detected with the above get-top request.

Get Entity hierarchy

Response
interface IResponse {
    Root: INode;
}

interface INode {
    // ID of the Entity.
    ID: string;
    // ID of the Relationship Type.
    "Type.ID": string;
    // Array of child Entities (if any).
    "Children": ITreeResNode[] | null;
}
Javascript example