# Group

Contains group object structure and API calls to interact with them. Tracker group used to organize trackers in user interface. Currently, its function is purely visual.

## Group object structure:

```json
{
  "id": 167,
  "title": "Main office",
  "color": "FF6DDC"
}
```

* `id` - int. Group ID. Used to reference group in objects and API calls. Read-only, assigned automatically by the server.
* `title` - string. User-specified group title, 1 to 60 printable characters, e.g. "Employees".
* `color` - string. Group color in web format (without #), e.g. "FF6DDC". Determines the color of tracker markers on the map.

## API actions

API base path: `/tracker/group`.

### assign

Assigns multiple trackers to the specified group.

**required sub-user rights:** `admin` (available only to master users).

#### Parameters

| name     | description                                                                                                | type      | format             |
| -------- | ---------------------------------------------------------------------------------------------------------- | --------- | ------------------ |
| id       | Group ID, or 0 if trackers should be removed from any group.                                               | int       | 167                |
| trackers | Array of IDs of the tracker (aka "object\_id"). Tracker must belong to authorized user and not be blocked. | int array | `[999199, 999919]` |

#### Example

cURL

{% code overflow="wrap" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/tracker/group/assign' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "a6aa75587e5c59c32d347da438505fc3", "trackers": [999199, 991999], "id": 167}'
```

{% endcode %}

#### Response

```json
{
  "success": true
}
```

#### Errors

* 201 - Not found in the database – if no group found with the specified ID (or group belongs to another user).
* 217 - List contains nonexistent entities – if one or more of tracker IDs belong to nonexistent tracker\
  (or to a tracker belonging to different user).

### create

Creates a new empty group.

**required sub-user rights:** `admin` (available only to master users).

#### Parameters

| name  | description                                              | type   | format      |
| ----- | -------------------------------------------------------- | ------ | ----------- |
| title | Ser-specified group title, 1 to 60 printable characters. | string | "Employees" |
| color | Group color.                                             | string | "FF6DDC"    |

#### Examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/tracker/group/create' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "a6aa75587e5c59c32d347da438505fc3", "title": "Employees", "color": "FF6DDC"}'
```

{% endcode %}
{% endtab %}

{% tab title="HTTP GET" %}
{% code overflow="wrap" %}

```http
https://api.eu.navixy.com/v2/tracker/group/create?hash=a6aa75587e5c59c32d347da438505fc3&title=Employees&color=FF6DDC
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response

```json
{
  "success": true,
  "id": 222
}
```

* `id` - int. An ID of created group, e.g. 222.

#### Errors

[General](https://www.navixy.com/docs/navixy-api/user-api/errors#error-codes) types only.

### delete

Deletes group with the specified ID. The group must belong to authorized user. All trackers from this group will be\
assigned to default group (0).

**required sub-user rights:** `admin` (available only to master users).

#### Parameters

| name | description            | type | format |
| ---- | ---------------------- | ---- | ------ |
| id   | ID of group to delete. | int  | 167    |

#### Examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/tracker/group/delete' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "a6aa75587e5c59c32d347da438505fc3", "id": 167}'
```

{% endcode %}
{% endtab %}

{% tab title="HTTP GET" %}
{% code overflow="wrap" %}

```http
https://api.eu.navixy.com/v2/tracker/group/delete?hash=a6aa75587e5c59c32d347da438505fc3&id=167
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response

```json
{
  "success": true
}
```

#### Errors

* 201 - Not found in the database – if no group found with the specified ID (or group belongs to another user).

### list

Gets all user tracker groups. There is always "default" unnamed group with ID = 0. It cannot be modified, deleted,\
and is not returned by this API call.

#### Examples

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

```sh
curl -X POST 'https://api.eu.navixy.com/v2/tracker/group/list' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "a6aa75587e5c59c32d347da438505fc3"}'
```

{% endtab %}

{% tab title="HTTP GET" %}
{% code overflow="wrap" %}

```http
https://api.eu.navixy.com/v2/tracker/group/list?hash=a6aa75587e5c59c32d347da438505fc3
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response

```json
{
  "success": true,
  "list": [
    {
      "title": "test",
      "color": "FF6DDC",
      "id": 129301
    }
  ]
}
```

#### Errors

[General](https://www.navixy.com/docs/navixy-api/user-api/errors#error-codes) types only.

### update

Updates specified tracker group. Group must belong to the authorized user.

**required sub-user rights**: `admin` (available only to master users).

#### Parameters

| name  | description                                              | type   | format      |
| ----- | -------------------------------------------------------- | ------ | ----------- |
| id    | ID of group to update.                                   | int    | 167         |
| title | Ser-specified group title, 1 to 60 printable characters. | string | "Employees" |
| color | Group color.                                             | string | "FF6DDC"    |

#### Examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/tracker/group/update' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "a6aa75587e5c59c32d347da438505fc3", "id": 167, "title": "Employees", "color": "FF6DDC"}'
```

{% endcode %}
{% endtab %}

{% tab title="HTTP GET" %}
{% code overflow="wrap" %}

```http
https://api.eu.navixy.com/v2/tracker/group/update?hash=a6aa75587e5c59c32d347da438505fc3&id=167&title=Employees&color=FF6DDC
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response

```json
{
  "success": true
}
```

#### Errors

* 201 - Not found in the database – if no group found with the specified ID (or group belongs to another user).
