---
title: "Project View Data"
section: "API Reference"
route: /apiprojectviewdata
account: {accountId}
bruce_api: https://{accountId}.api.nextspace.host
guardian_api: https://guardian.nextspace.host
---
# Project View Data

To avoid the need for parsing Project View Menu Items to perform changes to what Entity Types and Tilesets are loadeded. We have a dedicated endpoint for performing bulk changes.

This endpoint will match a given Entity Type ID or Tileset ID and update all related Menu Items to a new ID. Alternatively, you can delete all related Menu Items for a given Entity Type or Tileset.

## Requests

Below are the endpoints to reference.

### Update a single Project View

```http
POST https://{accountId}.api.nextspace.host/ui.view/{view_id}/relatedData
```

**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. |
| `{view_id}` | path | yes | Project View ID to we're updating. |

**Request body**

```typescript
interface ITypeChangeRequest {
    // Entity Type ID we're updating.
    "EntityType.ID": string;

    // The new Entity Type ID to swap related Menu Items to.
    "New.EntityType.ID"?: string;
    // If true, the related Menu Items will have their captions updated to the new type's name.
    "UpdateCaptions"?: boolean;

    // If true, the related Menu Items will be deleted instead of updated.
    // The newTypeID and captions don't need to be provided if this is true.
    "Delete"?: boolean;
}

interface ITilesetChangeRequest {
    // Tileset ID we're updating.
    "Tileset.ID": string;

    // The new Tileset ID to swap related Menu Items to.
    "New.Tileset.ID"?: string;
    // If true, the related Menu Items will have their captions updated to the new tileset's name.
    "UpdateCaptions"?: boolean;

    // If true, the "New.Tileset.ID" doesn't need to be provided.
    // Instead, we look for the latest Tileset with a matching name and use it if it's newer than the current one.
    "Predictive"?: boolean;

    // If true, the related Menu Items will be deleted instead of updated.
    // The newTilesetID and captions don't need to be provided if this is true.
    "Delete"?: boolean;
}

interface IBody {
    // List of changes.
    "Items": (ITypeChangeRequest |  ITilesetChangeRequest)[];
}
```

**Example request body**

```json
{
    "Items": [
        {
            "EntityType.ID": "my-existing-entity-type-id",
            "New.EntityType.ID": "my-new-entity-type-id"
        },
        {
            "Tileset.ID": "my-existing-tileset-id",
            "New.Tileset.ID": "my-new-tileset-id",
            "UpdateCaptions": true
        },
        {
            "EntityType.ID": "entity-type-id-to-remove",
            "Delete": true
        },
        {
            "Tileset.ID": "tileset-id-to-remove",
            "Delete": true
        },
        {
            "Tileset.ID": "my-existing-tileset-id",
            "Predictive": true
        }
    ]
}
```

**Response**

```typescript
// Response is the same for one view and multiple views being updated.
// So for one view, you mainly change for 0/1 counter to see if anything was updated.
interface IResponse {
    // Specific view IDs that were updated.
    "Updated.UIView.ID": string[];
    // Simple counter of View IDs that were updated.
    "Updated.Count": number;
}
```

**Javascript example**

```javascript
const url = "https://{accountId}.api.nextspace.host/ui.view/{view_id}/relatedData";
const method = "post";
const token = "your-token";
const body = {
    "Items": [
        {
            "EntityType.ID": "my-existing-entity-type-id",
            "New.EntityType.ID": "my-new-entity-type-id"
        },
        {
            "Tileset.ID": "my-existing-tileset-id",
            "New.Tileset.ID": "my-new-tileset-id",
            "UpdateCaptions": true
        },
        {
            "EntityType.ID": "entity-type-id-to-remove",
            "Delete": true
        },
        {
            "Tileset.ID": "tileset-id-to-remove",
            "Delete": true
        },
        {
            "Tileset.ID": "my-existing-tileset-id",
            "Predictive": true
        }
    ]
};

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);
});
```

### Update multiple or all Project Views

```http
POST https://{accountId}.api.nextspace.host/ui.view/relatedData
```

**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. |

**Request body**

```typescript
interface IBody {
    // List of changes (same as singular view request).
    "Items": (ITypeChangeRequest |  ITilesetChangeRequest)[];
    // Array of view IDs to apply the changes to.
    // Send ["*"] to update all Project Views.
    "View.ID": string[];
}
```

**Response**

```typescript
// Same as singular view update.
```

**Javascript example**

```javascript
const url = "https://{accountId}.api.nextspace.host/ui.view/relatedData";
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);
});
```

---

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/apiprojectviewdata
