Skip to content
Skip to Content
Coder Docs

Create new user

POST
/api/v2/users

Authorization

CoderSessionToken
headerCoder-Session-Token<token>

Request Body

Create user request

application/json
  1. body
email?string
Formatemail
login_type?string

UserLoginType defaults to LoginTypePassword.

Value in"""password""github""oidc""token""none"
name?string
organization_ids?array<>

OrganizationIDs is a list of organization IDs that the user should be a member of.

password?string
roles?array<string>

Roles is an optional list of site-level roles to assign at creation.

service_account?boolean

Service accounts are admin-managed accounts that cannot login.

user_status?string

UserStatus defaults to UserStatusDormant. Service accounts default to UserStatusActive and can't be dormant.

Value in"active""dormant""suspended"
username*string

Response Body

Created

application/json
  1. response
avatar_url?string
Formaturi
created_at*string
Formatdate-time
email*string
Formatemail
has_ai_seat?boolean

HasAISeat intentionally omits omitempty so the API always includes the field, even when false.

id*string
Formatuuid
is_service_account?boolean
last_seen_at?string
Formatdate-time
login_type?codersdk.LoginType
Value in"""password""github""oidc""token""none"
name?string
organization_ids?array<>
roles?array<>
status?string
Value in"active""suspended"
theme_preference?string

Deprecated: this value should be retrieved from codersdk.UserPreferenceSettings instead.

updated_at?string
Formatdate-time
username*string

The 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"}'
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"}