---
title: "Entity Relationship Types"
section: "API Reference"
route: /apirelationtypes
account: {accountId}
bruce_api: https://{accountId}.api.nextspace.host
guardian_api: https://guardian.nextspace.host
---
# Entity Relationship Types

A Relationship Type is a classification of a Relationship between two Entity records. It gives a human-readable way to describe how your Entities relate to each-other.

The most simple Relationship Type is "Parent" and "Child" where you provide the name and reverse-name of "parent of" and "child of". This allows us to create human-readable sentences that describe your records.

Entity A is parent of Entity B. Entity B is child of Entity A.

Some Relationship Types are generated automatically and serve an internal purpose. For example the ID `COMMENTS_REPLY` is reserved for relating Comment records to their replies. `BruceRsrvContains` is reserved for our Assembly imports for parent/child relationships that have relative positioning. `BruceRsrvInstanceOf` is a legacy Assembly Relationship Type.

## Relationship Type requests

Below are the basic requests for managing Relationship Types.

### Get Relationship Types

```http
GET https://{accountId}.api.nextspace.host/entityRelationTypes
```

**Requires:**

- Account ID: Account ID must be specified in the subdomain of the request url.

| Parameter | In | Required | Description |
| --- | --- | --- | --- |
| `{accountId}` | path | yes | The account id of the account to perform the request on. |

**Response**

```typescript
interface IResponse {
    Items: {
        // Unique ID for the Relationship Type.
        "ID": string;
        // Human readable name.
        "Name": string;
        // Forward name to use in a sentence.
        "ForwardName": string;
        // Reverse name to use in a sentence.
        "ReverseName": String;

        // Default Style ID.
        // This guides rendering the lines/parabolas between records in 3D.
        "EntityDisplaySettingsID"?: number;
        // Default Entity Type ID.
        // This is used as the default Entity Type when creating Entity data records for Relationships.
        "Relation.EntityType.ID"?: string;
    }[];
}
```

**Javascript example**

```javascript
const url = "https://{accountId}.api.nextspace.host/entityRelationTypes";
const method = "get";
const token = "your-token";
const body = null;

async function doRequest(type, url, body, token) {
    const headers = {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json"
    };
    const options = {
        method: type,
        headers: headers,
        body: body ? JSON.stringify(body) : null
    };
    const res = await fetch(url, options);
    const json = await res.json();
    return json;
}

doRequest(method, url, body, token).then((res) => {
    console.log(res);
}).catch((err) => {
    console.error(err);
});
```

### Create / Update Relationship Type

```http
POST https://{accountId}.api.nextspace.host/entityRelationType/{type_id}
```

**Requires:**

- Account ID: Account ID must be specified in the subdomain of the request url.
- Logged in user auth token: A token for an active user session on the account, sent as "Authorization: Bearer <token>".
- Power user auth token: A token for an active power user session on the account, sent as "Authorization: Bearer <token>".

| Parameter | In | Required | Description |
| --- | --- | --- | --- |
| `{accountId}` | path | yes | The account id of the account to perform the request on. |
| `{type_id}` | path | yes | ID of the Relationship Type to create/update. |

**Request body**

```typescript
interface IBody {
    // Human readable name.
    "Name": string;
    // Forward name to use in a sentence.
    "ForwardName": string;
    // Reverse name to use in a sentence.
    "ReverseName": String;
}
```

**Response**

```typescript
// Body is a JSON object with the same properties as a single item from the list above.
// It returns a single Relationship Type record directly.
```

**Javascript example**

```javascript
const url = "https://{accountId}.api.nextspace.host/entityRelationType/{type_id}";
const method = "post";
const token = "your-token";
const body = null;

async function doRequest(type, url, body, token) {
    const headers = {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json"
    };
    const options = {
        method: type,
        headers: headers,
        body: body ? JSON.stringify(body) : null
    };
    const res = await fetch(url, options);
    const json = await res.json();
    return json;
}

doRequest(method, url, body, token).then((res) => {
    console.log(res);
}).catch((err) => {
    console.error(err);
});
```

### Delete Relationship Type

```http
DELETE https://{accountId}.api.nextspace.host/entityRelationType/{type_id}
```

**Requires:**

- Account ID: Account ID must be specified in the subdomain of the request url.
- Logged in user auth token: A token for an active user session on the account, sent as "Authorization: Bearer <token>".
- Power user auth token: A token for an active power user session on the account, sent as "Authorization: Bearer <token>".

| Parameter | In | Required | Description |
| --- | --- | --- | --- |
| `{accountId}` | path | yes | The account id of the account to perform the request on. |
| `{type_id}` | path | yes | ID of the Relationship Type delete. |

**Javascript example**

```javascript
const url = "https://{accountId}.api.nextspace.host/entityRelationType/{type_id}";
const method = "delete";
const token = "your-token";
const body = null;

async function doRequest(type, url, body, token) {
    const headers = {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json"
    };
    const options = {
        method: type,
        headers: headers,
        body: body ? JSON.stringify(body) : null
    };
    const res = await fetch(url, options);
    const json = await res.json();
    return json;
}

doRequest(method, url, body, token).then((res) => {
    console.log(res);
}).catch((err) => {
    console.error(err);
});
```

---

Urls on this page are resolved for account `{accountId}`.
Site index: https://docs.nextspace.host/llms.txt · whole site in one file: https://docs.nextspace.host/llms-full.txt
Human-readable version of this page: https://docs.nextspace.host/apirelationtypes
