> ## 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.

# ワークスペース

> ワークスペースを表示し、difyctl がコマンドで使用するワークスペースをどう決定するかを解説します

> このドキュメントは AI によって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/cli/reference/workspaces) を参照してください。

サインインすると、`difyctl` はワークスペースを保存し、すべてのコマンドをそのワークスペースに対して実行します。解決順序の詳細は [difyctl がワークスペースを選択する仕組み](#difyctl-がワークスペースを選択する仕組み) を参照してください。

[`difyctl get workspace`](#ワークスペースを表示) は所属するワークスペースを表示し、[グローバルフラグ](/ja/cli/reference/global-flags) を受け付けます。

## ワークスペースを表示

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

### フラグ

| フラグ           | 型      | デフォルト | 説明                                                              |
| :------------ | :----- | :---- | :-------------------------------------------------------------- |
| `-o <format>` | string | none  | 出力形式：`json`、`yaml`、`name`、`wide` のいずれか。フラグを省略するとデフォルトの表形式になります。 |

### 例

ワークスペースを表示する：

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

スクリプト用に JSON 形式で取得する：

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

ワークスペース ID のみを出力する：

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

### 出力

| 形式                  | stdout に出力される内容                                                       |
| :------------------ | :-------------------------------------------------------------------- |
| default             | 整列された表。`CURRENT` 列は現在アクティブなワークスペースを `*` で示し、`ROLE` 列はロールを示します。        |
| `-o wide`           | 同じ列です。ワークスペースに wide 専用の列はありません。                                       |
| `-o json`、`-o yaml` | `workspaces` 配列。各エントリには `id`、`name`、`role`、`status`、`current` が含まれます。 |
| `-o name`           | ワークスペース ID。                                                           |

デフォルトの表：

```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
    }
  ]
}
```

### 終了コード

| コード | 意味                             |
| :-- | :----------------------------- |
| `0` | 成功                             |
| `1` | ネットワークまたはサーバーエラー               |
| `2` | 使用方法のエラー（サポートされていない `-o` の値など） |
| `4` | 認証エラー                          |
| `7` | レート制限（HTTP 429）                |

全体の体系については [出力形式と終了コード](/ja/cli/reference/output-formats-and-exit-codes) を参照してください。

## difyctl がワークスペースを選択する仕組み

アプリは必ず 1 つのワークスペースに属するため、すべてのコマンドは 1 つのワークスペースに対して実行されます。通常は、サインイン時に保存されたワークスペースです。`difyctl` は次の順序で解決し、最初に見つかった値を使用します。

1. [`DIFY_WORKSPACE_ID`](/ja/cli/reference/environment-variables) 環境変数。任意のオーバーライドです。
2. 保存されたデフォルト値。サインイン時に設定ディレクトリの `hosts.yml` に書き込まれます。

どちらからもワークスペースが得られない場合、コマンドは終了コード `2` で失敗します。

ワークスペース ID は UUID です。ワークスペース名ではなく、[`get workspace`](#ワークスペースを表示) で取得した ID を使用してください。UUID でない値は使用方法のエラーになります。
