Group

A collection of Users. Groups support hierarchy, and can contain sub-groups.

Every Group object has an access token which can be used with dashboard widgets to visualise the group's users.

Object properties

Property Type Description
id UUID string Unique identifier, set by hypertrack
unique_id string Unique identifier, set by you
name string Name of the group
parent_group_id UUID string id of parent group
token string Read-only token for group level dashboard widgets
created_at datetime Timestamp of when group was created

API calls

Base url: https://api.hypertrack.com/api/v2/

API call Method URL Description
Create a group groups/ Create a new group object
Retrieve a group groups/ID/ Get an existing group object
Update a group groups/ID/ Update an existing group object
List multiple groups groups/ List multiple group objects
Get users of a group users/ Get all users of a given group
Add user to group users/ID/ Add a user to given group
Remove user from group users/ID/ Remove a user from given group

Create a Group

Request body parameter Required Description
name Required Name of the group
unique_id Optional Unique id for the group
parent_group_id Optional UUID of the parent group, if this group belongs to a group
curl --request POST \
  --url https://api.hypertrack.com/api/v2/groups/ \
  --header 'Authorization: token PUBLISHABLE_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "unique_id": "GROUP_0001",
  "name": "Storm Trooper Group"
}'

//Create a child group
curl --request POST \
  --url https://api.hypertrack.com/api/v2/groups/ \
  --header 'Authorization: token PUBLISHABLE_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "unique_id": "GROUP_0001A",
  "name": "Storm Trooper Sub-group",
  "parent_group_id": "f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a"
}'
HyperTrackClient client = new HyperTrackClient("PUBLISHABLE_KEY");
GroupFactory groupFactory = new GroupFactory(client);
Map<String, Object> params = new HashMap<>();
params.put("name", "North zone");
Group group = groupFactory.create(params);
hypertrack.groups.create({
    "name": "North zone"
});;

Example response

{
  "id": "f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a",
  "name": "Southern group",
  "parent_group_id": "15ce9cdc-1409-4976-a260-dc0e5b2445ac",
  "token": "gk_1409a26018fse12",
  "created_at": "2016-03-09T05:20:19.742229Z",
  "modified_at": "2016-03-09T05:20:19.742257Z"
}

Retrieve a Group


curl -H "Authorization: token PUBLISHABLE_KEY" \
     -X GET \
     https://api.hypertrack.com/api/v2/groups/f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a/
HyperTrackClient client = new HyperTrackClient("PUBLISHABLE_KEY");
GroupFactory groupFactory = new GroupFactory(client);
Group group = groupFactory.retrieve("f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a");
hypertrack.groups
    .retrieve("f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a")
    .then(function(group) {})

Example response

{
  "id": "f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a",
  "name": "Group name",
  "created_at": "2016-03-09T05:20:19.742229Z",
  "modified_at": "2016-03-09T05:20:19.742257Z"
}

Update a Group

Request body parameter Description
name Name of the group
unique_id Unique identifier of the group
parent_group_id Identifier of the parent group
curl -H "Authorization: token PUBLISHABLE_KEY" \
     -H "Content-Type: application/json" \
     -X PATCH \
     -d "{\"name\": \"New Storm Trooper Group\"}" \       
     https://api.hypertrack.com/api/v2/groups/16d3d307-21e4-42b9-aa59-ac9a2ae43c65/
HyperTrackClient client = new HyperTrackClient("PUBLISHABLE_KEY");
GroupFactory groupFactory = new GroupFactory(client);
Map<String, Object> params = new HashMap<>();
params.put("name", "New name");
groupFactory.patch(group, params);
hypertrack.groups
    .update(
        "f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a",
        {
            "name": "New name"
        }
    )

Example response

{
  "id": "16d3d307-21e4-42b9-aa59-ac9a2ae43c65",
  "name": "Name changed",
  "created_at": "2016-03-09T05:20:19.742229Z",
  "modified_at": "2016-03-09T05:20:19.742257Z"
}

List multiple Groups

URL parameters Required Description
name No Filter groups with names that contain this string
unique_id No Filter by group unique id
has_parent No Pass true to filter for groups that have a parent, false for groups without a parent
page_size No Maximum number of objects to return, default is 50
curl -H "Authorization: token SECRET_KEY" \
     -X GET \
     https://api.hypertrack.com/api/v2/groups/?page_size=20
HyperTrackClient client = new HyperTrackClient("PUBLISHABLE_KEY");
GroupFactory groupFactory = new GroupFactory(client);
HyperTrackArrayList<Group> groups = groupFactory.list();
hypertrack.groups
    .list()
    .then(function(groups) {});

Example response

{
  "count":1,
  "next":null,
  "previous":null,
  "results":[
    {
      "id":"f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a",
      "name":"North group",
      "created_at":"2016-03-09T05:20:19.742229Z",
      "modified_at":"2016-03-09T05:20:19.742257Z"
    }
  ]
}

Get users of Group

URL parameters Required Description
group_id No Filter users that have this group. Note that groups can be hierarchical and this API only returns users that belong directly to this group
page_size No Maximum number of objects to return, default is 50
curl -H "Authorization: token PUBLISHABLE_KEY" \
     -X GET \
     https://api.hypertrack.com/api/v2/users/?group_id=f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a

Response will be a list of Users.

Add user to group

Update the user object to add the user to a group.

Request body parameter Value
group_id uuid of the group
curl -H "Authorization: token PUBLISHABLE_KEY" \
     -H "Content-Type: application/json" \
     -X PATCH \
     -d "{\"group_id\": \"f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a\"}" \
     https://api.hypertrack.com/api/v2/users/16d3d307-21e4-42b9-aa59-ac9a2ae43c65/
hypertrack.users
    .update(
        "16d3d307-21e4-42b9-aa59-ac9a2ae43c65",
        {
            "group_id": "f3ead2ae-dc0a-4a7e-85be-74ee51d9d70a"
        }
    );

Remove user from group

Update the user object to remove the user from a group.

Request body parameter Value
group_id null
curl -H "Authorization: token PUBLISHABLE_KEY" \
     -H "Content-Type: application/json" \
     -X PATCH \
     -d "{\"group_id\": null}" \
     https://api.hypertrack.com/api/v2/users/16d3d307-21e4-42b9-aa59-ac9a2ae43c65/
hypertrack.users
    .update(
        "16d3d307-21e4-42b9-aa59-ac9a2ae43c65",
        {
            "group_id": null
        }
    );

results matching ""

    No results matching ""