Skip to content

SonaMergeUser

Description

This function merges one user account into another. Associated records and roles are transferred from person_id_to_remove to person_id_to_keep, and the account identified by person_id_to_remove is then deleted. The merge is allowed only when both accounts exist, the person IDs are different, and the users have no roles in common. For example, two participants or two administrators cannot be merged.

Input Parameters

Below are the following input parameters for use with the SonaMergeUser API function.

Parameter Description / Possible Values
api_key Use API key generated for Sona admin user
person_id_to_keep Numeric identifier of the account that remains and receives the other account’s data and roles.
person_id_to_remove Numeric identifier of the account whose data and roles are transferred. This account is deleted after a successful merge.

Output Parameters

Returns integer value 1 when the users are merged successfully.

Error Codes

Below are the possible error messages encountered and their respective descriptions.

Error Type Error Code Description
Authentication Failed -1 through -7 Standard authentication errors
Invalid person_id -8 person_id_to_keep or person_id_to_remove entered is invalid
User not found -9 person_id_to_keep or person_id_to_remove entered is not found
Merge failed -15 The users could not be merged
Same user -16 person_id_to_keep and person_id_to_remove refer to the same user
Conflicting roles -17 The users have one or more roles in common. The error message lists the conflicting role codes: A = admin | E = researcher | I = instructor | P = PI | S = participant.
P may also be returned when person_id_to_remove has the PI role and the PI feature is disabled.

Sample Input

Request URL

https://myschool.sona-systems.com/services/SonaAPI.svc/SonaMergeUser?api_key=YOUR_API_KEY&person_id_to_keep=15&person_id_to_remove=27

URL components

Component Value
Scheme https
Host myschool.sona-systems.com
Service path /services/SonaAPI.svc
Function SonaMergeUser

Query parameters

api_key = YOUR_API_KEY
person_id_to_keep = 15
person_id_to_remove = 27

Sample Output

<SonaMergeUserResponse
  xmlns="https://www.sona-systems.com/"
  xmlns:a="http://schemas.datacontract.org/2004/07/emsdotnet.sonasystems"
  xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <SonaMergeUserResult>
    <a:Errors i:nil="true" />
    <a:Result>1</a:Result>
  </SonaMergeUserResult>
</SonaMergeUserResponse>