---
title: WorkspacesApi
summary: TypeScript SDK: the Workspaces operations, 5 methods, each with its parameters, result and a complete example.
order: 18
languages: [typescript]
sdk-package: TypeScript SDK · @bimworks/sdk
link-terms: true
---

# WorkspacesApi

[[page:reference/sdk/typescript|TypeScript SDK]] · `@bimworks/sdk` · class · 5 methods

Curated views on a folder for visitors of the BIM.works web app, and their share links

Construct it with the client of [[page:reference/sdk/typescript#connect|the connect step]]: `new WorkspacesApi(client)`. Each method is one operation of the [[page:api|API part]], where it runs on its page.

<table class="dense">
<thead><tr><th>Method</th><th>Operation</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>[[page:reference/sdk/typescript/workspacesapi#createworkspace|createWorkspace]]</code></td><td>[[openapi:CreateWorkspace]]</td><td>Create a workspace</td></tr>
<tr><td><code>[[page:reference/sdk/typescript/workspacesapi#deleteworkspace|deleteWorkspace]]</code></td><td>[[openapi:DeleteWorkspace]]</td><td>Delete a workspace</td></tr>
<tr><td><code>[[page:reference/sdk/typescript/workspacesapi#listworkspaces|listWorkspaces]]</code></td><td>[[openapi:ListWorkspaces]]</td><td>List the caller's workspaces</td></tr>
<tr><td><code>[[page:reference/sdk/typescript/workspacesapi#publishworkspace|publishWorkspace]]</code></td><td>[[openapi:PublishWorkspace]]</td><td>Publish or unpublish a workspace</td></tr>
<tr><td><code>[[page:reference/sdk/typescript/workspacesapi#updateworkspace|updateWorkspace]]</code></td><td>[[openapi:UpdateWorkspace]]</td><td>Change a workspace</td></tr>
</tbody>
</table>

## `createWorkspace` {#createworkspace}

```typescript
createWorkspace(requestParameters: { createWorkspaceRequest: CreateWorkspaceRequest }): Promise<CreateWorkspace200Response>
```

Create a workspace. An account only. A sub-workspace inherits the root folder and the scopes of its parent and can only narrow them.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:CreateWorkspace]] · <code>POST /openapi/workspaces/CreateWorkspace</code></td></tr>
<tr><th>Scope</th><td>[[scope:workspaces:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>createWorkspaceRequest</code></td><td><code>[[page:reference/sdk/typescript/models#CreateWorkspaceRequest|CreateWorkspaceRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:CreateWorkspace]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/typescript/models#CreateWorkspace200Response|CreateWorkspace200Response]]</code> — The new workspace

### Example

```typescript
import { AuthApi, Configuration, CreateWorkspace200ResponseToJSON, CreateWorkspaceRequestFromJSON, WorkspacesApi } from "@bimworks/sdk";

// 1. Connect to BIM.works and log in with your API token
const basePath = "BIM_WORKS_ADDRESS/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
  .loginWithApiToken({ loginWithApiTokenRequest: { token: "BIM_WORKS_API_TOKEN" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });

// 2. The request
const request = CreateWorkspaceRequestFromJSON({
  "name": "",
  "parent_workspace_uuid": "00000000-0000-0000-0000-000000000000",
  "scopes": {},
  "filter": "",
  "load_all_models_initially": false,
  "current_space": {},
  "feature_visibility": {}
});

// 3. The call
const result = await new WorkspacesApi(client).createWorkspace({ createWorkspaceRequest: request });

// 4. The result
console.log(JSON.stringify(CreateWorkspace200ResponseToJSON(result), null, 2));
```

## `deleteWorkspace` {#deleteworkspace}

```typescript
deleteWorkspace(requestParameters: { deleteWorkspaceRequest: DeleteWorkspaceRequest }): Promise<void>
```

Delete a workspace. Deletes the workspace and its sub-workspaces; their links stop working. The models and actions are kept. Its owner only.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:DeleteWorkspace]] · <code>POST /openapi/workspaces/DeleteWorkspace</code></td></tr>
<tr><th>Scope</th><td>[[scope:workspaces:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>deleteWorkspaceRequest</code></td><td><code>[[page:reference/sdk/typescript/models#DeleteWorkspaceRequest|DeleteWorkspaceRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:DeleteWorkspace]]'s request body.</td></tr>
</tbody>
</table>

### Returns

Nothing: the operation answers without a body (Deleted).

### Example

```typescript
import { AuthApi, Configuration, DeleteWorkspaceRequestFromJSON, WorkspacesApi } from "@bimworks/sdk";

// 1. Connect to BIM.works and log in with your API token
const basePath = "BIM_WORKS_ADDRESS/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
  .loginWithApiToken({ loginWithApiTokenRequest: { token: "BIM_WORKS_API_TOKEN" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });

// 2. The request
const request = DeleteWorkspaceRequestFromJSON({
  "uuid": "BIM_WORKS_FIRST_MODEL"
});

// 3. The call
await new WorkspacesApi(client).deleteWorkspace({ deleteWorkspaceRequest: request });

// 4. The result
// (DeleteWorkspace answers no content: the call returns once it succeeded and throws a ResponseError otherwise)
console.log("Done");
```

## `listWorkspaces` {#listworkspaces}

```typescript
listWorkspaces(): Promise<Array<Workspace>>
```

List the caller's workspaces. The caller's workspaces with their sub-workspaces (`children`). A workspace is a curated view on a folder for visitors of the BIM.works web app: its scopes, object filter and visible features; PublishWorkspace makes it a share link.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:ListWorkspaces]] · <code>POST /openapi/workspaces/ListWorkspaces</code></td></tr>
<tr><th>Scope</th><td>[[scope:workspaces:read]]</td></tr>
</tbody>
</table>

### Parameters

None: the operation takes no request.

### Returns

<code>Array&lt;[[page:reference/sdk/typescript/models#Workspace|Workspace]]&gt;</code> — The workspaces

### Example

```typescript
import { AuthApi, Configuration, WorkspaceToJSON, WorkspacesApi } from "@bimworks/sdk";

// 1. Connect to BIM.works and log in with your API token
const basePath = "BIM_WORKS_ADDRESS/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
  .loginWithApiToken({ loginWithApiTokenRequest: { token: "BIM_WORKS_API_TOKEN" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });

// 2. The request
// (ListWorkspaces takes no request)

// 3. The call
const result = await new WorkspacesApi(client).listWorkspaces();

// 4. The result
console.log(JSON.stringify(result.map(WorkspaceToJSON), null, 2));
```

## `publishWorkspace` {#publishworkspace}

```typescript
publishWorkspace(requestParameters: { publishWorkspaceRequest: PublishWorkspaceRequest }): Promise<Workspace>
```

Publish or unpublish a workspace. Publishing gives the workspace a new `publish_uuid`, the share link into the web app; publishing again replaces the link and ends the old one. `publish: false` unpublishes it and ends the visitors' sessions. Its owner only.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:PublishWorkspace]] · <code>POST /openapi/workspaces/PublishWorkspace</code></td></tr>
<tr><th>Scope</th><td>[[scope:workspaces:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>publishWorkspaceRequest</code></td><td><code>[[page:reference/sdk/typescript/models#PublishWorkspaceRequest|PublishWorkspaceRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:PublishWorkspace]]'s request body.</td></tr>
</tbody>
</table>

### Returns

<code>[[page:reference/sdk/typescript/models#Workspace|Workspace]]</code> — The workspace with its publish_uuid

### Example

```typescript
import { AuthApi, Configuration, PublishWorkspaceRequestFromJSON, WorkspaceToJSON, WorkspacesApi } from "@bimworks/sdk";

// 1. Connect to BIM.works and log in with your API token
const basePath = "BIM_WORKS_ADDRESS/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
  .loginWithApiToken({ loginWithApiTokenRequest: { token: "BIM_WORKS_API_TOKEN" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });

// 2. The request
const request = PublishWorkspaceRequestFromJSON({
  "uuid": "BIM_WORKS_FIRST_MODEL",
  "publish": true
});

// 3. The call
const result = await new WorkspacesApi(client).publishWorkspace({ publishWorkspaceRequest: request });

// 4. The result
console.log(JSON.stringify(WorkspaceToJSON(result), null, 2));
```

## `updateWorkspace` {#updateworkspace}

```typescript
updateWorkspace(requestParameters: { updateWorkspaceRequest: UpdateWorkspaceRequest }): Promise<void>
```

Change a workspace. Changes the fields that are passed; the others stay as they are. A field named in `clear` is removed. Its owner only.

<table class="dense">
<tbody>
<tr><th>Operation</th><td>[[openapi:UpdateWorkspace]] · <code>POST /openapi/workspaces/UpdateWorkspace</code></td></tr>
<tr><th>Scope</th><td>[[scope:workspaces:write]]</td></tr>
</tbody>
</table>

### Parameters

<table class="dense">
<thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead>
<tbody>
<tr><td><code>updateWorkspaceRequest</code></td><td><code>[[page:reference/sdk/typescript/models#UpdateWorkspaceRequest|UpdateWorkspaceRequest]]</code><span class="req">required</span></td><td>The request: its properties are those of the model, its JSON that of [[openapi:UpdateWorkspace]]'s request body.</td></tr>
</tbody>
</table>

### Returns

Nothing: the operation answers without a body (Changed).

### Example

```typescript
import { AuthApi, Configuration, UpdateWorkspaceRequestFromJSON, WorkspacesApi } from "@bimworks/sdk";

// 1. Connect to BIM.works and log in with your API token
const basePath = "BIM_WORKS_ADDRESS/openapi";
const auth = await new AuthApi(new Configuration({ basePath }))
  .loginWithApiToken({ loginWithApiTokenRequest: { token: "BIM_WORKS_API_TOKEN" } });
const client = new Configuration({ basePath, accessToken: typeof auth === "string" ? auth : auth.base64 });

// 2. The request
const request = UpdateWorkspaceRequestFromJSON({
  "uuid": "BIM_WORKS_FIRST_MODEL",
  "name": "",
  "scopes": {},
  "filter": "",
  "load_all_models_initially": false,
  "current_space": {},
  "feature_visibility": {},
  "sub_path": "",
  "clear": [
    "filter"
  ]
});

// 3. The call
await new WorkspacesApi(client).updateWorkspace({ updateWorkspaceRequest: request });

// 4. The result
// (UpdateWorkspace answers no content: the call returns once it succeeded and throws a ResponseError otherwise)
console.log("Done");
```
