# WorkspaceLayoutsAPI

**Kind**: interface | **Module**: [Workspaces](https://docs.interop.io/desktop/reference/javascript/workspaces/index.md) | **Access**: `io.workspaces.layouts`

**Source**: https://docs.interop.io/desktop/reference/javascript/workspaces/workspacelayoutsapi/index.html

An API enabling basic CRUD workspaces actions

## Methods

### delete

Deletes a previously saved layout. In **io.Connect Browser** delete will fail with an error in trying to delete a read-only layout, this is a layout defined in the io.layouts.json file.

```ts
(name: string) => Promise<void>
```

**Parameters**

- **`name`** (`string`, required)
  The name of the layout to delete.

**Returns**: `Promise<void>`

### export

Returns all layouts which satisfy the predicate. This collection of all saved layouts includes the layouts structure. If no predicate is provided, it returns all saved layouts.

```ts
(predicate?: (layout: WorkspaceLayout) => boolean) => Promise<WorkspaceLayout[]>
```

**Parameters**

- **`predicate`** (`(layout: WorkspaceLayout) => boolean`, optional)
  A filtering function (predicate) called for each saved layout.

**Returns**: `Promise<WorkspaceLayout[]>`

### getSummaries

Returns a collection of summarized layouts data. This data contains all the standard data excluding the actual structure of the layout.
This is helpful in cases where a simple query of existing layouts is needed without the complexity of transmitting the full layouts structure.

```ts
() => Promise<WorkspaceLayoutSummary[]>
```

**Returns**: `Promise<WorkspaceLayoutSummary[]>`

### import

Saves the provided layouts into io.Connect. In **io.Connect Browser** this will fail with an error if a provided layout's name matches a read-only layout.

```ts
(layouts: WorkspaceLayout[], mode?: "replace" | "merge") => Promise<void>
```

**Parameters**

- **`layouts`** (`WorkspaceLayout[]`, required)
  A collection of layouts to add to IO Connet.
- **`mode`** (`"replace" | "merge"`, optional)

**Returns**: `Promise<void>`

### onRemoved

Notifies when a layouts has been removed.

```ts
(callback: (layout: WorkspaceLayout) => void) => Promise<Unsubscribe>
```

**Parameters**

- **`callback`** (`(layout: WorkspaceLayout) => void`, required)
  Callback function to handle the event. Receives the removed layout as a parameter.

**Returns**: `Promise<Unsubscribe>`

### onSaved

Notifies when a layouts has been saved. This event is fired when a new layout has been saved and an existing layout has been updated.

```ts
(callback: (layout: WorkspaceLayout) => void) => Promise<Unsubscribe>
```

**Parameters**

- **`callback`** (`(layout: WorkspaceLayout) => void`, required)
  Callback function to handle the event. Receives the saved layout as a parameter.

**Returns**: `Promise<Unsubscribe>`

### save

Saves an existing, open workspace as a layout.

```ts
(config: WorkspaceLayoutSaveConfig) => Promise<WorkspaceLayout>
```

**Parameters**

- **`config`** (`WorkspaceLayoutSaveConfig`, required)
  An object describing the name of the layout and the id of the workspace, whose structure will be saved.

**Returns**: `Promise<WorkspaceLayout>`

## Related types

- [Unsubscribe](https://docs.interop.io/desktop/reference/javascript/workspaces/unsubscribe/index.md)
- [WorkspaceLayout](https://docs.interop.io/desktop/reference/javascript/workspaces/workspacelayout/index.md)
- [WorkspaceLayoutSaveConfig](https://docs.interop.io/desktop/reference/javascript/workspaces/workspacelayoutsaveconfig/index.md)
- [WorkspaceLayoutSummary](https://docs.interop.io/desktop/reference/javascript/workspaces/workspacelayoutsummary/index.md)
