Assign role to user
PUT
CoderSessionTokenheader
Coder-Session-Token<token>user*stringUser ID, name, or me
Update roles request
application/json- body
roles?array<string>OK
application/json- response
avatar_url?stringFormat
uricreated_at*stringFormat
date-timeemail*stringFormat
emailhas_ai_seat?booleanHasAISeat intentionally omits omitempty so the API always includes the field, even when false.
id*stringFormat
uuidis_service_account?booleanlast_seen_at?stringFormat
date-timelogin_type?codersdk.LoginTypeValue in
"""password""github""oidc""token""none"name?stringorganization_ids?array<>roles?array<>status?stringValue in
"active""suspended"theme_preference?stringDeprecated: this value should be retrieved from
codersdk.UserPreferenceSettings instead.
updated_at?stringFormat
date-timeusername*stringThe samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X PUT \ "$CODER_URL/api/v2/users/{user}/roles" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "roles": [ "string" ]}'Example Response200
{ "avatar_url": "http://example.com", "created_at": "2019-08-24T14:15:22Z", "email": "[email protected]", "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": [ "7d4232d7-54a0-4c93-9c1e-a8fd2dfcdabe" ], "roles": [ { "display_name": "string", "name": "string", "organization_id": "string" } ], "status": "active", "theme_preference": "string", "updated_at": "2019-08-24T14:15:22Z", "username": "string"}