# Create new record

`POST /api/user`

Authentication (security requirement alternatives):

```json
[
  {
    "bearer": []
  },
  {
    "bearer": []
  }
]
```

- bearer: http (bearer), header JWT. Enter JWT token

Request body: application/json (required)

Type: object

Schema: [CreateUserDTO](https://sourcey-gauzy.pages.dev/api-reference/models/createuserdto/index.md)

- `email` (required)
  Type: string

- `roleId` (optional)
  Type: string

- `role` (optional)
  Type: object
  
  Role reference: an object with the role `id` (UUID).

- `firstName` (optional)
  Type: string

- `lastName` (optional)
  Type: string

- `imageUrl` (optional)
  Type: string

- `preferredLanguage` (optional)
  Type: string
  
  enum: ["en","bg","he","ru","fr","es","zh","de","pt","it","nl","pl","ar"]

Responses:

- 201: The record has been successfully created.

- 400: Invalid input, The response body may contain clues as to what went wrong

- 401: Unauthorized

- 403: Forbidden

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/user' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "email": "string",
  "roleId": "string",
  "role": {},
  "firstName": "string",
  "lastName": "string",
  "imageUrl": "string",
  "preferredLanguage": "en"
}'
```

### JavaScript

```javascript
const body = `{
  "email": "string",
  "roleId": "string",
  "role": {},
  "firstName": "string",
  "lastName": "string",
  "imageUrl": "string",
  "preferredLanguage": "en"
}`;

const response = await fetch('http://localhost:3000/api/user', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "email": "string",
  "roleId": "string",
  "role": {},
  "firstName": "string",
  "lastName": "string",
  "imageUrl": "string",
  "preferredLanguage": "en"
}'''

response = requests.post(
    'http://localhost:3000/api/user',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
