Link two user accounts
User Administration
Link User Accounts
Admin-only endpoint to link a secondary user account into a primary account. - The userToLinkId account will be deleted after merging its linked accounts into the primary userId.
POST
Link two user accounts
Admin-only endpoint to link a secondary user account into a primary account. The
userToLinkId account will be deleted after merging its linked accounts into the primary userId.
Request
Headers
| Name | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Bearer token |
| Content-Type | string | Yes | application/json |
Request Body
Request Body Schema
| Field | Type | Required | Description |
|---|---|---|---|
| payload | object | Yes | Link accounts payload |
| payload.userId | string | Yes | Primary user ID (will keep the account) |
| payload.userToLinkId | string | Yes | Secondary user ID (will be deleted) |
Response
200 OK - Successfully linked accounts
400 Bad Request
401 Unauthorized
404 Not Found
500 Internal Server Error
Example
Notes
- This is an admin-only endpoint - requires administrative privileges
- Both user IDs must be valid MongoDB ObjectIds
- The secondary account (
userToLinkId) will be permanently deleted - All linked accounts from the secondary user are merged into the primary
- This action is irreversible - the secondary account cannot be restored
- Use this to consolidate duplicate user accounts
- The primary user retains their original ID and all merged linked accounts
- Permissions and department assignments from the secondary account are lost