# createRole

## Overview

Creates a new role with a unique name and optional description. Automatically assigns the `audit:logAuditEvent` and `user-management:updateOwnProfile` permissions so that all operations performed under this role are audited and users can update their own profile. The role can then have additional permissions assigned to it.

## Modules Commands Used

- `user-management.createRole` — Creates a new role record
- `user-management.assignPermissionToRole` — Auto-assigns the `audit:logAuditEvent` and `user-management:updateOwnProfile` permissions to the new role

## Exception Handling

| Error Code             | Source               | Description                              |
| ---------------------- | -------------------- | ---------------------------------------- |
| DUPLICATE_ROLE_NAME    | createRole           | A role with the same name already exists |
| MISSING_REQUIRED_FIELD | createRole           | The role name was not provided           |
