# Users

## Get users [#get-users]

### Code samples [#code-samples]

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

`GET /api/v2/users`

### Parameters [#parameters]

| Name       | In    | Type         | Required | Description  |
| ---------- | ----- | ------------ | -------- | ------------ |
| `q`        | query | string       | false    | Search query |
| `after_id` | query | string(uuid) | false    | After ID     |
| `limit`    | query | integer      | false    | Page limit   |
| `offset`   | query | integer      | false    | Page offset  |

### Example responses [#example-responses]

> 200 Response

```json
{
  "count": 0,
  "users": [
    {
      "avatar_url": "http://example.com",
      "created_at": "2019-08-24T14:15:22Z",
      "email": "user@example.com",
      "has_ai_seat": true,
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "is_service_account": true,
      "last_seen_at": "2019-08-24T14:15:22Z",
      "login_type": "",
      "name": "string",
      "organization_ids": [
        "497f6eca-6276-4993-bfeb-53cbbbba6f08"
      ],
      "roles": [
        {
          "display_name": "string",
          "name": "string",
          "organization_id": "string"
        }
      ],
      "status": "active",
      "theme_preference": "string",
      "updated_at": "2019-08-24T14:15:22Z",
      "username": "string"
    }
  ]
}
```

### Responses [#responses]

