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

Conversation

EdwardAngert
Copy link
Contributor

@EdwardAngert EdwardAngert commented May 13, 2025

previews

followup to slack thread:

Tim
what's the best way for customers to export a list of Coder users?

@ericpaulsen
the /api/v2/users API route returns all users in the deployment (along with other information - email, status, username, etc.). from https://coder.com/docs/reference/api/users#get-users

  • adds an easy-to-find section to the admin/users doc
  • updates the cli commands with short descriptions

@EdwardAngert EdwardAngert requested a review from ericpaulsen May 13, 2025 16:24
@EdwardAngert EdwardAngert self-assigned this May 13, 2025
@EdwardAngert EdwardAngert added the docs Area: coder.com/docs label May 13, 2025
Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

I think we should encourage CLI usage over API

Comment on lines 209 to 237

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

@ericpaulsen
Copy link
Member

looks great, thanks @EdwardAngert for filling this gap, and @matifali for the feedback.

Copy link
Member

@matifali matifali left a comment

Choose a reason for hiding this comment

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

That's great Edward. Left a few more suggestions.

EdwardAngert and others added 2 commits May 13, 2025 16:33
Co-authored-by: M Atif Ali <atif@coder.com>
Co-authored-by: M Atif Ali <atif@coder.com>
@EdwardAngert EdwardAngert enabled auto-merge (squash) May 13, 2025 20:40
@EdwardAngert EdwardAngert merged commit f9817af into main May 13, 2025
36 checks passed
@EdwardAngert EdwardAngert deleted the export-coder-users branch May 13, 2025 20:48
@github-actions github-actions bot locked and limited conversation to collaborators May 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
docs Area: coder.com/docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants