> ## Documentation Index
> Fetch the complete documentation index at: https://www.unkey.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Unkey is two separate products. Compute builds, deploys, and runs apps behind a gateway. API Management issues API keys, enforces rate limits, manages identities and permissions, and reports usage. Say which product a page belongs to; a reader can use either without the other.
> Every Unkey API endpoint is an HTTP POST to https://api.unkey.com/v2/{service}.{procedure} with a root key in the Authorization: Bearer header. Root keys are workspace scoped.
> Error codes have the form err:{system}:{category}:{specific} and each has a page at /errors/{system}/{category}/{specific}.
> The word environment means production or preview in Compute. Rate limiting has four meanings on this site; the glossary lists them.

# unkey workspace switch

> Change the active workspace for commands that use a CLI session.

Make another stored workspace the active one. Resource commands and `unkey deploy` that use a CLI session then send requests to that workspace. Commands that use a root key from `--root-key`, `UNKEY_ROOT_KEY`, or `--config` aren't affected, because a root key belongs to one workspace.

The command changes local state only. It doesn't call the API and needs no root key.

## Usage

```bash theme={"system"}
unkey workspace switch <workspace-id>
```

Exactly one workspace ID is required. Missing or extra arguments exit 1 with `usage: unkey workspace switch <workspace-id>`. The command has no flags.

The workspace must already have a stored session. Run `unkey workspace list` to see stored workspaces. To add a workspace, run `unkey login` and choose it on the approval page. A workspace without a stored session exits 1 with `switch workspace: cli session not found`.

On success, the command prints `Using workspace <workspace-id>.` to `stdout`. The change is saved for every later command and terminal until you switch again, run `unkey login`, or sign out of the active workspace.

## Examples

```bash theme={"system"}
unkey workspace switch ws_5678efgh
unkey projects list
```

See [unkey workspace list](https://www.unkey.com/docs/platform/cli/workspace/list.md) and [unkey login](https://www.unkey.com/docs/platform/cli/login.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.