Workspaces

When belonging to different workspaces, it’s possible you need to switch between workspaces when working on a project.

Imagine the following scenario: You have your personal Tinybird account and you belong to two workspaces: production and staging. You want to be able switch from staging to production when necessary in order to push the current status of your project.

Authenticate

Authenticate as usual, using the admin token of your personal account:

Authenticate
$> tb auth
Copy the admin token from https://ui.tinybird.co/tokens and paste it here: <pasted token>
** Auth successful!
** Configuration written to .tinyb file, consider adding it to .gitignore

List workspaces

Then, you can list the workspaces you have access to:

List workspaces
$> tb workspace ls

---------------------------------------------------------------------------------
| name                | id                                   | role  | plan     |
---------------------------------------------------------------------------------
| User                | 24cc4f46-4110-490e-a5b5-e3ffb0d54ee3 | admin | personal |
| Staging             | 3a798a68-38b1-4947-a0eb-399b7adbfa25 | admin | personal |
| Production          | 841717b1-2472-44f9-9a81-42f1263cabe7 | admin | personal |
---------------------------------------------------------------------------------

Add workspaces

Let’s add both workspaces using their workspace id, respectively.

Show local config
$> tb auth ls

----------------------------------------------------------------------------------------------------------
| idx | name                | id                                   | host                   | is_current |
----------------------------------------------------------------------------------------------------------
|   0 | User                | 24cc4f46-4110-490e-a5b5-e3ffb0d54ee3 | http://api.tinybird.co | True       |
----------------------------------------------------------------------------------------------------------
Add the Staging workspace
$> tb auth add --workspace 3a798a68-38b1-4947-a0eb-399b7adbfa25

** Workspace config added!

$> tb auth ls

----------------------------------------------------------------------------------------------------------
| idx | name                | id                                   | host                   | is_current |
----------------------------------------------------------------------------------------------------------
|   0 | User                | 24cc4f46-4110-490e-a5b5-e3ffb0d54ee3 | http://api.tinybird.co | True       |
|   1 | Staging             | 3a798a68-38b1-4947-a0eb-399b7adbfa25 | http://api.tinybird.co | False      |
----------------------------------------------------------------------------------------------------------
Add the Production workspace
$> tb auth add --workspace 3a798a68-38b1-4947-a0eb-399b7adbfa25

** Workspace config added!

$> tb auth ls

----------------------------------------------------------------------------------------------------------
| idx | name                | id                                   | host                   | is_current |
----------------------------------------------------------------------------------------------------------
|   0 | User                | 24cc4f46-4110-490e-a5b5-e3ffb0d54ee3 | http://api.tinybird.co | True       |
|   1 | Staging             | 3a798a68-38b1-4947-a0eb-399b7adbfa25 | http://api.tinybird.co | False      |
|   2 | Production          | 841717b1-2472-44f9-9a81-42f1263cabe7 | http://api.tinybird.co | False      |
----------------------------------------------------------------------------------------------------------

Switch to a workspace

Now, you can authenticate to the another workspace by using the switch command:

Switch to the Staging workspace using workspace id
$> tb auth use --workspace 3a798a68-38b1-4947-a0eb-399b7adbfa25

** Now using Staging workspace (3a798a68-38b1-4947-a0eb-399b7adbfa25)

$> tb auth ls

----------------------------------------------------------------------------------------------------------
| idx | name                | id                                   | host                   | is_current |
----------------------------------------------------------------------------------------------------------
|   0 | User                | 24cc4f46-4110-490e-a5b5-e3ffb0d54ee3 | http://api.tinybird.co | False      |
|   1 | Staging             | 3a798a68-38b1-4947-a0eb-399b7adbfa25 | http://api.tinybird.co | True       |
|   2 | Production          | 841717b1-2472-44f9-9a81-42f1263cabe7 | http://api.tinybird.co | False      |
----------------------------------------------------------------------------------------------------------
Switch to the Production workspace using local config index
$> tb auth use --workspace 2

** Now using Production workspace (841717b1-2472-44f9-9a81-42f1263cabe7)

$> tb auth ls

----------------------------------------------------------------------------------------------------------
| idx | name                | id                                   | host                   | is_current |
----------------------------------------------------------------------------------------------------------
|   0 | User                | 24cc4f46-4110-490e-a5b5-e3ffb0d54ee3 | http://api.tinybird.co | False      |
|   1 | Staging             | 3a798a68-38b1-4947-a0eb-399b7adbfa25 | http://api.tinybird.co | False      |
|   2 | Production          | 841717b1-2472-44f9-9a81-42f1263cabe7 | http://api.tinybird.co | True       |
----------------------------------------------------------------------------------------------------------

You can also quickly check which workspace you’re currently into:

Show current workspace
$> tb auth ls --workspace current

----------------------------------------------------------------------------------------------------------
| idx | name                | id                                   | host                   | is_current |
----------------------------------------------------------------------------------------------------------
|   2 | Production          | 841717b1-2472-44f9-9a81-42f1263cabe7 | http://api.tinybird.co | True       |
----------------------------------------------------------------------------------------------------------