|
1
|
import { Table, CodeTabs, CodeTab } from "docs-ui" |
|
2
|
|
|
3
|
export const metadata = { |
|
4
|
title: `whoami Command - Medusa Cloud CLI Reference`, |
|
5
|
} |
|
6
|
|
|
7
|
# {metadata.title} |
|
8
|
|
|
9
|
Show the authenticated user, the active organization, project, and environment, and CLI metadata. Use this command to verify which account and context the CLI is currently using. |
|
10
|
|
|
11
|
```bash |
|
12
|
mcloud whoami |
|
13
|
``` |
|
14
|
|
|
15
|
Returns the following information: |
|
16
|
|
|
17
|
<CodeTabs group="cli-output"> |
|
18
|
<CodeTab label="Plaintext" value="plaintext"> |
|
19
|
|
|
20
|
```bash |
|
21
|
CLI version: 0.1.10 |
|
22
|
Auth: jwt expires 2026-05-01 09:00 |
|
23
|
User: Alice Example <alice@example.com> (eu_01ABC) |
|
24
|
API URL: https://api.prod.medusajs.cloud |
|
25
|
Dashboard URL: https://cloud.medusajs.com |
|
26
|
|
|
27
|
Organization: My Organization (org_123) |
|
28
|
Project: my-store (proj_01ABC) |
|
29
|
Environment: production (projenv_01XYZ) |
|
30
|
``` |
|
31
|
|
|
32
|
</CodeTab> |
|
33
|
<CodeTab label="JSON (--json)" value="json"> |
|
34
|
|
|
35
|
```json |
|
36
|
{ |
|
37
|
"cli_version": "0.1.10", |
|
38
|
"auth": { |
|
39
|
"kind": "jwt", |
|
40
|
"expires_at": "2026-05-01T09:00:00.000Z" |
|
41
|
}, |
|
42
|
"user": { |
|
43
|
"id": "eu_01ABC", |
|
44
|
"email": "alice@example.com", |
|
45
|
"first_name": "Alice", |
|
46
|
"last_name": "Example" |
|
47
|
}, |
|
48
|
"api_url": "https://api.prod.medusajs.cloud", |
|
49
|
"dashboard_url": "https://cloud.medusajs.com", |
|
50
|
"organization": { |
|
51
|
"value": "org_123", |
|
52
|
"id": "org_123", |
|
53
|
"name": "My Organization" |
|
54
|
}, |
|
55
|
"project": { |
|
56
|
"value": "my-store", |
|
57
|
"id": "proj_01ABC", |
|
58
|
"handle": "my-store" |
|
59
|
}, |
|
60
|
"environment": { |
|
61
|
"value": "production", |
|
62
|
"id": "projenv_01XYZ", |
|
63
|
"handle": "production" |
|
64
|
} |
|
65
|
} |
|
66
|
``` |
|
67
|
|
|
68
|
</CodeTab> |
|
69
|
</CodeTabs> |
|
70
|
|
|
71
|
The `Auth` line shows whether the CLI is using a JWT (browser login) or an access key, and when the JWT expires (when applicable). |
|
72
|
|
|
73
|
## Options |
|
74
|
|
|
75
|
<Table> |
|
76
|
<Table.Header> |
|
77
|
<Table.Row> |
|
78
|
<Table.HeaderCell> |
|
79
|
Option |
|
80
|
</Table.HeaderCell> |
|
81
|
<Table.HeaderCell> |
|
82
|
Description |
|
83
|
</Table.HeaderCell> |
|
84
|
<Table.HeaderCell> |
|
85
|
Default |
|
86
|
</Table.HeaderCell> |
|
87
|
</Table.Row> |
|
88
|
</Table.Header> |
|
89
|
<Table.Body> |
|
90
|
<Table.Row> |
|
91
|
<Table.Cell> |
|
92
|
|
|
93
|
`--json` |
|
94
|
|
|
95
|
</Table.Cell> |
|
96
|
<Table.Cell> |
|
97
|
|
|
98
|
Print the result as JSON instead of formatted text. Useful for piping the active context into scripts. |
|
99
|
|
|
100
|
</Table.Cell> |
|
101
|
<Table.Cell> |
|
102
|
|
|
103
|
`false` |
|
104
|
|
|
105
|
</Table.Cell> |
|
106
|
</Table.Row> |
|
107
|
</Table.Body> |
|
108
|
</Table> |
|
109
|
|
|
110
|
--- |
|
111
|
|
|
112
|
## Verify Authentication in a Script |
|
113
|
|
|
114
|
Pipe `whoami --json` into `jq` to assert that the CLI is authenticated and that the active context is set before running other commands: |
|
115
|
|
|
116
|
```bash |
|
117
|
mcloud whoami --json | jq -e '.auth.kind != "none" and .organization.id != null' |
|
118
|
``` |
|
119
|
|
|
120
|
The command exits with a non-zero status if either condition is unmet, which is useful as a guard step in CI/CD pipelines. |
|
121
|
|
|
122
|
--- |
|
123
|
|
|
124
|
## Switch the Active Context |
|
125
|
|
|
126
|
To change the active organization, project, or environment, use [`mcloud use`](../use/page.mdx). |
|
127
|
|
|
128
|
To switch accounts, use [`mcloud logout`](../logout/page.mdx) followed by [`mcloud login`](../login/page.mdx). |