# Create company with an existing name via api

**URL:** https://forum.mautic.org/t/create-company-with-an-existing-name-via-api/27487
**Category:** Product Support
**Created:** [March 23, 2023, 4:53pm UTC](https://forum.mautic.org/t/create-company-with-an-existing-name-via-api/27487 "2023-03-23T16:53:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jeanplouin](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@jeanplouin](https://forum.mautic.org/u/jeanplouin)
#### Post date: [March 23, 2023, 4:53pm UTC](https://forum.mautic.org/t/create-company-with-an-existing-name-via-api/27487/1 "2023-03-23T16:53:56Z")

</div>

Hi all!

I’m trying, via API, to create a company that has the same name as an existing one (as i can do through the browser).

I POST to /api/companies/new with only one param (companyname)

instead of creating a second company with the existing name, it updates and returns the existing one…

Is it the expected behavior ? If it is, how can i achieve the creation of a company with a name that already exists ?

Thank you !

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [March 23, 2023, 5:15pm UTC](https://forum.mautic.org/t/create-company-with-an-existing-name-via-api/27487/2 "2023-03-23T17:15:10Z")

</div>

Hi, are you using the “Primary Company” of the contact in your call?

---

<div class="post-metadata">

### Author: ![jeanplouin](https://avatars.discourse-cdn.com/v4/letter/j/a698b9/32.png) [@jeanplouin](https://forum.mautic.org/u/jeanplouin)
#### Post date: [March 24, 2023, 9:21am UTC](https://forum.mautic.org/t/create-company-with-an-existing-name-via-api/27487/3 "2023-03-24T09:21:48Z")

</div>

Hi!  
No i am not using the “primary company”.

The field companyname is actually a default primary key for companies, and the post request “deduplicates” using the primary key. The primary key can be changed via “custom fields”, and that did the trick for me.

Thanks for you help i’m closing the thread

---

<div class="post-metadata">

### Author: ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)
#### Post date: [March 24, 2023, 9:59am UTC](https://forum.mautic.org/t/create-company-with-an-existing-name-via-api/27487/4 "2023-03-24T09:59:36Z")

</div>

Cool.  
make sure this move doesn’t have an affect on pairing contacts to companies.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/1X/43c63600fe51440378769136903f1fa2a9a34102.png) [@system](https://forum.mautic.org/u/system)
#### Post date: [March 25, 2023, 10:00pm UTC](https://forum.mautic.org/t/create-company-with-an-existing-name-via-api/27487/5 "2023-03-25T22:00:29Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
