Skip to main content
The Workspace API allows Lightning Web Components to interact with the Salesforce console workspace, controlling tabs, subtabs, and navigation. This API is essential for building console applications that provide agent-friendly interfaces.
Workspace API methods only work in console applications. Always check if you’re in a console context using IsConsoleNavigation before calling Workspace API methods.

Checking Console Context

Before using any Workspace API methods, verify you’re in a console application:

Opening Tabs

Open new workspace tabs programmatically. workspaceAPIOpenTab.js:

Opening Different Page Types

Opening Subtabs

Open subtabs within a parent tab. workspaceAPIOpenSubtab.js:

Setting Tab Label

Change the label of a tab dynamically. workspaceAPISetTabLabel.js:

Setting Tab Icon

Update the icon displayed on a tab. workspaceAPISetTabIcon.js:

Focusing Tabs

Bring a specific tab into focus. workspaceAPIFocusTab.js:

Refreshing Tabs

Refresh the content of a tab and optionally its subtabs. workspaceAPIRefreshTab.js:

Closing Tabs

Close tabs programmatically. workspaceAPICloseTab.js:

Preventing Tab Close

Disable the close button on a tab. workspaceAPIDisableTabClose.js:

Getting Tab Information

Get Focused Tab Info

Get All Tab Info

Get All Subtab Info

Highlighting Tabs

Highlight a tab to draw attention to it.
Available states:
  • success - Green highlight
  • warning - Orange highlight
  • error - Red highlight
  • info - Blue highlight (default)

Common Patterns

Update Tab Label with Record Name

Close All Subtabs

Best Practices

Always Check Console Context

Never call Workspace API methods without checking IsConsoleNavigation first:

Handle Async Operations

Workspace API methods return promises. Use async/await or .then():

Cache Tab IDs When Needed

If you need to reference a tab multiple times, cache the ID:

Provide User Feedback

Let users know when tab operations complete: