Create new user
POST
CoderSessionTokenheader
Coder-Session-Token<token>Create user request
application/json- body
email?stringFormat
emaillogin_type?stringUserLoginType defaults to LoginTypePassword.
Value in
"""password""github""oidc""token""none"name?stringorganization_ids?array<>OrganizationIDs is a list of organization IDs that the user should be a member of.
password?stringroles?array<string>Roles is an optional list of site-level roles to assign at creation.
service_account?booleanService accounts are admin-managed accounts that cannot login.
user_status?stringUserStatus defaults to UserStatusDormant. Service accounts default to UserStatusActive and can't be dormant.
Value in
"active""dormant""suspended"username*stringCreated
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 POST \ "$CODER_URL/api/v2/users" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "username": "string"}'const { CODER_URL, CODER_SESSION_TOKEN } = process.env;const url = `${CODER_URL}/api/v2/users`;const response = await fetch(url, { method: "POST", headers: { "Coder-Session-Token": CODER_SESSION_TOKEN, "Content-Type": "application/json", }, body: JSON.stringify({ username: "string", }),});console.log(response.status, await response.text());import osimport requestsurl = os.environ["CODER_URL"] + "/api/v2/users"token = os.environ["CODER_SESSION_TOKEN"]response = requests.post( url, headers={ "Coder-Session-Token": token, }, json={ "username": "string", },)print(response.status_code, response.text)package mainimport ( "fmt" "io" "net/http" "os" "strings")func main() { body := strings.NewReader(`{ "username": "string"}`) url := os.Getenv("CODER_URL") + "/api/v2/users" token := os.Getenv("CODER_SESSION_TOKEN") req, err := http.NewRequest(http.MethodPost, url, body) if err != nil { panic(err) } req.Header.Set("Coder-Session-Token", token) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, err := io.ReadAll(resp.Body) if err != nil { panic(err) } fmt.Println(resp.Status, string(out))}Example Response201
{ "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"}