> For the complete documentation index, see [llms.txt](https://docs.microting.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.microting.com/integration-with-microting-backend/device-users.md).

# Device users

## Get list of devices users

<mark style="color:blue;">`GET`</mark> `http://localhost:5000/api/device-users/index`

This endpoint allows you to get a list of all current device users.\
In the example below we assume we have two device users; a 1 and a 2:

#### Headers

| Name           | Type   | Description          |
| -------------- | ------ | -------------------- |
| Authentication | string | Bearer access\_token |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```javascript
{
	"model": [{
		"siteId": 187924,
		"siteName": "a 1",
		"firstName": "a",
		"lastName": "1",
		"customerNo": 342345,
		"otpCode": 950286,
		"unitId": 185092,
		"workerUid": 161047
	}, {
		"siteId": 165341,
		"siteName": "a 2",
		"firstName": "a",
		"lastName": "2",
		"customerNo": 342345,
		"otpCode": 193498,
		"unitId": 129455,
		"workerUid": 923185
	}],
	"success": true,
	"message": "Success"
}
```

{% endtab %}
{% endtabs %}

## Create a new device user

<mark style="color:orange;">`PUT`</mark> `http://locahost:5000/api/device-users/create`

#### Headers

| Name           | Type   | Description          |
| -------------- | ------ | -------------------- |
| Authentication | string | Bearer access\_token |

#### Request Body

| Name          | Type   | Description                                |
| ------------- | ------ | ------------------------------------------ |
| userFirstName | string | First name of the user to create, eg: John |
| userLastName  | string | Last name of the user to create, eg: Doe   |

{% tabs %}
{% tab title="200 " %}

```javascript
{
	"success": true,
	"message": "Device user \"John Doe\" was created successfully"
}
```

{% endtab %}
{% endtabs %}

## Update a device user

<mark style="color:green;">`POST`</mark> `http://locahost:5000/api/device-users/update`

#### Headers

| Name           | Type   | Description          |
| -------------- | ------ | -------------------- |
| Authentication | string | Bearer access\_token |

#### Request Body

| Name          | Type   | Description                                      |
| ------------- | ------ | ------------------------------------------------ |
| id            | number | Id of the user to update (siteId from the index) |
| userFirstName | string | First name of the user to update, eg: John       |
| userLastName  | string | Last name of the user to update, eg: Doe         |

{% tabs %}
{% tab title="200 " %}

```javascript
{
	"success": true,
	"message": "Device user updated successfully"
}
```

{% endtab %}
{% endtabs %}

## Delete a device user

<mark style="color:red;">`DELETE`</mark> `http://locahost:5000/api/device-users/delete`

id is the siteId from the index response

#### Path Parameters

| Name | Type   | Description                         |
| ---- | ------ | ----------------------------------- |
| id   | string | siteId of the device user to delete |

#### Headers

| Name           | Type   | Description          |
| -------------- | ------ | -------------------- |
| Authentication | string | Bearer access\_token |

{% tabs %}
{% tab title="200 " %}

```javascript
{
	"success": true,
	"message": "Device user \"John Doe\" deleted successfully"
}
```

{% endtab %}
{% endtabs %}