| Status | Meaning                                                 | Description | Schema                                                                                  |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.GetUsersResponse](/beta-docs/reference/api/schemas/#codersdkgetusersresponse) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Create new user [#create-new-user]

### Code samples [#code-samples-1]

```sh
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/users \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`POST /api/v2/users`

> Body parameter

```json
{
  "email": "user@example.com",
  "login_type": "",
  "name": "string",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "password": "string",
  "roles": [
    "string"
  ],
  "service_account": true,
  "user_status": "active",
  "username": "string"
}
```

### Parameters [#parameters-1]

| Name   | In   | Type                                                                                                      | Required | Description         |
| ------ | ---- | --------------------------------------------------------------------------------------------------------- | -------- | ------------------- |
| `body` | body | [codersdk.CreateUserRequestWithOrgs](/beta-docs/reference/api/schemas/#codersdkcreateuserrequestwithorgs) | true     | Create user request |

### Example responses [#example-responses-1]

> 201 Response

```json
{
  "avatar_url": "http://example.com",
  "created_at": "2019-08-24T14:15:22Z",
  "email": "user@example.com",
  "has_ai_seat": true,
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "is_service_account": true,
  "last_seen_at": "2019-08-24T14:15:22Z",
  "login_type": "",
  "name": "string",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "roles": [
    {
      "display_name": "string",
      "name": "string",
      "organization_id": "string"
    }
  ],
  "status": "active",
  "theme_preference": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "username": "string"
}
```

### Responses [#responses-1]

| Status | Meaning                                                      | Description | Schema                                                          |
| ------ | ------------------------------------------------------------ | ----------- | --------------------------------------------------------------- |
| 201    | [Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) | Created     | [codersdk.User](/beta-docs/reference/api/schemas/#codersdkuser) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get authentication methods [#get-authentication-methods]

### Code samples [#code-samples-2]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/authmethods \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/authmethods`

### Example responses [#example-responses-2]

> 200 Response

```json
{
  "github": {
    "default_provider_configured": true,
    "enabled": true
  },
  "oidc": {
    "enabled": true,
    "iconUrl": "string",
    "signInText": "string"
  },
  "password": {
    "enabled": true
  },
  "terms_of_service_url": "string"
}
```

### Responses [#responses-2]

| Status | Meaning                                                 | Description | Schema                                                                        |
| ------ | ------------------------------------------------------- | ----------- | ----------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.AuthMethods](/beta-docs/reference/api/schemas/#codersdkauthmethods) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Check initial user created [#check-initial-user-created]

### Code samples [#code-samples-3]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/first \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/first`

### Example responses [#example-responses-3]

> 200 Response

```json
{
  "detail": "string",
  "message": "string",
  "validations": [
    {
      "detail": "string",
      "field": "string"
    }
  ]
}
```

### Responses [#responses-3]

| Status | Meaning                                                 | Description | Schema                                                                  |
| ------ | ------------------------------------------------------- | ----------- | ----------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.Response](/beta-docs/reference/api/schemas/#codersdkresponse) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Create initial user [#create-initial-user]

### Code samples [#code-samples-4]

```sh
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/users/first \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`POST /api/v2/users/first`

> Body parameter

```json
{
  "email": "string",
  "name": "string",
  "onboarding_info": {
    "newsletter_marketing": true,
    "newsletter_releases": true
  },
  "password": "string",
  "trial": true,
  "trial_info": {
    "company_name": "string",
    "country": "string",
    "developers": "string",
    "first_name": "string",
    "job_title": "string",
    "last_name": "string",
    "phone_number": "string"
  },
  "username": "string"
}
```

### Parameters [#parameters-2]

| Name   | In   | Type                                                                                                | Required | Description        |
| ------ | ---- | --------------------------------------------------------------------------------------------------- | -------- | ------------------ |
| `body` | body | [codersdk.CreateFirstUserRequest](/beta-docs/reference/api/schemas/#codersdkcreatefirstuserrequest) | true     | First user request |

### Example responses [#example-responses-4]

> 201 Response

```json
{
  "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
}
```

### Responses [#responses-4]

| Status | Meaning                                                      | Description | Schema                                                                                                |
| ------ | ------------------------------------------------------------ | ----------- | ----------------------------------------------------------------------------------------------------- |
| 201    | [Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) | Created     | [codersdk.CreateFirstUserResponse](/beta-docs/reference/api/schemas/#codersdkcreatefirstuserresponse) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Log out user [#log-out-user]

### Code samples [#code-samples-5]

```sh
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/users/logout \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`POST /api/v2/users/logout`

### Example responses [#example-responses-5]

> 200 Response

```json
{
  "detail": "string",
  "message": "string",
  "validations": [
    {
      "detail": "string",
      "field": "string"
    }
  ]
}
```

### Responses [#responses-5]

| Status | Meaning                                                 | Description | Schema                                                                  |
| ------ | ------------------------------------------------------- | ----------- | ----------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.Response](/beta-docs/reference/api/schemas/#codersdkresponse) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## OAuth 2.0 GitHub Callback [#oauth-20-github-callback]

### Code samples [#code-samples-6]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/oauth2/github/callback \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/oauth2/github/callback`

### Responses [#responses-6]

| Status | Meaning                                                                 | Description        | Schema |
| ------ | ----------------------------------------------------------------------- | ------------------ | ------ |
| 307    | [Temporary Redirect](https://tools.ietf.org/html/rfc7231#section-6.4.7) | Temporary Redirect |        |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get Github device auth [#get-github-device-auth]

### Code samples [#code-samples-7]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/oauth2/github/device \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/oauth2/github/device`

### Example responses [#example-responses-6]

> 200 Response

```json
{
  "device_code": "string",
  "expires_in": 0,
  "interval": 0,
  "user_code": "string",
  "verification_uri": "string"
}
```

### Responses [#responses-7]

| Status | Meaning                                                 | Description | Schema                                                                                      |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.ExternalAuthDevice](/beta-docs/reference/api/schemas/#codersdkexternalauthdevice) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get OIDC claims for the authenticated user [#get-oidc-claims-for-the-authenticated-user]

### Code samples [#code-samples-8]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/oidc-claims \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/oidc-claims`

### Example responses [#example-responses-7]

> 200 Response

```json
{
  "claims": {}
}
```

### Responses [#responses-8]

| Status | Meaning                                                 | Description | Schema                                                                                      |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.OIDCClaimsResponse](/beta-docs/reference/api/schemas/#codersdkoidcclaimsresponse) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## OpenID Connect Callback [#openid-connect-callback]

### Code samples [#code-samples-9]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/oidc/callback \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/oidc/callback`

### Responses [#responses-9]

| Status | Meaning                                                                 | Description        | Schema |
| ------ | ----------------------------------------------------------------------- | ------------------ | ------ |
| 307    | [Temporary Redirect](https://tools.ietf.org/html/rfc7231#section-6.4.7) | Temporary Redirect |        |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get user by name [#get-user-by-name]

### Code samples [#code-samples-10]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}`

### Parameters [#parameters-3]

| Name   | In   | Type   | Required | Description              |
| ------ | ---- | ------ | -------- | ------------------------ |
| `user` | path | string | true     | User ID, username, or me |

### Example responses [#example-responses-8]

> 200 Response

```json
{
  "avatar_url": "http://example.com",
  "created_at": "2019-08-24T14:15:22Z",
  "email": "user@example.com",
  "has_ai_seat": true,
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "is_service_account": true,
  "last_seen_at": "2019-08-24T14:15:22Z",
  "login_type": "",
  "name": "string",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "roles": [
    {
      "display_name": "string",
      "name": "string",
      "organization_id": "string"
    }
  ],
  "status": "active",
  "theme_preference": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "username": "string"
}
```

### Responses [#responses-10]

| Status | Meaning                                                 | Description | Schema                                                          |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.User](/beta-docs/reference/api/schemas/#codersdkuser) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Delete user [#delete-user]

### Code samples [#code-samples-11]

```sh
# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/users/{user} \
  -H 'Coder-Session-Token: API_KEY'
```

`DELETE /api/v2/users/{user}`

### Parameters [#parameters-4]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Responses [#responses-11]

| Status | Meaning                                                 | Description | Schema |
| ------ | ------------------------------------------------------- | ----------- | ------ |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          |        |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get user appearance settings [#get-user-appearance-settings]

### Code samples [#code-samples-12]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/appearance \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/appearance`

### Parameters [#parameters-5]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Example responses [#example-responses-9]

> 200 Response

```json
{
  "terminal_font": "",
  "theme_dark": "string",
  "theme_light": "string",
  "theme_mode": "",
  "theme_preference": "string"
}
```

### Responses [#responses-12]

| Status | Meaning                                                 | Description | Schema                                                                                              |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.UserAppearanceSettings](/beta-docs/reference/api/schemas/#codersdkuserappearancesettings) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Update user appearance settings [#update-user-appearance-settings]

### Code samples [#code-samples-13]

```sh
# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/appearance \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`PUT /api/v2/users/{user}/appearance`

> Body parameter

```json
{
  "terminal_font": "",
  "theme_dark": "light",
  "theme_light": "light",
  "theme_mode": "sync",
  "theme_preference": "string"
}
```

### Parameters [#parameters-6]

| Name   | In   | Type                                                                                                                          | Required | Description             |
| ------ | ---- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------- |
| `user` | path | string                                                                                                                        | true     | User ID, name, or me    |
| `body` | body | [codersdk.UpdateUserAppearanceSettingsRequest](/beta-docs/reference/api/schemas/#codersdkupdateuserappearancesettingsrequest) | true     | New appearance settings |

### Example responses [#example-responses-10]

> 200 Response

```json
{
  "terminal_font": "",
  "theme_dark": "string",
  "theme_light": "string",
  "theme_mode": "",
  "theme_preference": "string"
}
```

### Responses [#responses-13]

| Status | Meaning                                                 | Description | Schema                                                                                              |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.UserAppearanceSettings](/beta-docs/reference/api/schemas/#codersdkuserappearancesettings) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get autofill build parameters for user [#get-autofill-build-parameters-for-user]

### Code samples [#code-samples-14]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/autofill-parameters?template_id=string \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/autofill-parameters`

### Parameters [#parameters-7]

| Name          | In    | Type   | Required | Description              |
| ------------- | ----- | ------ | -------- | ------------------------ |
| `user`        | path  | string | true     | User ID, username, or me |
| `template_id` | query | string | true     | Template ID              |

### Example responses [#example-responses-11]

> 200 Response

```json
[
  {
    "name": "string",
    "value": "string"
  }
]
```

### Responses [#responses-14]

| Status | Meaning                                                 | Description | Schema                                                                                     |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------ |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | array of [codersdk.UserParameter](/beta-docs/reference/api/schemas/#codersdkuserparameter) |

<h3 id="get-autofill-build-parameters-for-user-responseschema">Response Schema</h3>

Status Code **200**

| Name           | Type   | Required | Restrictions | Description |
| -------------- | ------ | -------- | ------------ | ----------- |
| `[array item]` | array  | false    |              |             |
| `» name`       | string | false    |              |             |
| `» value`      | string | false    |              |             |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get user Git SSH key [#get-user-git-ssh-key]

### Code samples [#code-samples-15]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/gitsshkey \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/gitsshkey`

### Parameters [#parameters-8]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Example responses [#example-responses-12]

> 200 Response

```json
{
  "created_at": "2019-08-24T14:15:22Z",
  "public_key": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
}
```

### Responses [#responses-15]

| Status | Meaning                                                 | Description | Schema                                                                    |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.GitSSHKey](/beta-docs/reference/api/schemas/#codersdkgitsshkey) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Regenerate user SSH key [#regenerate-user-ssh-key]

### Code samples [#code-samples-16]

```sh
# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/gitsshkey \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`PUT /api/v2/users/{user}/gitsshkey`

### Parameters [#parameters-9]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Example responses [#example-responses-13]

> 200 Response

```json
{
  "created_at": "2019-08-24T14:15:22Z",
  "public_key": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
}
```

### Responses [#responses-16]

| Status | Meaning                                                 | Description | Schema                                                                    |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.GitSSHKey](/beta-docs/reference/api/schemas/#codersdkgitsshkey) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Create new session key [#create-new-session-key]

### Code samples [#code-samples-17]

```sh
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/users/{user}/keys \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`POST /api/v2/users/{user}/keys`

### Parameters [#parameters-10]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Example responses [#example-responses-14]

> 201 Response

```json
{
  "key": "string"
}
```

### Responses [#responses-17]

| Status | Meaning                                                      | Description | Schema                                                                                              |
| ------ | ------------------------------------------------------------ | ----------- | --------------------------------------------------------------------------------------------------- |
| 201    | [Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) | Created     | [codersdk.GenerateAPIKeyResponse](/beta-docs/reference/api/schemas/#codersdkgenerateapikeyresponse) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get user tokens [#get-user-tokens]

### Code samples [#code-samples-18]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/keys/tokens \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/keys/tokens`

### Parameters [#parameters-11]

| Name              | In    | Type    | Required | Description                        |
| ----------------- | ----- | ------- | -------- | ---------------------------------- |
| `user`            | path  | string  | true     | User ID, name, or me               |
| `include_expired` | query | boolean | false    | Include expired tokens in the list |

### Example responses [#example-responses-15]

> 200 Response

```json
[
  {
    "allow_list": [
      {
        "id": "string",
        "type": "*"
      }
    ],
    "created_at": "2019-08-24T14:15:22Z",
    "expires_at": "2019-08-24T14:15:22Z",
    "id": "string",
    "last_used": "2019-08-24T14:15:22Z",
    "lifetime_seconds": 0,
    "login_type": "password",
    "scope": "all",
    "scopes": [
      "all"
    ],
    "token_name": "string",
    "updated_at": "2019-08-24T14:15:22Z",
    "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
  }
]
```

### Responses [#responses-18]

| Status | Meaning                                                 | Description | Schema                                                                       |
| ------ | ------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | array of [codersdk.APIKey](/beta-docs/reference/api/schemas/#codersdkapikey) |

<h3 id="get-user-tokens-responseschema">Response Schema</h3>

Status Code **200**

| Name                 | Type                                                                            | Required | Restrictions | Description                     |
| -------------------- | ------------------------------------------------------------------------------- | -------- | ------------ | ------------------------------- |
| `[array item]`       | array                                                                           | false    |              |                                 |
| `» allow_list`       | array                                                                           | false    |              |                                 |
| `»» id`              | string                                                                          | false    |              |                                 |
| `»» type`            | [codersdk.RBACResource](/beta-docs/reference/api/schemas/#codersdkrbacresource) | false    |              |                                 |
| `» created_at`       | string(date-time)                                                               | true     |              |                                 |
| `» expires_at`       | string(date-time)                                                               | true     |              |                                 |
| `» id`               | string                                                                          | true     |              |                                 |
| `» last_used`        | string(date-time)                                                               | true     |              |                                 |
| `» lifetime_seconds` | integer                                                                         | true     |              |                                 |
| `» login_type`       | [codersdk.LoginType](/beta-docs/reference/api/schemas/#codersdklogintype)       | true     |              |                                 |
| `» scope`            | [codersdk.APIKeyScope](/beta-docs/reference/api/schemas/#codersdkapikeyscope)   | false    |              | Deprecated: use Scopes instead. |
| `» scopes`           | array                                                                           | false    |              |                                 |
| `» token_name`       | string                                                                          | true     |              |                                 |
| `» updated_at`       | string(date-time)                                                               | true     |              |                                 |
| `» user_id`          | string(uuid)                                                                    | true     |              |                                 |

#### Enumerated Values [#enumerated-values]

| Property     | Value(s)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type`       | `*`, `ai_gateway_key`, `ai_model_price`, `ai_provider`, `ai_seat`, `aibridge_interception`, `api_key`, `assign_org_role`, `assign_role`, `audit_log`, `boundary_log`, `boundary_usage`, `chat`, `chat_model_config`, `connection_log`, `crypto_key`, `debug_info`, `deployment_config`, `deployment_stats`, `file`, `group`, `group_member`, `idpsync_settings`, `inbox_notification`, `license`, `mcp_server_config`, `notification_message`, `notification_preference`, `notification_template`, `oauth2_app`, `oauth2_app_code_token`, `oauth2_app_secret`, `organization`, `organization_member`, `prebuilt_workspace`, `provisioner_daemon`, `provisioner_jobs`, `replicas`, `system`, `tailnet_coordinator`, `task`, `template`, `usage_event`, `user`, `user_secret`, `user_skill`, `webpush_subscription`, `workspace`, `workspace_agent_devcontainers`, `workspace_agent_resource_monitor`, `workspace_build_orchestration`, `workspace_dormant`, `workspace_proxy` |
| `login_type` | `github`, `oidc`, `password`, `token`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `scope`      | `all`, `application_connect`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Create token API key [#create-token-api-key]

### Code samples [#code-samples-19]

```sh
# Example request using curl
curl -X POST http://coder-server:8080/api/v2/users/{user}/keys/tokens \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`POST /api/v2/users/{user}/keys/tokens`

> Body parameter

```json
{
  "allow_list": [
    {
      "id": "string",
      "type": "*"
    }
  ],
  "lifetime": 0,
  "scope": "all",
  "scopes": [
    "all"
  ],
  "token_name": "string"
}
```

### Parameters [#parameters-12]

| Name   | In   | Type                                                                                        | Required | Description          |
| ------ | ---- | ------------------------------------------------------------------------------------------- | -------- | -------------------- |
| `user` | path | string                                                                                      | true     | User ID, name, or me |
| `body` | body | [codersdk.CreateTokenRequest](/beta-docs/reference/api/schemas/#codersdkcreatetokenrequest) | true     | Create token request |

### Example responses [#example-responses-16]

> 201 Response

```json
{
  "key": "string"
}
```

### Responses [#responses-19]

| Status | Meaning                                                      | Description | Schema                                                                                              |
| ------ | ------------------------------------------------------------ | ----------- | --------------------------------------------------------------------------------------------------- |
| 201    | [Created](https://tools.ietf.org/html/rfc7231#section-6.3.2) | Created     | [codersdk.GenerateAPIKeyResponse](/beta-docs/reference/api/schemas/#codersdkgenerateapikeyresponse) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get API key by token name [#get-api-key-by-token-name]

### Code samples [#code-samples-20]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/keys/tokens/{keyname} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/keys/tokens/{keyname}`

### Parameters [#parameters-13]

| Name      | In   | Type           | Required | Description          |
| --------- | ---- | -------------- | -------- | -------------------- |
| `user`    | path | string         | true     | User ID, name, or me |
| `keyname` | path | string(string) | true     | Key Name             |

### Example responses [#example-responses-17]

> 200 Response

```json
{
  "allow_list": [
    {
      "id": "string",
      "type": "*"
    }
  ],
  "created_at": "2019-08-24T14:15:22Z",
  "expires_at": "2019-08-24T14:15:22Z",
  "id": "string",
  "last_used": "2019-08-24T14:15:22Z",
  "lifetime_seconds": 0,
  "login_type": "password",
  "scope": "all",
  "scopes": [
    "all"
  ],
  "token_name": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
}
```

### Responses [#responses-20]

| Status | Meaning                                                 | Description | Schema                                                              |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.APIKey](/beta-docs/reference/api/schemas/#codersdkapikey) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get API key by ID [#get-api-key-by-id]

### Code samples [#code-samples-21]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/keys/{keyid} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/keys/{keyid}`

### Parameters [#parameters-14]

| Name    | In   | Type           | Required | Description          |
| ------- | ---- | -------------- | -------- | -------------------- |
| `user`  | path | string         | true     | User ID, name, or me |
| `keyid` | path | string(string) | true     | Key ID               |

### Example responses [#example-responses-18]

> 200 Response

```json
{
  "allow_list": [
    {
      "id": "string",
      "type": "*"
    }
  ],
  "created_at": "2019-08-24T14:15:22Z",
  "expires_at": "2019-08-24T14:15:22Z",
  "id": "string",
  "last_used": "2019-08-24T14:15:22Z",
  "lifetime_seconds": 0,
  "login_type": "password",
  "scope": "all",
  "scopes": [
    "all"
  ],
  "token_name": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
}
```

### Responses [#responses-21]

| Status | Meaning                                                 | Description | Schema                                                              |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.APIKey](/beta-docs/reference/api/schemas/#codersdkapikey) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Delete API key [#delete-api-key]

### Code samples [#code-samples-22]

```sh
# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/users/{user}/keys/{keyid} \
  -H 'Coder-Session-Token: API_KEY'
```

`DELETE /api/v2/users/{user}/keys/{keyid}`

### Parameters [#parameters-15]

| Name    | In   | Type           | Required | Description          |
| ------- | ---- | -------------- | -------- | -------------------- |
| `user`  | path | string         | true     | User ID, name, or me |
| `keyid` | path | string(string) | true     | Key ID               |

### Responses [#responses-22]

| Status | Meaning                                                         | Description | Schema |
| ------ | --------------------------------------------------------------- | ----------- | ------ |
| 204    | [No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5) | No Content  |        |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Expire API key [#expire-api-key]

### Code samples [#code-samples-23]

```sh
# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/keys/{keyid}/expire \
  -H 'Accept: */*' \
  -H 'Coder-Session-Token: API_KEY'
```

`PUT /api/v2/users/{user}/keys/{keyid}/expire`

### Parameters [#parameters-16]

| Name    | In   | Type           | Required | Description          |
| ------- | ---- | -------------- | -------- | -------------------- |
| `user`  | path | string         | true     | User ID, name, or me |
| `keyid` | path | string(string) | true     | Key ID               |

### Example responses [#example-responses-19]

> 404 Response

### Responses [#responses-23]

| Status | Meaning                                                                    | Description           | Schema                                                                  |
| ------ | -------------------------------------------------------------------------- | --------------------- | ----------------------------------------------------------------------- |
| 204    | [No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5)            | No Content            |                                                                         |
| 404    | [Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)             | Not Found             | [codersdk.Response](/beta-docs/reference/api/schemas/#codersdkresponse) |
| 500    | [Internal Server Error](https://tools.ietf.org/html/rfc7231#section-6.6.1) | Internal Server Error | [codersdk.Response](/beta-docs/reference/api/schemas/#codersdkresponse) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get user login type [#get-user-login-type]

### Code samples [#code-samples-24]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/login-type \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/login-type`

### Parameters [#parameters-17]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Example responses [#example-responses-20]

> 200 Response

```json
{
  "login_type": ""
}
```

### Responses [#responses-24]

| Status | Meaning                                                 | Description | Schema                                                                            |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.UserLoginType](/beta-docs/reference/api/schemas/#codersdkuserlogintype) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get organizations by user [#get-organizations-by-user]

### Code samples [#code-samples-25]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/organizations \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/organizations`

### Parameters [#parameters-18]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Example responses [#example-responses-21]

> 200 Response

```json
[
  {
    "created_at": "2019-08-24T14:15:22Z",
    "default_org_member_roles": [
      "string"
    ],
    "description": "string",
    "display_name": "string",
    "icon": "string",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "is_default": true,
    "name": "string",
    "updated_at": "2019-08-24T14:15:22Z"
  }
]
```

### Responses [#responses-25]

| Status | Meaning                                                 | Description | Schema                                                                                   |
| ------ | ------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | array of [codersdk.Organization](/beta-docs/reference/api/schemas/#codersdkorganization) |

<h3 id="get-organizations-by-user-responseschema">Response Schema</h3>

Status Code **200**

| Name                         | Type              | Required | Restrictions | Description                                                                                                                                     |
| ---------------------------- | ----------------- | -------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `[array item]`               | array             | false    |              |                                                                                                                                                 |
| `» created_at`               | string(date-time) | true     |              |                                                                                                                                                 |
| `» default_org_member_roles` | array             | false    |              | Default org member roles are unioned into every member's effective roles at request time. Changes propagate to all members on the next request. |
| `» description`              | string            | false    |              |                                                                                                                                                 |
| `» display_name`             | string            | false    |              |                                                                                                                                                 |
| `» icon`                     | string            | false    |              |                                                                                                                                                 |
| `» id`                       | string(uuid)      | true     |              |                                                                                                                                                 |
| `» is_default`               | boolean           | true     |              |                                                                                                                                                 |
| `» name`                     | string            | false    |              |                                                                                                                                                 |
| `» updated_at`               | string(date-time) | true     |              |                                                                                                                                                 |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get organization by user and organization name [#get-organization-by-user-and-organization-name]

### Code samples [#code-samples-26]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/organizations/{organizationname} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/organizations/{organizationname}`

### Parameters [#parameters-19]

| Name               | In   | Type   | Required | Description          |
| ------------------ | ---- | ------ | -------- | -------------------- |
| `user`             | path | string | true     | User ID, name, or me |
| `organizationname` | path | string | true     | Organization name    |

### Example responses [#example-responses-22]

> 200 Response

```json
{
  "created_at": "2019-08-24T14:15:22Z",
  "default_org_member_roles": [
    "string"
  ],
  "description": "string",
  "display_name": "string",
  "icon": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "is_default": true,
  "name": "string",
  "updated_at": "2019-08-24T14:15:22Z"
}
```

### Responses [#responses-26]

| Status | Meaning                                                 | Description | Schema                                                                          |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.Organization](/beta-docs/reference/api/schemas/#codersdkorganization) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Update user password [#update-user-password]

### Code samples [#code-samples-27]

```sh
# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/password \
  -H 'Content-Type: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`PUT /api/v2/users/{user}/password`

> Body parameter

```json
{
  "old_password": "string",
  "password": "string"
}
```

### Parameters [#parameters-20]

| Name   | In   | Type                                                                                                      | Required | Description             |
| ------ | ---- | --------------------------------------------------------------------------------------------------------- | -------- | ----------------------- |
| `user` | path | string                                                                                                    | true     | User ID, name, or me    |
| `body` | body | [codersdk.UpdateUserPasswordRequest](/beta-docs/reference/api/schemas/#codersdkupdateuserpasswordrequest) | true     | Update password request |

### Responses [#responses-27]

| Status | Meaning                                                         | Description | Schema |
| ------ | --------------------------------------------------------------- | ----------- | ------ |
| 204    | [No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5) | No Content  |        |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get user preference settings [#get-user-preference-settings]

### Code samples [#code-samples-28]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/preferences \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/preferences`

### Parameters [#parameters-21]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Example responses [#example-responses-23]

> 200 Response

```json
{
  "agent_chat_send_shortcut": "enter",
  "code_diff_display_mode": "auto",
  "shell_tool_display_mode": "auto",
  "task_notification_alert_dismissed": true,
  "thinking_display_mode": "auto"
}
```

### Responses [#responses-28]

| Status | Meaning                                                 | Description | Schema                                                                                              |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.UserPreferenceSettings](/beta-docs/reference/api/schemas/#codersdkuserpreferencesettings) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Update user preference settings [#update-user-preference-settings]

### Code samples [#code-samples-29]

```sh
# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/preferences \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`PUT /api/v2/users/{user}/preferences`

> Body parameter

```json
{
  "agent_chat_send_shortcut": "enter",
  "code_diff_display_mode": "auto",
  "shell_tool_display_mode": "auto",
  "task_notification_alert_dismissed": true,
  "thinking_display_mode": "auto"
}
```

### Parameters [#parameters-22]

| Name   | In   | Type                                                                                                                          | Required | Description             |
| ------ | ---- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | ----------------------- |
| `user` | path | string                                                                                                                        | true     | User ID, name, or me    |
| `body` | body | [codersdk.UpdateUserPreferenceSettingsRequest](/beta-docs/reference/api/schemas/#codersdkupdateuserpreferencesettingsrequest) | true     | New preference settings |

### Example responses [#example-responses-24]

> 200 Response

```json
{
  "agent_chat_send_shortcut": "enter",
  "code_diff_display_mode": "auto",
  "shell_tool_display_mode": "auto",
  "task_notification_alert_dismissed": true,
  "thinking_display_mode": "auto"
}
```

### Responses [#responses-29]

| Status | Meaning                                                 | Description | Schema                                                                                              |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.UserPreferenceSettings](/beta-docs/reference/api/schemas/#codersdkuserpreferencesettings) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Update user profile [#update-user-profile]

### Code samples [#code-samples-30]

```sh
# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/profile \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`PUT /api/v2/users/{user}/profile`

> Body parameter

```json
{
  "avatar_url": "http://example.com",
  "name": "string",
  "username": "string"
}
```

### Parameters [#parameters-23]

| Name   | In   | Type                                                                                                    | Required | Description          |
| ------ | ---- | ------------------------------------------------------------------------------------------------------- | -------- | -------------------- |
| `user` | path | string                                                                                                  | true     | User ID, name, or me |
| `body` | body | [codersdk.UpdateUserProfileRequest](/beta-docs/reference/api/schemas/#codersdkupdateuserprofilerequest) | true     | Updated profile      |

### Example responses [#example-responses-25]

> 200 Response

```json
{
  "avatar_url": "http://example.com",
  "created_at": "2019-08-24T14:15:22Z",
  "email": "user@example.com",
  "has_ai_seat": true,
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "is_service_account": true,
  "last_seen_at": "2019-08-24T14:15:22Z",
  "login_type": "",
  "name": "string",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "roles": [
    {
      "display_name": "string",
      "name": "string",
      "organization_id": "string"
    }
  ],
  "status": "active",
  "theme_preference": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "username": "string"
}
```

### Responses [#responses-30]

| Status | Meaning                                                 | Description | Schema                                                          |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.User](/beta-docs/reference/api/schemas/#codersdkuser) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Get user roles [#get-user-roles]

### Code samples [#code-samples-31]

```sh
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/roles \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`GET /api/v2/users/{user}/roles`

### Parameters [#parameters-24]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Example responses [#example-responses-26]

> 200 Response

```json
{
  "avatar_url": "http://example.com",
  "created_at": "2019-08-24T14:15:22Z",
  "email": "user@example.com",
  "has_ai_seat": true,
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "is_service_account": true,
  "last_seen_at": "2019-08-24T14:15:22Z",
  "login_type": "",
  "name": "string",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "roles": [
    {
      "display_name": "string",
      "name": "string",
      "organization_id": "string"
    }
  ],
  "status": "active",
  "theme_preference": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "username": "string"
}
```

### Responses [#responses-31]

| Status | Meaning                                                 | Description | Schema                                                          |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.User](/beta-docs/reference/api/schemas/#codersdkuser) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Assign role to user [#assign-role-to-user]

### Code samples [#code-samples-32]

```sh
# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/roles \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`PUT /api/v2/users/{user}/roles`

> Body parameter

```json
{
  "roles": [
    "string"
  ]
}
```

### Parameters [#parameters-25]

| Name   | In   | Type                                                                          | Required | Description          |
| ------ | ---- | ----------------------------------------------------------------------------- | -------- | -------------------- |
| `user` | path | string                                                                        | true     | User ID, name, or me |
| `body` | body | [codersdk.UpdateRoles](/beta-docs/reference/api/schemas/#codersdkupdateroles) | true     | Update roles request |

### Example responses [#example-responses-27]

> 200 Response

```json
{
  "avatar_url": "http://example.com",
  "created_at": "2019-08-24T14:15:22Z",
  "email": "user@example.com",
  "has_ai_seat": true,
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "is_service_account": true,
  "last_seen_at": "2019-08-24T14:15:22Z",
  "login_type": "",
  "name": "string",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "roles": [
    {
      "display_name": "string",
      "name": "string",
      "organization_id": "string"
    }
  ],
  "status": "active",
  "theme_preference": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "username": "string"
}
```

### Responses [#responses-32]

| Status | Meaning                                                 | Description | Schema                                                          |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.User](/beta-docs/reference/api/schemas/#codersdkuser) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Activate user account [#activate-user-account]

### Code samples [#code-samples-33]

```sh
# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/status/activate \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`PUT /api/v2/users/{user}/status/activate`

### Parameters [#parameters-26]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Example responses [#example-responses-28]

> 200 Response

```json
{
  "avatar_url": "http://example.com",
  "created_at": "2019-08-24T14:15:22Z",
  "email": "user@example.com",
  "has_ai_seat": true,
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "is_service_account": true,
  "last_seen_at": "2019-08-24T14:15:22Z",
  "login_type": "",
  "name": "string",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "roles": [
    {
      "display_name": "string",
      "name": "string",
      "organization_id": "string"
    }
  ],
  "status": "active",
  "theme_preference": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "username": "string"
}
```

### Responses [#responses-33]

| Status | Meaning                                                 | Description | Schema                                                          |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.User](/beta-docs/reference/api/schemas/#codersdkuser) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).

## Suspend user account [#suspend-user-account]

### Code samples [#code-samples-34]

```sh
# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/status/suspend \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'
```

`PUT /api/v2/users/{user}/status/suspend`

### Parameters [#parameters-27]

| Name   | In   | Type   | Required | Description          |
| ------ | ---- | ------ | -------- | -------------------- |
| `user` | path | string | true     | User ID, name, or me |

### Example responses [#example-responses-29]

> 200 Response

```json
{
  "avatar_url": "http://example.com",
  "created_at": "2019-08-24T14:15:22Z",
  "email": "user@example.com",
  "has_ai_seat": true,
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "is_service_account": true,
  "last_seen_at": "2019-08-24T14:15:22Z",
  "login_type": "",
  "name": "string",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "roles": [
    {
      "display_name": "string",
      "name": "string",
      "organization_id": "string"
    }
  ],
  "status": "active",
  "theme_preference": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "username": "string"
}
```

### Responses [#responses-34]

| Status | Meaning                                                 | Description | Schema                                                          |
| ------ | ------------------------------------------------------- | ----------- | --------------------------------------------------------------- |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK          | [codersdk.User](/beta-docs/reference/api/schemas/#codersdkuser) |

To perform this operation, you must be authenticated. [Learn more](/beta-docs/reference/api/authentication/).
