# Now that there is an API call for Merge Users, how to call it?

**URL:** https://meta.discourse.org/t/now-that-there-is-an-api-call-for-merge-users-how-to-call-it/149820
**Category:** Development
**Tags:** rest-api, merge-user
**Created:** [29 april 2020 om 20:38 UTC](https://meta.discourse.org/t/now-that-there-is-an-api-call-for-merge-users-how-to-call-it/149820 "2020-04-29T20:38:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mpemburn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpemburn/32/178585_2.png) [@mpemburn](https://meta.discourse.org/u/mpemburn)
#### Post date: [29 april 2020 om 20:38 UTC](https://meta.discourse.org/t/now-that-there-is-an-api-call-for-merge-users-how-to-call-it/149820/1 "2020-04-29T20:38:26Z")

</div>

Hi,

I started a topic yesterday (now closed) about calling the Merge Users plugin programmatically, and Rafael kindly referred me to the release notes, which feature a mention of the plugin now having a UI ([Discourse 2.5.0.beta3 Release Notes](https://meta.discourse.org/t/discourse-2-5-0-beta3-release-notes/148766)). Sadly, my skills with the Discourse API are not such that I can translate this into an API call. This is something that we will need to do from our application on a fairly regular basis. Can you help me out, please?

Thanks in advance,

Mark Pemburn  
Blue Ocean Ideas

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [29 april 2020 om 21:45 UTC](https://meta.discourse.org/t/now-that-there-is-an-api-call-for-merge-users-how-to-call-it/149820/2 "2020-04-29T21:45:55Z")

</div>

The button is visible at the bottom of a user’s administration page.

![image](https://global.discourse-cdn.com/meta/original/3X/1/b/1b2937eec7ac15affb66eda55794c6271428846b.png)

If you open your [browser developer tools while using it](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576), you will see the request that needs to be made.

---

<div class="post-metadata">

### Author: ![mpemburn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpemburn/32/178585_2.png) [@mpemburn](https://meta.discourse.org/u/mpemburn)
#### Post date: [6 mei 2020 om 15:27 UTC](https://meta.discourse.org/t/now-that-there-is-an-api-call-for-merge-users-how-to-call-it/149820/3 "2020-05-06T15:27:15Z")

</div>

Hi Kane,

Thanks for the tip! It took me a while to be able to create some users in my sandbox Discourse, but I was able to do so today. I took what I gleaned from the dev tools Network panel and attempted to duplicate it via Postman. These are the values:

Method: POST  
Endpoint: [https://my-discourse-sandbox/admin/users/](https://my-discourse-sandbox/admin/users/){source user ID}/merge.json

Headers:

```plaintext
Content-Type: multipart/form-data
Accept: application/json

```

Params:

```plaintext
Api-Key: {create via the UI}
Api-Username: system
context: /admin/users/{source user ID/{source username}
target_username: {target username}

```

The response was:

```plaintext
    {
        "errors": [
            "The requested URL or resource could not be found."
        ],
        "error_type": "not_found"
    }

```

Any idea of what I’m doing wrong?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [6 mei 2020 om 15:42 UTC](https://meta.discourse.org/t/now-that-there-is-an-api-call-for-merge-users-how-to-call-it/149820/4 "2020-05-06T15:42:54Z")

</div>

Those all look correct at a glance. Have you checked that the target\_username value exists?

---

<div class="post-metadata">

### Author: ![mpemburn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpemburn/32/178585_2.png) [@mpemburn](https://meta.discourse.org/u/mpemburn)
#### Post date: [6 mei 2020 om 16:41 UTC](https://meta.discourse.org/t/now-that-there-is-an-api-call-for-merge-users-how-to-call-it/149820/5 "2020-05-06T16:41:26Z")

</div>

Kane,

Yes, both source and target are current users. If I remove the headers, I get back an HTML page that says “Oops! That page doesn’t exist or is private.” The “page doesn’t exist” part is understandable for a 404 error, but I’m not sure what “private” implies here.

Mark

---

<div class="post-metadata">

### Author: ![artur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/artur/32/260740_2.png) [@artur](https://meta.discourse.org/u/artur)
#### Post date: [19 mei 2022 om 09:50 UTC](https://meta.discourse.org/t/now-that-there-is-an-api-call-for-merge-users-how-to-call-it/149820/6 "2022-05-19T09:50:41Z")

</div>

@mpemburn did you have any success with this?

I’m migrating some mailing lists to a discourse instance. Since many people used different emails the transfer creates many staged users per real person. I would like to automate the merging of users via the API.
