Skip to content

Commit eda3705

Browse files
committed
add retrieve user list
1 parent eb9a651 commit eda3705

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/admin/users/index.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,32 @@ The following filters are supported:
206206
- `created_before` and `created_after` - The time a user was created. Uses the
207207
RFC3339Nano format.
208208
- `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
209+
210+
## Use the Coder API to retrieve a list of users
211+
212+
Use the [Coder API](../../reference/api/users.md#get-users) to retrieve a full list of users on your Coder deployment:
213+
214+
```shell
215+
curl -X GET http://coder-server:8080/api/v2/users \
216+
-H 'Accept: application/json' \
217+
-H 'Coder-Session-Token: API_KEY'
218+
```
219+
220+
You can also filter your results based on the `organization_id` with:
221+
222+
```shell
223+
curl -X GET 'http://coder-server:8080/api/v2/users?organization_id=Example-Org' \
224+
-H 'Accept: application/json' \
225+
-H 'Coder-Session-Token: API_KEY'
226+
```
227+
228+
### Export a list of users to a CSV file
229+
230+
You can use [jq](https://jqlang.org/) to process the JSON response and export the results to a CSV file:
231+
232+
```shell
233+
curl -X GET http://coder-server:8080/api/v2/users \
234+
-H 'Accept: application/json' \
235+
-H 'Coder-Session-Token: API_KEY' | \
236+
jq -r '.users | (map(keys) | add | unique) as $cols | $cols, (.[] | [.[$cols[]]] | @csv)' > users.csv
237+
```

0 commit comments

Comments
 (0)