Update user data

To find a specific user and modify its data leverage the Users API. The examples below show how to get an access token, and use the API to update users' account data, and change their status, assigned roles and data access.
Detailed information about the API is available in these topics:
  1. Obtain your API keys from Medallia
    1. 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.

    2. To access user accounts, the role associated with the account needs the Manage Users permission.

    3. 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.

  2. Request an access token
    To 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.

  3. Request data about a specific user
    Make 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"
        }
    }
  4. Change the user status
    Make 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.
  5. Reset the user password
    Make 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.
  6. Change the user contact information
    Make 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 the email parameter has the new value.
  7. Assign a new role to the user
    Make 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.

  8. Update the user data access
    For 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"
        }
    }
To see more detailed information about this API, see the Users API documentation.