Table of Contents

APIs for user groups

Ramya Priya Updated by Ramya Priya

Here, you can find APIs for

  • Creating user groups (POST)
  • Updating user groups (PUT)
  • Getting a list of all user groups (GET)
  • Deleting user groups (DELETE)
  • Adding users to a user group/ removing users from a user group
  • Creating row-level policy

For accessing the following APIs, JSON Web Token (JWT) needs to be generated using login API.

Create a user group

The API can be used to create a new user group.

Request

URL
http://<TELLIUS_URL>/groups
CURL

User groups can only be created using superUser/ Admin tokens.

curl -v  -H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>" \
http://<TELLIUS_URL>/groups \
--data '{"name": "usersListViewers"}'
Method
POST
Headers

By default, only superUsers can access this view.

Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json
Body
{
"name": "usersListViewers",
"role": "interactive"
}

Response

Success
Status Code: 200 OK
Body

A new user group with the following properties will be created.

{
"name": "usersListViewers",
"id": "568264b3e4e80befc93",
"role": "interactive"
}

Update a user group

The API can be used to update an existing user group.

Request

URL

Replace <groupId> with the ID of the user group that needs to be updated.

https://<telliusUrl>/groups/<groupId>
CURL
 curl 'https://<telliusUrl>/groups/568264b3ed93764e80befc93' \
-X 'PUT' \
-H 'Authorization: Bearer token' \
--data-binary '{"name":"new name"}'
Method
PUT
Headers
Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json
Body
{
"name": "new_name"
}

Response

Success
Status Code: 200 OK
Body

This returns the updated user group name.

{
"name": "new_name",
"id": "dwew34hd80befc93",
"role": "interactive"
}

Get the list of user groups

The API returns the list of existing user groups.

Request

URL
 https://<TelliusUrl>/groups
CURL
curl -v -H "Content-Type: application/json" \
-H "Authorization:<AUTHENTICATION_TOKEN_FROM_LOGIN_API>" \
https://<tellius>/groups
Method
GET
Headers

By default, only superUsers can access this view.

Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json

Response

Success
Status Code: 200 OK
Body

This returns the list of user groups (in an array, depending upon the number of user groups).

{
"groups": [
{
"updatedAt": "2019-12-13T16:07:28.993086",
"role": "view",
"name": "testGroup",
"id": "6f69ff18-9134-42ac-a763-af0897678fa9",
"createdAt": "2019-12-13T16:07:28.993073"
}
]
}

Delete a user group

The API can be used to delete an existing user group.

Request

URL

Replace <groupId> with the ID of the user group that needs to be deleted.

 https://<telliusUrl>/groups/<groupId>
CURL
 curl 'https://<telliusUrl>/groups/568264b3ed93764e80befc93' \
-X DELETE \
-H 'Authorization: Bearer token'
Method
DELETE
Headers
Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json

Response

Success
Status Code: 200 OK
Body

If the user group is successfully deleted, the API will return a response with HTTP status code 200 and an empty response body.

Add/remove users to user groups

This API takes a list of groups that the user should be a part of. It is an overwrite operation so it can be used to add/remove a user from groups using the same API.

  1. If a user is part of two groups and has to be added to another group, then all three group IDs need to be sent.
  2. If a user is part of two groups and has to be removed from one of the groups, then that particular group ID needs to be removed from the list.

This API updates the user with the given user ID and adds/removes the user from the specified groups.

Request

URL
https://<TelliusUrl>/users/<userId>
CURL

User groups can only be created using superUser/ Admin tokens

curl -v -X PUT -H "Content-Type: application/json" \
-H "Authorization:<AUTHENTICATION_TOKEN_FROM_LOGIN_API>" \
https://<tellius>/users/<user-id> \
--data '{"groups":["9f7ad673-cb94-4c59-99d3-f8e777f325eb"]}'
Method
PUT
Headers

By default, only superUsers can access this view.

Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json
Body

The request body consists of a "groups" key containing a list of group IDs that the user should be a part of.

{
"groups": ["9f7ad673-cb94-4c59-99d3-f8e777f325eb"]
}

Response

Success
Status Code: 200 OK
Body

The response body is a JSON object with the updated user details, including the list of groups the user belongs to.

{
"visits": [],
"username": "stest",
"updatedAt": "2019-12-13T14:45:37.833222",
"role": "interactive",
"lastName": "sb",
"id": "720e8bdf-6394-4a80-b22c-4b8ef5976634",
"groups": [
{
"updatedAt": "2019-12-13T16:07:28.993086",
"role": "view",
"name": "testGroup",
"id": "6f69ff18-9134-42ac-a763-af0897678fa9",
"createdAt": "2019-12-13T16:07:28.993073"
}
],
"firstName": "stest",
"email": "a@b.co",
"dataLoadingRestriction": false,
"createdAt": "2019-12-13T08:01:40.818675",
"color": "#3252DB",
"active": true
}

Create row-level policy

This API takes a list of groups that the user should be a part of. It is an overwrite operation so it can be used to add/remove a user from groups using the same API.

  1. If a user is part of two groups and has to be added to another group, then all three group IDs need to be sent.
  2. If a user is part of two groups and has to be removed from one of the groups, then that particular group ID needs to be removed from the list.

This API updates the user with the given user ID and adds/removes the user from the specified groups.

Request

URL
https://<TelliusUrl>/groups/:groupId
CURL

User groups can only be created using superUser/ Admin tokens

curl -v -X PUT -H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>" \
http://<TELLIUS_URL>/groups/<group_Id> \
--data '{
"rowLevelPolicies": [{
"businessViewId": "<BusinessViewID_1>",
"rowLevelPolicy": {
"operator": "OR",
"args": [{
"field": "age",
"condition": ">",
"value": 35
},
{
"field": "age",
"condition": "<",
"value": 60
}
]
}
}, {
"businessViewId": "<BusinessViewID_2>",
"rowLevelPolicy": {
"condition": "=",
"field": "FinancialGroup",
"value": "TTOTG"
}
}]
}'
Method
PUT
Headers
Authorization: Bearer <AUTHENTICATION_TOKEN_FROM_LOGIN_API>
Content-Type: application/json
Body

Multiple rowLevelPolicy can be passed in rowLevelPolicies field in Group object. There can be only one rowLevelPolicy for a BusinessView.

{
"rowLevelPolicies": [{
"businessViewId": "<BusinessViewID_1>",
"rowLevelPolicy": {
"operator": "OR",
"args": [{
"field": "age",
"condition": ">",
"value": 35
},
{
"field": "age",
"condition": "<",
"value": 60
}
]
}
}, {
"businessViewId": "<BusinessViewID_2>",
"rowLevelPolicy": {
"condition": "=",
"field": "FinancialGroup",
"value": "TTOTG"
}
}]
}

Response

Success
Status Code: 200 OK
Body

The response body returns the updated group object with the newly added row-level policies.

{
"updatedAt": "2018-07-13T12:45:11.958069",
"rowLevelPolicies": [{
"businessViewId": "<BusinessViewID_1>",
"rowLevelPolicy": {
"operator": "OR",
"args": [{
"field": "age",
"condition": ">",
"value": 35
},
{
"field": "age",
"condition": "<",
"value": 60
}
]
}
}, {
"businessViewId": "<BusinessViewID_2>",
"rowLevelPolicy": {
"condition": "=",
"field": "FinancialGroup",
"value": "TTOTG"
}
}],
"name": "testGroup",
"id": "adbe3a78-1816-49b3-b660-3d442d7c3e76",
"createdAt": "2018-07-13T12:45:11.958060"
}

Did we help you?

APIs for users

Contact