Skip to content

docs: add section on how to retrieve user list #17798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/testdata/coder_users_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ USAGE:
SUBCOMMANDS:
activate Update a user's status to 'active'. Active users can fully
interact with the platform
create
create Create a new user.
delete Delete a user by username or user_id.
edit-roles Edit a user's roles by username or id
list
list Prints the list of users.
show Show a single user. Use 'me' to indicate the currently
authenticated user.
suspend Update a user's status to 'suspended'. A suspended user cannot
Expand Down
2 changes: 2 additions & 0 deletions cli/testdata/coder_users_create_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ coder v0.0.0-devel
USAGE:
coder users create [flags]

Create a new user.

OPTIONS:
-O, --org string, $CODER_ORGANIZATION
Select which organization (uuid or name) to use.
Expand Down
2 changes: 2 additions & 0 deletions cli/testdata/coder_users_list_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ coder v0.0.0-devel
USAGE:
coder users list [flags]

Prints the list of users.

Aliases: ls

OPTIONS:
Expand Down
3 changes: 2 additions & 1 deletion cli/usercreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func (r *RootCmd) userCreate() *serpent.Command {
)
client := new(codersdk.Client)
cmd := &serpent.Command{
Use: "create",
Use: "create",
Short: "Create a new user.",
Middleware: serpent.Chain(
serpent.RequireNArgs(0),
r.InitClient(client),
Expand Down
1 change: 1 addition & 0 deletions cli/userlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (r *RootCmd) userList() *serpent.Command {

cmd := &serpent.Command{
Use: "list",
Short: "Prints the list of users.",
Aliases: []string{"ls"},
Middleware: serpent.Chain(
serpent.RequireNArgs(0),
Expand Down
39 changes: 39 additions & 0 deletions docs/admin/users/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,42 @@ The following filters are supported:
- `created_before` and `created_after` - The time a user was created. Uses the
RFC3339Nano format.
- `login_type` - Represents the login type of the user. Refer to the [LoginType documentation](https://pkg.go.dev/github.com/coder/coder/v2/codersdk#LoginType) for a list of supported values

## Retrieve your list of Coder users

<div class="tabs">

You can use the Coder CLI or API to retrieve your list of users.

### CLI

Use `users list` to export the list of users to a CSV file:

```shell
coder users list > users.csv
```

Visit the [users list](../../reference/cli/users_list.md) documentation for more options.

### API

Use [get users](../../reference/api/users.md#get-users):

```shell
curl -X GET http://coder-server:8080/api/v2/users \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```

To export the results to a CSV file, you can use [`jq`](https://jqlang.org/) to process the JSON response:

```shell
curl -X GET http://coder-server:8080/api/v2/users \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY' | \
jq -r '.users | (map(keys) | add | unique) as $cols | $cols, (.[] | [.[$cols[]]] | @csv)' > users.csv
```

Visit the [get users](../../reference/api/users.md#get-users) documentation for more options.

</div>
2 changes: 2 additions & 0 deletions docs/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,7 @@
},
{
"title": "users create",
"description": "Create a new user.",
"path": "reference/cli/users_create.md"
},
{
Expand All @@ -1639,6 +1640,7 @@
},
{
"title": "users list",
"description": "Prints the list of users.",
"path": "reference/cli/users_list.md"
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/cli/users.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/reference/cli/users_create.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/reference/cli/users_list.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading