# Users

Every person that uses the system has their own [user profile](/data-models.md#userprofile), which contains a collection of [devices](/data-models.md#device) that the user is allowed to log into. For each device, the user can be granted different rights.

## API methods

## Get users

<mark style="color:blue;">`GET`</mark> `http://{server-address}/users`

Returns all users that matches query parameters. Result is of type [`QueryResult<UserProfile>`](/data-models.md#queryresult).

#### Query Parameters

| Name        | Type      | Description                                                                                                              |
| ----------- | --------- | ------------------------------------------------------------------------------------------------------------------------ |
| isActive    | bool      | Supports NData syntax.                                                                                                   |
| isVirtual   | bool      | Supports NData syntax.                                                                                                   |
| $skip       | int       | Pagination property. Describing number of records to skip from beginning of result collection.                           |
| $take       | int       | Pagination property. Maximum count of items to be returned.                                                              |
| $sort       | string\[] | <p>Comma separated list of property names. Please see NData syntax.<br></p>                                              |
| $count      | bool      | If set to `true`, response will not contain `items` collection. Use to get resource count, not the resources themselves. |
| featureName | string    | Supports NData syntax.                                                                                                   |
| userName    | string    | Supports NData syntax.                                                                                                   |
| name        | string    | Supports NData syntax.                                                                                                   |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successful response" %}

```javascript
{
    "items":
    [
        {
            "id": "62ffb6c57028d4f9c14f0fc1",
            "isActive": true,
            "isVirtual": false,
            "userName": "999",
            "featureName": null,
            "name": "Majiteľ",
            "devices":
            [
                {
                    "isActive": true,
                    "envName": "CashRegister",
                    "name": "P01",
                    "roles":
                    [
                        "admin"
                    ],
                    "description": "Pokladňa 01",
                    "preferences":
                    {}
                },
                {
                    "isActive": true,
                    "envName": "BackOffice",
                    "name": "BackOffice",
                    "roles":
                    [
                        "admin"
                    ],
                    "description": "BackOffice",
                    "preferences":
                    {}
                },
                {
                    "isActive": true,
                    "envName": "Tool",
                    "name": "mPOS Link",
                    "roles":
                    [
                        "admin"
                    ],
                    "description": "mPOS Link",
                    "preferences":
                    {}
                },
                {
                    "isActive": true,
                    "envName": "PDA",
                    "name": "PDA1",
                    "roles":
                    [
                        "sale",
                        "statsCurrent",
                        "statsTicketsCurrent",
                        "openDrawer",
                        "negativeSale",
                        "overviewSalesReport",
                        "ticketSplit",
                        "storno",
                        "stats",
                        "statsPlus",
                        "cashTransfer",
                        "allTickets",
                        "ticketSetDiscount",
                        "admin"
                    ],
                    "description": "",
                    "preferences":
                    {}
                },
                {
                    "isActive": true,
                    "envName": "PDA",
                    "name": "PDA2",
                    "roles":
                    [
                        "sale",
                        "statsCurrent",
                        "statsTicketsCurrent",
                        "openDrawer",
                        "negativeSale",
                        "overviewSalesReport",
                        "ticketSplit",
                        "storno",
                        "stats",
                        "statsPlus",
                        "cashTransfer",
                        "allTickets",
                        "ticketSetDiscount",
                        "admin"
                    ],
                    "description": "",
                    "preferences":
                    {}
                },
                {
                    "isActive": true,
                    "envName": "CashRegister",
                    "name": "P02",
                    "roles":
                    [
                        "sale",
                        "statsCurrent",
                        "statsTicketsCurrent",
                        "openDrawer",
                        "negativeSale",
                        "overviewSalesReport",
                        "ticketSplit",
                        "storno",
                        "stats",
                        "statsPlus",
                        "cashTransfer",
                        "allTickets",
                        "ticketSetDiscount",
                        "admin"
                    ],
                    "description": "",
                    "preferences":
                    {}
                }
            ],
            "hasPassword": false,
            "_v": 4
        },
        {
            "id": "63260d6e046c7b515ea93beb",
            "isActive": true,
            "isVirtual": true,
            "userName": "Qerko",
            "featureName": "Portos.Features.Qerko",
            "name": "Qerko",
            "devices":
            [
                {
                    "isActive": true,
                    "envName": "System",
                    "name": "SYSTEM",
                    "roles":
                    [
                        "admin"
                    ],
                    "description": null,
                    "preferences":
                    {}
                }
            ],
            "hasPassword": false,
            "_v": 1
        }
    ],
    "count": 2,
    "totalCount": 2
}
```

{% endtab %}
{% endtabs %}

## Get user

<mark style="color:blue;">`GET`</mark> `http://{server-address}/users/{id}`

Result is of type [UserProfile](/data-models.md#userprofile).

#### Path Parameters

| Name                                 | Type   | Description             |
| ------------------------------------ | ------ | ----------------------- |
| id<mark style="color:red;">\*</mark> | string | Unique user identifier. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Resource found." %}

```javascript
{
    "id": "62ffb6c57028d4f9c14f0fc1",
    "isActive": true,
    "isVirtual": false,
    "userName": "999",
    "featureName": null,
    "name": "Majiteľ",
    "devices":
    [
        {
            "isActive": true,
            "envName": "CashRegister",
            "name": "P01",
            "roles":
            [
                "admin"
            ],
            "description": "Pokladňa 01",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "BackOffice",
            "name": "BackOffice",
            "roles":
            [
                "admin"
            ],
            "description": "BackOffice",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "Tool",
            "name": "mPOS Link",
            "roles":
            [
                "admin"
            ],
            "description": "mPOS Link",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "PDA",
            "name": "PDA1",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "PDA",
            "name": "PDA2",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "CashRegister",
            "name": "P02",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        }
    ],
    "hasPassword": false,
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found User is not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}

## Create user

<mark style="color:green;">`POST`</mark> `http://{server-address}/users`

Creates new user. Method accepts [`UserCreateUpdateContext`](/data-models.md#usercreateupdatecontext) in the request body. Result is of type [UserProfile](/data-models.md#userprofile).

**Required rights**

Authorized user must have `UserCreate` [right ](/user-rights.md)assigned.

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type                    | Description                    |
| ---------------------------------------- | ----------------------- | ------------------------------ |
| (body)<mark style="color:red;">\*</mark> | UserCreateUpdateContext | Context create or update user. |

{% tabs %}
{% tab title="201: Created Successfuly created." %}

```javascript
{
    "id": "62ffb6c57028d4f9c14f0fc1",
    "isActive": true,
    "isVirtual": false,
    "userName": "999",
    "featureName": null,
    "name": "Majiteľ",
    "devices":
    [
        {
            "isActive": true,
            "envName": "CashRegister",
            "name": "P01",
            "roles":
            [
                "admin"
            ],
            "description": "Pokladňa 01",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "BackOffice",
            "name": "BackOffice",
            "roles":
            [
                "admin"
            ],
            "description": "BackOffice",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "Tool",
            "name": "mPOS Link",
            "roles":
            [
                "admin"
            ],
            "description": "mPOS Link",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "PDA",
            "name": "PDA1",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "PDA",
            "name": "PDA2",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "CashRegister",
            "name": "P02",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        }
    ],
    "hasPassword": false,
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Create or update user

<mark style="color:orange;">`PUT`</mark> `http://{server-address}/users/{id}`

Updates existing or creates new user. Method accepts [`UserCreateUpdateContext`](/data-models.md#usercreateupdatecontext) in the request body. Result is of type [UserProfile](/data-models.md#userprofile).

**Required rights**

Authorized user must have assigned `UserCreate` or `UserUpdate` [right](/user-rights.md).

#### Path Parameters

| Name                                 | Type   | Description             |
| ------------------------------------ | ------ | ----------------------- |
| id<mark style="color:red;">\*</mark> | string | Unique user identifier. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

#### Request Body

| Name                                     | Type                    | Description                    |
| ---------------------------------------- | ----------------------- | ------------------------------ |
| (body)<mark style="color:red;">\*</mark> | UserCreateUpdateContext | Context create or update user. |

{% tabs %}
{% tab title="200: OK Successfuly created or updated." %}

```javascript
{
    "id": "62ffb6c57028d4f9c14f0fc1",
    "isActive": true,
    "isVirtual": false,
    "userName": "999",
    "featureName": null,
    "name": "Majiteľ",
    "devices":
    [
        {
            "isActive": true,
            "envName": "CashRegister",
            "name": "P01",
            "roles":
            [
                "admin"
            ],
            "description": "Pokladňa 01",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "BackOffice",
            "name": "BackOffice",
            "roles":
            [
                "admin"
            ],
            "description": "BackOffice",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "Tool",
            "name": "mPOS Link",
            "roles":
            [
                "admin"
            ],
            "description": "mPOS Link",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "PDA",
            "name": "PDA1",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "PDA",
            "name": "PDA2",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "CashRegister",
            "name": "P02",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        }
    ],
    "hasPassword": false,
    "_v": 1
}
```

{% endtab %}
{% endtabs %}

## Delete user

<mark style="color:red;">`DELETE`</mark> `http://{server-address}/users/{id}`

**Required rights**

Authorized user must have `UserDelete` [right ](/user-rights.md)assigned.

#### Path Parameters

| Name                                 | Type   | Description             |
| ------------------------------------ | ------ | ----------------------- |
| id<mark style="color:red;">\*</mark> | string | Unique user identifier. |

#### Headers

| Name                                            | Type   | Description                                    |
| ----------------------------------------------- | ------ | ---------------------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Authorization header with authorization token. |

{% tabs %}
{% tab title="200: OK Successfuly deleted." %}

```javascript
{
    "id": "62ffb6c57028d4f9c14f0fc1",
    "isActive": true,
    "isVirtual": false,
    "userName": "999",
    "featureName": null,
    "name": "Majiteľ",
    "devices":
    [
        {
            "isActive": true,
            "envName": "CashRegister",
            "name": "P01",
            "roles":
            [
                "admin"
            ],
            "description": "Pokladňa 01",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "BackOffice",
            "name": "BackOffice",
            "roles":
            [
                "admin"
            ],
            "description": "BackOffice",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "Tool",
            "name": "mPOS Link",
            "roles":
            [
                "admin"
            ],
            "description": "mPOS Link",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "PDA",
            "name": "PDA1",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "PDA",
            "name": "PDA2",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        },
        {
            "isActive": true,
            "envName": "CashRegister",
            "name": "P02",
            "roles":
            [
                "sale",
                "statsCurrent",
                "statsTicketsCurrent",
                "openDrawer",
                "negativeSale",
                "overviewSalesReport",
                "ticketSplit",
                "storno",
                "stats",
                "statsPlus",
                "cashTransfer",
                "allTickets",
                "ticketSetDiscount",
                "admin"
            ],
            "description": "",
            "preferences":
            {}
        }
    ],
    "hasPassword": false,
    "_v": 1
}
```

{% endtab %}

{% tab title="404: Not Found Given resource was not found." %}

```javascript
{
    "title": "Zdroj nebol nájdený",
    "status": 404
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.portos.sk/api-reference/users.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
