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
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions docs/admin/users/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,32 @@ 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

## Use the Coder API to retrieve a list of users

Use the [Coder API](../../reference/api/users.md#get-users) to retrieve a full list of users on your Coder deployment:

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

You can also filter your results based on the `organization_id` with:

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

### Export a list of users to a CSV file

You can use [jq](https://jqlang.org/) to process the JSON response and export the results to a CSV file:

```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
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coder users list > users.txt

This does the same thing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a documentation page for that. https://coder.com/docs/reference/cli/users_list

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather update CLI command to add description

Use: "list",
by adding the Short: "Prints the users list.", field

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example use case is here:

Short: short,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to switch it to the Coder CLI command and can also PR to the CLI source docs, but I do want to keep the heading in this doc, where I think it's more likely to be found and we can explain the examples better

++ to including a better description of list in both:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that with a better-described CLI command, our admin documentation could be pretty simple. We can demonstrate a single use case for exporting list to a CSV file. There is no need to cover all use cases in admin docs, as they are already covered in CLI docs.

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm torn - I agree, I don't think we need to catch every possibility from the same page.

but generally, I think if someone's looking for it, we should make it easy to find, and I think the CLI is almost that if someone already knows how they're trying to do it ("I want to use the CLI to get a list of users, what command do I use"), but in some cases, I think we want to catch people from web/docs search who just know they want to "list users" and don't know where they'd do that

it'd be really nice to check back on these pages in a few months to see if they're getting more traffic 🤔

Loading