> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Create User

> Create a new user in your workspace. This endpoint is typically used by admins to create user accounts in the workspace.
<br>Permissions required:
- `create-user`: Permission to create users
- `edit-other-user-active-status`: Permission to enable or disable other accounts


### Changelog
| Version      | Description | 
| ---------------- | ------------|
|0.48.0            | `role` property is now `roles` which is an array of strings for the roles to create the user with.       |
|0.45.0            | Users created via this now join the default channels.       |
|0.40.0            | Added       |

## OpenAPI

````json POST /api/v1/users.create
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "User Management"
  },
  "servers": [
    {
      "url": "https://apiexplorer.support.rocket.chat"
    }
  ],
  "tags": [
    {
      "name": "LDAP"
    },
    {
      "name": "Permissions"
    },
    {
      "name": "Roles"
    },
    {
      "name": "Users"
    }
  ],
  "paths": {
    "/api/v1/users.create": {
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Create User",
        "description": "Create a new user in your workspace. This endpoint is typically used by admins to create user accounts in the workspace.\n<br>Permissions required:\n- `create-user`: Permission to create users\n- `edit-other-user-active-status`: Permission to enable or disable other accounts\n\n\n### Changelog\n| Version      | Description | \n| ---------------- | ------------|\n|0.48.0            | `role` property is now `roles` which is an array of strings for the roles to create the user with.       |\n|0.45.0            | Users created via this now join the default channels.       |\n|0.40.0            | Added       |",
        "operationId": "post-api-v1-users.create",
        "parameters": [
          {
            "$ref": "#/components/parameters/UserId"
          },
          {
            "$ref": "#/components/parameters/Auth-Token"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "email",
                  "password",
                  "username"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "The display name of the user.",
                    "example": "Test User"
                  },
                  "email": {
                    "type": "string",
                    "description": "The email address for the user.",
                    "example": "email@user.tld1"
                  },
                  "password": {
                    "type": "string",
                    "description": "The password for the user.",
                    "example": "anypassyouwant"
                  },
                  "username": {
                    "type": "string",
                    "description": "The username for the user.",
                    "example": "uniqueusername1"
                  },
                  "active": {
                    "type": "boolean",
                    "description": "Set the users' active status.  If the user is deactivated, they can not login. By default, the user is active.",
                    "example": "true",
                    "default": "true"
                  },
                  "nickname": {
                    "type": "string",
                    "description": "The nickname for the user. ",
                    "example": "testusername"
                  },
                  "bio": {
                    "type": "string",
                    "description": "The bio for the user.",
                    "example": "All about the user"
                  },
                  "joinDefaultChannels": {
                    "type": "boolean",
                    "description": "Select whether users should automatically join default channels once they are created. By default, it is set to `true`.",
                    "example": "true",
                    "default": "true"
                  },
                  "statusText": {
                    "type": "string",
                    "description": "The status text of the user.",
                    "example": "On a vacation"
                  },
                  "roles": {
                    "type": "array",
                    "description": "The roles to be assigned to this user. If it is not specified, the `user` role is assigned by default.\n**Note:**\n* For default roles, the role name and ID are the same. For custom roles, the name and ID are different. \n* If you are setting a custom role for a user, make sure to enter the custom role ID, and not the role name.\nRefer to [Roles](https://docs.rocket.chat/use-rocket.chat/workspace-administration/permissions#roles) for more information.",
                    "items": {
                      "type": "string",
                      "example": "bot"
                    }
                  },
                  "requirePasswordChange": {
                    "type": "boolean",
                    "description": "Should the user be required to change their password when they login? It is set to `false` by default",
                    "example": "false",
                    "default": "false"
                  },
                  "setRandomPassword": {
                    "type": "boolean",
                    "description": "Should the user be assigned a random password once they are created? It is set to `false` by defualt.",
                    "example": "false",
                    "default": "false"
                  },
                  "sendWelcomeEmail": {
                    "type": "boolean",
                    "description": "Should the user get a welcome email? It is set to `true` by default.",
                    "example": "false",
                    "default": "false"
                  },
                  "verified": {
                    "type": "boolean",
                    "description": "Should the user's email address be verified when created? It is set to `false` by default.",
                    "example": "false",
                    "default": "false"
                  },
                  "customFields": {
                    "type": "object",
                    "example": {
                      "clearance": "High",
                      "team": "Queen"
                    },
                    "description": "A valid JSON object of key-value pairs consisting of additional fields to be\nadded during user registration. By default, the value is `undefined`.\nTo save custom fields, you must first define them in the [workspace admin settings](https://docs.rocket.chat/use-rocket.chat/workspace-administration/settings/accounts/custom-fields).\nFor information on how to view the custom fields, see the [Get Users List](https://developer.rocket.chat/reference/api/rest-api/endpoints/user-management/users-endpoints/get-users-list) endpoint."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "type": "object",
                      "properties": {
                        "_id": {
                          "type": "string"
                        },
                        "createdAt": {
                          "type": "string"
                        },
                        "username": {
                          "type": "string"
                        },
                        "emails": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "address": {
                                "type": "string"
                              },
                              "verified": {
                                "type": "boolean"
                              }
                            }
                          }
                        },
                        "type": {
                          "type": "string"
                        },
                        "roles": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "status": {
                          "type": "string"
                        },
                        "active": {
                          "type": "boolean"
                        },
                        "_updatedAt": {
                          "type": "string"
                        },
                        "bio": {
                          "type": "string"
                        },
                        "name": {
                          "type": "string"
                        },
                        "nickname": {
                          "type": "string"
                        },
                        "requirePasswordChange": {
                          "type": "boolean"
                        },
                        "settings": {
                          "type": "object"
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Success Example": {
                    "value": {
                      "user": {
                        "_id": "BsNr28znDkG8aeo7W",
                        "createdAt": "2016-09-13T14:57:56.037Z",
                        "services": {
                          "password": {
                            "bcrypt": "$2a$i7BFS55uFYRf5TE4ErSUH8HymMNAbpMAvsOcl2C"
                          }
                        },
                        "username": "uniqueusername",
                        "emails": [
                          {
                            "address": "email@user.tld",
                            "verified": "false"
                          }
                        ],
                        "type": "user",
                        "status": "offline",
                        "active": "true",
                        "roles": [
                          "user"
                        ],
                        "_updatedAt": "2016-09-13T14:57:56.175Z",
                        "name": "name",
                        "settings": {}
                      },
                      "success": "true"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "string"
                    },
                    "errorType": {
                      "type": "string"
                    },
                    "details": {
                      "type": "object",
                      "properties": {
                        "method": {
                          "type": "string"
                        },
                        "action": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "Permission Error": {
                    "value": {
                      "success": "false",
                      "error": "Adding user is not allowed [error-action-not-allowed]",
                      "errorType": "error-action-not-allowed",
                      "details": {
                        "method": "insertOrUpdateUser",
                        "action": "Adding_user"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "UserId": {
        "name": "X-User-Id",
        "in": "header",
        "description": "The authenticated user ID.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "rbAXPnMktTFbNpwtJ"
      },
      "Auth-Token": {
        "name": "X-Auth-Token",
        "in": "header",
        "description": "The authenticated user token.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f"
      }
    },
    "responses": {
      "authorizationError": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            },
            "examples": {
              "Authorization Error": {
                "value": {
                  "status": "error",
                  "message": "You must be logged in to do this."
                }
              }
            }
          }
        }
      }
    }
  }
}
````

