User and Group API
This article provides sample API calls to add Users and Groups and access to Dimensions.
PRE-REQUISITES:
- Set up API access. NOTE: For the User API you must also enable User Management access.
- Verify that you have API access and obtain a token via a since all API calls require a token
1. Fetch Users
You can fetch the list of all users created in the system.
- Item: user
- Method: GET
- Request URL (generated automatically):
https://docs.metricinsights.com/api/user
- Run Request
1.1. Create User
This call creates a new user. After this user is created, Login credentials are going to be sent to a specified email address.
- Item: user
- Method: POST
- ID: Specify ID of any other user previously created in the system. This user's data is going to serve as a basis for creating a new user. User ID can be found at the User Editor link (Admin > Users > select a user):
https://docs.metricinsights.com/admin/user/edit/id/4
- Define the following required user info:
- username, first_name, last_name, email, password
- type: regular, power or administrator
Optional:
- copy_from_user_id: Specify ID of a user you want to copy all permissions from.
- in_group_id: If this value is not specified, the created user is going to be assigned to a default User Group. If you want to assign a new user to a specific Group instead of a Default group (for example, to the "Finance" group), specify ID of the required Group in this field. Group ID can be found at the Group Editor link (Admin > Groups > select a group):
https://docs.metricinsights.com/admin/group/edit/id/2
- Run Request
2. Fetch Groups
You can fetch the list of all users created in the system.
- Item: user_group
- Method: GET
- Request URL (generated automatically):
https://docs.metricinsights.com/api/user
- Run Request
2.1. Create Group
This call creates a new User Group.
- Item: user_group
- Method: POST
- ID: Specify ID of any other User Group previously created in the system. This Group's data is going to serve as a basis for creating a new Group. Group ID can be found at the Group Editor link (Admin > Groups > select a group):
https://docs.metricinsights.com/admin/group/edit/id/2
- Provide a meaningful Group name
- all_access_group: Specify "yes" / "no". If creating an All Access Group, its members inherit access to all available elements, Dimensions, Dimension Values, Categories and Datasets
- Optionally, enter a description for the Group
- Run Request
3. Review User's Group membership
You can get a list of all Groups a certain User is a member of.
- Item: user_group_member
- Method: GET
- user: Specify ID of a User you want to make a member of a specific Group. User ID can be found at the User Editor link (Admin > Users > select a user):
https://docs.metricinsights.com/admin/user/edit/id/170
- Run Request
NOTE: In this example User belongs to several groups.
3.1. Add User to Group
This procedure allows adding a user to a specified group (one user at a time).
- Item: user_group_member
- Method: POST
- ID: Enter the ID of the previously created "user+group" combination. To see the list of all such pairs, choose GET method, leave other fields and Run Request. All "user+group" combinations are going to be displayed in the Raw response field. Choose the one that is supposed to serve as a foundation for the new combination.
- user_id: Specify ID of a User you want to make a member of a specific Group. User ID can be found at the User Editor link (Admin > Users > select a user):
https://docs.metricinsights.com/admin/user/edit/id/360
- user_group_id: Specify ID of the User Group you want this User to be assigned to. Group ID can be found at the Group Editor link (Admin > Groups > select a user):
https://docs.metricinsights.com/admin/group/edit/id/3
- Run Request
3.2. Remove User from the Group
To remove a user from a group, first fetch the Groups that the user is a member of (see Step 3)
- Item: user_group_member
- Method: DELETE
- ID: Enter the ID of the previously created "user+group" combination. To fetch all Groups that the User is a member of, see Step 3 of this article
- Run Request
4. Add Dimension access to Group (to all Dimension Values)
This procedure allows adding a user to a specified group (one user at a time).
- Item: group_dimension
- Method: POST
- ID: Enter the ID of the previously created "group+dimension" combination. To see the list of all such pairs, choose GET method, leave other fields empty and Run Request. All "group+dimensioned" combinations are going to be displayed in the Raw response field. Choose the one that is supposed to serve as a foundation for the new combination. If you want to give all users of a specific group access to all Dimension values, it is better to choose a combination with "All Dimension Access".
- dimension: Specify ID of a Dimension you want to give access to. Dimension ID can be found at the Dimension Editor link (Content > Dimensions > select a Dimension):
https://docs.metricinsights.com/editor/segment/edit/segment/60
- scope_of_access: All Dimension values
- group: Specify ID of the Group to which access should be given. Group ID can be found at the Group Editor link (Admin > Groups > select a group):
https://docs.metricinsights.com/admin/group/edit/id/33
- Run Request
4.1. Add specific Dimension Value access to Group
API:
https://yourinstance.metricinsights.com/api/group_dimension_value
Header:
Accept:application/json
Token:UClCUUKxUlkdbhE1cHLz3kyjbIZYVh9eB34A5Q21Y3FPqKGSJs
POST body payload:
{
"group": "14",
"dimension": "55",
"dimension_value": "7094"
}
Response:
{"id":"2","dimension_value":"7094","dimension":"55","group":"14"}