Skip to main content

Mastra.removeWorkspace()

The .removeWorkspace() method removes a workspace from the Mastra runtime registry. Pass { destroy: true } to destroy the workspace before it is removed.

Usage example
Direct link to Usage example

await mastra.removeWorkspace('workspace-123', { destroy: true })

Parameters
Direct link to Parameters

id:

string
The ID of the workspace to remove.

options?:

{ destroy?: boolean }
Optional cleanup behavior. Set `destroy` to `true` to call `workspace.destroy()` before removing the workspace.

Returns
Direct link to Returns

removed:

Promise<boolean>
`true` when a workspace was removed. `false` when no workspace exists for the ID.

When destroy is true and workspace.destroy() throws, the call rejects with that error and the workspace remains registered so the caller can retry cleanup.

On this page