Recent searches


No recent searches

[Support API] [Bug] Merging Users is not atomic



Posted Dec 07, 2021

I'm trying to merge two users, each with different emails and external_id. Say User_1 has email 1@ex.com and external_id 1, and User 2 has email 2@ex.com and external_id 2.

Immediately after that, I want to know the resulting user's identities. I would expect the answer to be two identities, one for the email 1@ex.com and one for the email 2@ex.com. But the API is only returning one of them.


1

6

6 comments

image avatar

Greg Katechis

Zendesk Developer Advocacy

Hi Santiago! The issue that you're running into here is that users with external IDs cannot be merged. In order to merge these users, you would need to first remove the external IDs and then you could proceed with the merge.

0


But in my tests, the merge is working. If I add a 10 seconds delay between doing the merge and making the request for the user's identities (or another request like updating some information from the merged user), then it works just fine (of course this workaround would not be acceptable as a valid solution for the software that we are trying to build because of the large amount of requests that we are making). Are you saying that if I deleted the user's external_id before doing the merge, then the merge would be fully made before the response is returned and I could Immediately be able to make the other requests?

0


image avatar

Greg Katechis

Zendesk Developer Advocacy

Hi Santiago! I just checked in both the agent interface and via Postman that I am unable to merge two end-users with external IDs. Could you share the steps that you are using to accomplish this?

To answer your other question, this would not be possible, since the response is simply to the user (with their default identity) and not to the identities endpoint. You could run a script/create an app/middleware that takes the user ID of the "winning" user after the merge and list that user's identities.

0


Steps:
1. Create user with this body:
{
"user": {
"external_id": "ext_1",
"email": "ext_1@test.com",
"name": "Some Name"
}
}
The user was created with id 1903966013487
2. Create another user with this body:
{
"user": {
"external_id": "ext_2",
"email": "ext_2@test.com",
"name": "Other Name"
}
}
The user was created with id 422351264852
3. Merge users by sending PUT to /api/v2/users/1903966013487/merge
with body:
{
"user": {
"id": 422351264852
}
}
Response is 200 OK and in the boody:
{
"user": {
"id": 422351264852,
"url": "XXXXXXXXXXX",
"name": "Other Name",
"email": "ext_2@test.com",
"created_at": "2021-12-08T21:32:42Z",
"updated_at": "2021-12-08T21:32:42Z",
"time_zone": "Brasilia",
"iana_time_zone": "America/Sao_Paulo",
"phone": null,
"shared_phone_number": null,
"photo": null,
"locale_id": 1194,
"locale": "es-419",
"organization_id": null,
"role": "end-user",
"verified": false,
"external_id": "ext_2",
"tags": [],
"alias": null,
"active": true,
"shared": false,
"shared_agent": false,
"last_login_at": null,
"two_factor_auth_enabled": false,
"signature": null,
"details": null,
"notes": null,
"role_type": null,
"custom_role_id": null,
"moderator": false,
"ticket_restriction": "requested",
"only_private_comments": false,
"restricted_agent": true,
"suspended": false,
"default_group_id": null,
"report_csv": false,
"user_fields": {
"XXXXXXXX": false,
}
}
}


1


Hi Joseph James Greg Katechis,

I have the same issue as Santiago: when merging users, I cannot immediately fetch the user and see the changes. If I wait a couple seconds, then I can see the changes. Is there a way to merge users using the API and ensure that it is an atomic change before receiving the response?

I'm curious what the result of Santiago's fix was because it may be similar to mine.

Thanks!

0


Hi Travis!
We didn't find a fix, we were forced to add a complex workaround that consists in adding the process that we needed to run after the merge in a delay queue, so that we can dequeue it only after the delay time has passed.
If you found a better solution please tell me to check if it simplifies our code.

Cheers!

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post