User Commands
The stategraph user command group provides user identity and tenant membership operations.
Commands
| Command | Description |
|---|---|
stategraph user whoami |
Display current user information |
stategraph user tenants list |
List tenants you belong to |
stategraph user whoami
Display information about the currently authenticated user. stategraph whoami is a top-level alias for the same command.
stategraph user whoami
Example
stategraph user whoami
By default, output is a field | value table:
field value
----------- ------------------------------------
id 550e8400-e29b-41d4-a716-446655440000
name Jane Smith
email jane@example.com
type User
avatar_url
auth_origin local
is_admin false
For scripting, use --format json:
stategraph user whoami --format json
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "Jane Smith",
"email": "jane@example.com",
"type": "user",
"is_admin": false
}
This command is useful for:
- Verifying your authentication is working
- Checking which account you're logged in as
- Getting your user ID for API calls
stategraph user tenants list
List all tenants that the current user is a member of.
stategraph user tenants list
Example
stategraph user tenants list
By default, output is an id | name table:
id name
------------------------------------ -----------
550e8400-e29b-41d4-a716-446655440000 production
660e8400-e29b-41d4-a716-446655440001 staging
770e8400-e29b-41d4-a716-446655440002 development
For scripting, use --format simple (tab-separated, no header) or --format json:
stategraph user tenants list --format simple
550e8400-e29b-41d4-a716-446655440000 production
660e8400-e29b-41d4-a716-446655440001 staging
770e8400-e29b-41d4-a716-446655440002 development
Scripting Examples
Get tenant ID by name
TENANT_ID=$(stategraph user tenants list --format simple | grep "production" | awk '{print $1}')
echo "Production tenant: $TENANT_ID"
Verify authentication in CI
#!/bin/bash
if ! stategraph user whoami > /dev/null 2>&1; then
echo "Authentication failed. Check STATEGRAPH_API_KEY."
exit 1
fi
echo "Authenticated successfully"
List all states across all tenants
stategraph user tenants list --format simple | while read id name; do
echo "=== $name ==="
stategraph states list --tenant "$id" --format json | jq -r '.results[].name'
done
Next Steps
- States - Manage Terraform states
- Authentication - Set up API keys
- CLI Overview - All CLI commands