---
title: "Import Assemblies"
section: "API Reference"
route: /apiimportassembly
account: {accountId}
bruce_api: https://{accountId}.api.nextspace.host
guardian_api: https://guardian.nextspace.host
---
# Import Assemblies

You can mimic the import functionality you see in Operator by making your own import process for IFC, RVT, BRZ, etc files.

We'll assume you know how to upload files through the API and that you have access to a `TempFile.ID`.

## Analysis

This is an **optional** step to the process that gets you the bounding box size and an attribute schema definition.

In Operator, this step lets the user pick what attribute to use for creating new Entity Types.

### Assembly Analysis

```http
POST https://{accountId}.api.nextspace.host/import/analyze/assembly
```

**Requires:**

- Account ID: Account ID must be specified in the subdomain of the request url.
- 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 IPostBody {
    // Previously uploaded temp file ID.
    "TempFile.ID": string;
    // The file name is used to determine the file extension.
    // Internally we processes everything as a BRZ, which means IFC or other are first converted to BRZ.
    // This name is also used to create a file import record in the database.
    // Eg: 'my-file.ifc'.
    "TempFile.Name": string;
}
```

**Example request body**

```json
{
    "TempFile.ID": "abc",
    "TempFile.Name": "my-file.ifc"
}
```

**Response**

```typescript
interface IResponse {
    "PendingActionID": number;
}
```

**Javascript example**

```javascript
const url = "https://{accountId}.api.nextspace.host/import/analyze/assembly";
const method = "post";
const token = "your-token";
const body = {
    "TempFile.ID": "abc",
    "TempFile.Name": "my-file.ifc"
};

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

When the Pending Action is marked as completed, here is the result to expect:

```typescript
interface IResult {
    // Assembly bounding box.
    // You can use this to estimate the size of the assembly.
    // If it's all zeros, or missing, that indicates we couldn't determine the size.
    // That is usually a bad sign.
    "BoundingBox"?: any;
    // Root data schema item. Includes a hierarchy of attribute definitions.
    "DataSchema"?: any;
    // The converted file ID if we went from a non-BRZ to a BRZ format.
    // Pass this into the import step to avoid re-conversion.
    "Converted.TempFile.ID"?: string;
}
```

## Import

In this step we import the Entities and relationships from the assembly into Nextspace.

### Assembly Import

```http
POST https://{accountId}.api.nextspace.host/import/assembly
```

**Requires:**

- Account ID: Account ID must be specified in the subdomain of the request url.
- 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 IPostBody {
    // Previously uploaded temp file ID.
    "TempFile.ID": string;
    // The file name is used to determine the file extension.
    // Internally we processes everything as a BRZ, which means IFC or other are first converted to BRZ.
    // This name is also used to create a file import record in the database.
    // Eg: 'my-file.ifc'.
    "TempFile.Name": string;

    // Optional temp file ID from the analysis step.
    // If you have this, provide both the temp file ID and this converted temp file ID.
    "Converted.TempFile.ID"?: string;

    // Optional parent Entity Type ID.
    // New assembly Entity Types will be created underneath this parent.
    "Parent.EntityType.ID"?: string;
    // If 'Parent.EntityType.ID' is not provided then this name is used to create a new parent Entity Type.
    // If this is not set, the file's name is used to create a new parent Entity Type.
    "NewParentTypeName"?: string;

    // Attribute path to sort Entity Types by.
    // Attribute path segments are separated by a forward slash. Eg: 'address/city'.
    // Attribute values are used to get-or-create Entity Types.
    // Eg: if you sort by 'IFCType', you'll get-or-create Entity Types based on the IFC Type attribute.
    "SortAttrPath"?: string;

    // If you provided a parent Entity Type ID, then this indicates if newly found Entity Types should be created.
    // Default is true.
    "ExtendEntityTypes"?: boolean;
    // If you provided a parent Entity Type ID, then this indicates if the data schemas are allowed to be extended.
    // Default is true.
    "ExtendTypeSchemas"?: boolean;
    // Indicates if newly created Entity Types should look for global definitions to extend from.
    // Default is true, however our Operator has this on 'false' for the time being.
    "LoadTypeTemplates"?: boolean;
    // Indicates if newly created Entity Types should be 'strict'.
    // Default is true.
    // When an Entity Type is not strict then newly found attributes are NOT added to its schema.
    // This is useful for Entity Types where each Entity has a different set of attributes.
    "CreateStrictTypes"?: boolean;
}
```

**Example request body**

```json
{
    "TempFile.ID": "blah-abc",
    "TempFile.Name": "my-file.ifc",
    "Converted.TempFile.ID": "blah-123",
    "NewParentTypeName": "my import",
    "SortAttrPath": "IFCType"
}
```

**Response**

```typescript
interface IResponse {
    "PendingActionID": number;
}
```

**Javascript example**

```javascript
const url = "https://{accountId}.api.nextspace.host/import/assembly";
const method = "post";
const token = "your-token";
const body = {
    "TempFile.ID": "blah-abc",
    "TempFile.Name": "my-file.ifc",
    "Converted.TempFile.ID": "blah-123",
    "NewParentTypeName": "my import",
    "SortAttrPath": "IFCType"
};

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

When the Pending Action is marked as completed, here is the result to expect:

```typescript
interface IResult {
    // Array of assembly root Entity IDs.
    // Typically there is only one, and you take the first one.
    RootEntityIDs: string[];
}
```

---

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