# User Management



# Create New User

This API enables your application to **Create new Business Admin or Business user under current user's organization**. 


### Endpoint

```
GET https://demo-api.frontpayment.no/api/v1/connect/users/create/{{userRoleSlug}}
```
userRoleSlug can be either user or business-admin

#### Authorization

Include a **Bearer Token** in the `Authorization` header. You can obtain this token from **Front Payment**.

**Example:**  
```
Authorization: Bearer YOUR_FRONTPAYMENT_BEARER_TOKEN
```

### Request Payload

Send the following parameters as a JSON object in the request body:

```json
{
    "name": "Swedish BE User",
    "email": "swebeuser@yopmail.com",
    "countryCode": "+47",
    "msisdn": "46567468",
    "designation": null,
    "password": "qwerty12",
    "preferredLanguage": "en"
}
```

### Validation Rules

Make sure your request meets the following requirements:

<table style="width: 100%">
  <thead>
    <tr>
      <th style="width: 260px">Field</th>
      <th style="width: 80px">Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code>name</code></td>
      <td><code>string</code></td>
      <td><strong>Required</strong> Name of the user</td>
    </tr>
    <tr>
      <td><code>email</code></td>
      <td><code>string, email</code></td>
      <td><strong>Required</strong> Email of the user.</td>
    </tr>
    <tr>
      <td><code>countryCode</code></td>
      <td><code>string</code></td>
      <td><strong>Required</strong> Country code of the user.</td>
    </tr>
    <tr>
      <td><code>msisdn</code></td>
      <td><code>numeric</code></td>
      <td><strong>Required</strong> msisdn of the user</td>
    </tr>
    <tr>
      <td><code>designation</code></td>
      <td><code>string</code></td>
      <td><strong>Optional</strong> Designation of the user.</td>
    </tr>
    <tr>
      <td><code>password</code></td>
      <td><code>string</code></td>
      <td><strong>Required</strong> Password for user login</td>
    </tr>
    <tr>
      <td><code>preferredLanguage</code></td>
      <td><code>string</code></td>
      <td><strong>Required</strong> Code of user's preferred language and one of 'en', 'no', 'de', 'da', 'sv'.</td>
    </tr>
  </tbody>
</table>

### Response

A successful request will return a `200 OK` status with the following JSON payload:

```json
{
    "status_code": 201,
    "status_message": "OK",
    "message": "userCreatedSuccessfully",
    "is_data": false,
    "data": null
}
```


API returns a `400` error, it means user already exists with given email.

```json
{
    "status_code": 400,
    "status_message": "Conflict of Business Logic ",
    "message": "userAlreadyExistsWithSameEmail",
    "is_data": false,
    "data": null
}
```


API returns a `510` error, it means something failed on the server side

```json
{
    "status_code": 510,
    "status_message": "Execution Exception Occurred",
    "message": "Something Went Wrong",
    "is_error": true,
    "errors": "Array"
}
```