> ## Documentation Index
> Fetch the complete documentation index at: https://dify-6c0370d8-docs-agent-app-service-api.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Workspaces

> Show your workspace and how difyctl resolves which workspace your commands use

After you sign in, `difyctl` saves your workspace and runs every command against it. For the full resolution order, see [How difyctl Picks a Workspace](#how-difyctl-picks-a-workspace).

[`difyctl get workspace`](#show-your-workspace) shows the workspace you belong to, and accepts the [global flags](/en/cli/reference/global-flags).

## Show Your Workspace

```text theme={null}
difyctl get workspace [flags]
```

### Flags

| Flag          | Type   | Default | Description                                                                            |
| :------------ | :----- | :------ | :------------------------------------------------------------------------------------- |
| `-o <format>` | string | none    | Output format: `json`, `yaml`, `name`, or `wide`. Omit the flag for the default table. |

### Examples

See your workspace:

```bash theme={null}
difyctl get workspace
```

Get it as JSON for scripts:

```bash theme={null}
difyctl get workspace -o json
```

Print the workspace ID only:

```bash theme={null}
difyctl get workspace -o name
```

### Output

| Format               | What stdout gets                                                                           |
| :------------------- | :----------------------------------------------------------------------------------------- |
| default              | An aligned table. `CURRENT` marks your active workspace with `*`, and `ROLE` is your role. |
| `-o wide`            | The same columns. Workspaces have no wide-only columns.                                    |
| `-o json`, `-o yaml` | A `workspaces` array, each entry carrying `id`, `name`, `role`, `status`, and `current`.   |
| `-o name`            | The workspace ID.                                                                          |

Default table:

```text theme={null}
ID                                    NAME       ROLE    STATUS  CURRENT
b4e8d2a6-7c3f-4a1e-9d5b-8f2c6e0a4d7b  Acme Team  owner   normal  *
```

`-o json`:

```json theme={null}
{
  "workspaces": [
    {
      "id": "b4e8d2a6-7c3f-4a1e-9d5b-8f2c6e0a4d7b",
      "name": "Acme Team",
      "role": "owner",
      "status": "normal",
      "current": true
    }
  ]
}
```

### Exit Codes

| Code | Meaning                                        |
| :--- | :--------------------------------------------- |
| `0`  | Success                                        |
| `1`  | Network or server error                        |
| `2`  | Usage error, such as an unsupported `-o` value |
| `4`  | Authentication failure                         |
| `7`  | Rate limited (HTTP 429)                        |

See [Output Formats and Exit Codes](/en/cli/reference/output-formats-and-exit-codes) for the full scheme.

## How difyctl Picks a Workspace

Apps live in exactly one workspace, so every command runs against one. Normally that's the workspace saved when you signed in. `difyctl` resolves it in this order, taking the first value it finds:

1. The [`DIFY_WORKSPACE_ID`](/en/cli/reference/environment-variables) environment variable, an optional override.
2. Your stored default, written to `hosts.yml` in the config directory when you sign in.

If neither yields a workspace, the command fails with exit code `2`.

Workspace IDs are UUIDs, so use the ID from [`get workspace`](#show-your-workspace), not a workspace name. A value that isn't a UUID fails as a usage error.
