Update user data
- Obtain your API keys from Medallia
-
Create an application account and create an OAuth account for you application (per Create an OAuth client for API access). You need the client ID and client secret to authorize access and provide an access token.
-
To access user accounts, the role associated with the account needs the Manage Users permission.
-
Identify the resource endpoint to use to make queries. Verify the query URL and endpoint (for details about this URL and for determining the URL for the sandbox, see API hosts.
-
- Request an access tokenTo request an access token ,substitute your company URL for instance.medallia.com, insert your company name, and use the client ID and secret provided:
POST <token_URL>/oauth/company/token Username: clientID Password: clientSecret grant_type: set this to client_credentials
The OAuth server returns a JSON value like this:{"access_token":"40d182e5dcbef32ce34b737ba5d4","token_type":"Bearer","expires_in":3600}
Once you have the access token (access_token value), you can make a request to find a specific user.
- Request data about a specific userMake an HTTP GET request using the access token as the
Bearer
value. Substitute the URL and endpoint provided to you. In this example, the username is cabbott.GET <api-host>/admin/v1/users/cabbott Bearer: 40d182e5dcbef32ce34b737ba5d4
The query returns the user data. Note that the user status is ACTIVE, we will change the user status in the next example.
{ "username": "cabbott", "first_name": "Carmen", "last_name": "Abbott", "email": "cabbott@example.com", "automatic_update": true, "excluded_from_user_activity": false, "login_blocked": false, "roles": { "primary_role": { "role": "[CC] Agent" }, "extra_roles": [] }, "data-access": { "organization": [ { "role": "[CC] Agent", "data_view": "Expdemo for Experience", "unit_group": "(U) cc_agent_145", "unit_group_display_name": "Carmen Abbott [ 145 ]" } ], "segments": [] }, "_system_properties": { "status": "ACTIVE", "created_on": "2019-06-04T22:27:38.417Z", "modified_on": "2021-03-09T22:10:46.844Z", "modified_by": "medallia_app_integrations", "login_count": 0, "failed_login_count": 0, "password_not_set_reason": "NEW_ACCOUNT" } }
- Change the user statusMake an HTTP POST request using the access token as the
Bearer
value to set the user status to INACTIVE.POST <api-host>/admin/v1/users/cabbott/actions/inactive Bearer: 40d182e5dcbef32ce34b737ba5d4
The API returns standard HTTP response codes. - Reset the user passwordMake an HTTP POST request using the access token as the
Bearer
value to reset the user password.POST <api-host>/admin/v1/users/cabbott/actions/reset-password Bearer: 40d182e5dcbef32ce34b737ba5d4
The API returns standard HTTP response codes. - Change the user contact informationMake an HTTP PUT request using the access token as the
Bearer
value to change the user email.PUT <api-host>/admin/v1/users/cabbott Bearer: 40d182e5dcbef32ce34b737ba5d4 Content-Type: application/json
{ "username": "cabbott", "first_name": "Carmen", "last_name": "Abbott", "email": "carmen.abbott@example.com", "automatic_update": true, "excluded_from_user_activity": false, "login_blocked": false, "roles": { "primary_role": { "role": "[CC] Agent" }, "extra_roles": [] }, "data-access": { "organization": [ { "role": "[CC] Agent", "data_view": "Expdemo for Experience", "unit_group": "(U) cc_agent_145", "unit_group_display_name": "Carmen Abbott [ 145 ]" } ], "segments": [] }, "_system_properties": { "status": "INACTIVE", "created_on": "2019-06-04T22:27:38.417Z", "modified_on": "2021-03-09T22:10:46.844Z", "modified_by": "medallia_app_integrations", "login_count": 0, "failed_login_count": 0, "password_not_set_reason": "NEW_ACCOUNT" } }
The query returns the user data. Check that theemail
parameter has the new value. - Assign a new role to the userMake an HTTP PUT request using the access token as the
Bearer
value to assign a role to the user.PUT <api-host>/admin/v1/users/cabbott Bearer: 40d182e5dcbef32ce34b737ba5d4 Content-Type: application/json
{ "username": "cabbott", "first_name": "Carmen", "last_name": "Abbott", "email": "carmen.abbott@example.com", "automatic_update": true, "excluded_from_user_activity": false, "login_blocked": false, "roles": { "primary_role": { "role": "[CC] Agent" }, "extra_roles": [ { "role": "[RETAIL] Insights" } ] }, "data-access": { "organization": [ { "role": "[CC] Agent", "data_view": "Expdemo for Experience", "unit_group": "(U) cc_agent_145" }, { "role": "[RETAIL] Insights", "data_view": "Expdemo for Experience", "unit_group": "expdemo" } ], "segments": [] } }
The API returns the user data. Check that the user has the new role.
- Update the user data accessFor a user, their data access is defined by the role and data view:
{ "role": "[CC] Agent", "data_view": "Expdemo for Experience", "unit_group": "(U) cc_agent_145" }
For example, for Role A and Data View D, users might have access to 3 units, but for Role B and Data View D, they can have access to 2 units.
Make an HTTP PUT request using the access token as the
Bearer
value to change the user's data access.PUT <api-host>/admin/v1/users/cabbott/data-access Bearer: 40d182e5dcbef32ce34b737ba5d4 Content-Type: application/json
{ "organization": [ { "role": "[CC] Agent", "data_view": "Expdemo for Experience", "unit_group": "(U) cc_agent_145", "unit_group_display_name": "Carmen Abbott [ 145 ]" }, { "role": "[CC] Agent", "data_view": "Expdemo for Experience", "unit_group": "unittype_cc_agent", "unit_group_display_name": "Contact Center" } ], "segments": [] }
The query returns the user data. Check that the data access has been updated.
{ "username": "cabbott", "first_name": "Carmen", "last_name": "Abbott", "email": "carmen.abbott@example.com", "automatic_update": true, "excluded_from_user_activity": false, "login_blocked": false, "roles": { "primary_role": { "role": "[CC] Agent" }, "extra_roles": [] }, "data-access": { "organization": [ { "role": "[CC] Agent", "data_view": "Expdemo for Experience", "unit_group": "(U) cc_agent_145", "unit_group_display_name": "Carmen Abbott [ 145 ]" }, { "role": "[CC] Agent", "data_view": "Expdemo for Experience", "unit_group": "unittype_cc_agent", "unit_group_display_name": "Contact Center" } ], "segments": [] }, "_system_properties": { "status": "INACTIVE", "created_on": "2019-06-04T22:27:38.417Z", "modified_on": "2021-03-11T20:03:11.254Z", "modified_by": "medallia_app_integrations", "login_count": 0, "failed_login_count": 0, "password_not_set_reason": "NEW_ACCOUNT" } }