---
title: "Create User"
method: POST
path: "/api/registration/create_user"
tags: ["Sign Up"]
---

# Create User

`POST /api/registration/create_user`

**Function**: `create_user`
**Type**: API Endpoint (POST)

**Purpose**:  
This function creates a new user in the database. It generates a unique user code based on the provided LSCode and other parameters, checks if the user email already exists, encrypts the password, and adds the new user to the database.

**URL**:  
`POST /api/registration/create_user`

**Request Body**:
- **application_code** (string, required):  
  The application code for the user.
- **lscode** (string, required):  
  The LSCode for the user.
- **email** (string, required):  
  The email address of the user.
- **mobile** (string, required):  
  The mobile number of the user.
- **password** (string, required):  
  The password for the user.
- **is_administrator** (boolean, optional):  
  Whether the user is an administrator or not (default is False).
- **user_group_code** (string, required):  
  The user group code for the user.
- **default_firm** (string, required):  
  The default firm for the user.
- **is_license** (boolean, optional):  
  Whether the user is a licensed user or not (default is True).
- **is_support_admin** (boolean, optional):  
  Whether the user is a support administrator or not (default is False).
- **created_by** (string, required):  
  The user who created the user.

**Response**:
- **message** (string):  
  A success message if the user is created successfully.
- **user** (object):  
  The newly created user object.

**Error Handling**:
- If a user with the provided email already exists, the function raises an `HTTPException` with a `400` status code and an error message.
- If any other error occurs during database operations, the function returns a `500` error with the error message.

## Request body

- UserCreate
  - `application_code` string, required
  - `lscode` string, required
  - `send_notification` boolean
  - `first_name` string, required
  - `last_name` string, required
  - `email` string, required
  - `mobile` string, required
  - `password` string, required
  - `is_administrator` boolean
  - `is_license` boolean
  - `two_factor_auth` boolean
  - `is_support_admin` boolean
  - `user_group_code` string, required
  - `created_by` string, required
  - `default_firm` string
  - `is_group` integer
  - `user_active` boolean
  - `access_sync_app` boolean

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/leapsurgebi/apis/leapsurgeapi.md) · [All operations](https://skmtc.dev/leapsurgebi/apis/leapsurgeapi/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/leapsurgebi/leapsurgeapi/revisions/5a6b1464bfeb/schema)
