# Update contacts via API

**URL:** <https://forum.mautic.org/t/update-contacts-via-api/29089>\
**Category:** Product Support\
**Created:** [August 28, 2023, 3:30pm UTC](https://forum.mautic.org/t/update-contacts-via-api/29089 "2023-08-28T15:30:43Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![CarlJohan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/carljohan/32/7016_2.png) [@CarlJohan](https://forum.mautic.org/u/CarlJohan)\
**Post date:** [August 28, 2023, 3:30pm UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/1 "2023-08-28T15:30:43Z")

</div>

Hi,

I have a lot of contacts in Excel that also sit in Mautic. I would like to update them via an API.

I understand that this is possible, but, does anyone have any script example on how this can be done?

---

<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:** [August 28, 2023, 7:03pm UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/2 "2023-08-28T19:03:54Z")

</div>

Sure but first: why not do an import?

---

<div class="post-metadata">

**Author:** ![CarlJohan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/carljohan/32/7016_2.png) [@CarlJohan](https://forum.mautic.org/u/CarlJohan)\
**Post date:** [August 28, 2023, 7:21pm UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/3 "2023-08-28T19:21:41Z")

</div>

Just easier, clicking a button and updating, will save me some time.

---

<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:** [August 28, 2023, 9:02pm UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/4 "2023-08-28T21:02:16Z")

</div>

Okay, so you have this excel (lets call it a csv) on your server?

---

<div class="post-metadata">

**Author:** ![CarlJohan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/carljohan/32/7016_2.png) [@CarlJohan](https://forum.mautic.org/u/CarlJohan)\
**Post date:** [August 29, 2023, 8:32am UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/5 "2023-08-29T08:32:30Z")

</div>

Thats local.

Ic an ofc script the excel file to simply update the DB, but that scares me a bit since I don’t know what kind of mess I can do.

---

<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:** [August 29, 2023, 10:07am UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/6 "2023-08-29T10:07:38Z")

</div>

I still don’t understand why you don’t use mautic import? It’s 3 clicks:

> **[How to import contacts to Mautic in the background without timing out -...](https://kb.mautic.org/article/how-to-import-contacts-to-mautic-in-the-background-without-timing-out.html)**
>
> How to import large volumes of contacts to Mautic using the background cron job.

---

<div class="post-metadata">

**Author:** ![CarlJohan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/carljohan/32/7016_2.png) [@CarlJohan](https://forum.mautic.org/u/CarlJohan)\
**Post date:** [August 29, 2023, 10:09am UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/7 "2023-08-29T10:09:31Z")

</div>

The excel sheet I have dont have the right format, and I don’t want to add steps to my process, easier just to push a button.

---

<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:** [August 29, 2023, 10:11am UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/8 "2023-08-29T10:11:39Z")

</div>

Oh okay, so you want to save the “excel to CSV” conversion step? 🙂

---

<div class="post-metadata">

**Author:** ![CarlJohan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/carljohan/32/7016_2.png) [@CarlJohan](https://forum.mautic.org/u/CarlJohan)\
**Post date:** [August 29, 2023, 10:15am UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/9 "2023-08-29T10:15:20Z")

</div>

Well, there is more to it, the excel sheet doesn’t have a form that is good for import, so I need to add several steps.

---

<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:** [August 29, 2023, 10:22am UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/10 "2023-08-29T10:22:47Z")

</div>

Okay,  
so you need to program either the steps as macro / concat solution in excel  
OR  
you need to create a script, that recognises the fields in excel and passes over to Mautic via API.

I think this is not so much a Mautic question then an excel quesiton 🙂

---

<div class="post-metadata">

**Author:** ![CarlJohan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/carljohan/32/7016_2.png) [@CarlJohan](https://forum.mautic.org/u/CarlJohan)\
**Post date:** [August 29, 2023, 11:48am UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/11 "2023-08-29T11:48:29Z")

</div>

Well, Mautic have an API, right?

---

<div class="post-metadata">

**Author:** ![bobkitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/bobkitz/32/12780_2.png) [@bobkitz](https://forum.mautic.org/u/bobkitz)\
**Post date:** [August 31, 2023, 11:25am UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/12 "2023-08-31T11:25:03Z")

</div>

Yes Mautic has an API. But coding against an API is usually more work than doing the same data manipulation in Excel, saving as CSV and importing, especially for one-time updates. If you coded against the API you would have to do the same manipulation in code prior to calling the API to update the contact. And you would have the extra effort of writing code to read data from the Excel/CSV file, etc. What programming languages are you familiar with? That might help with examples, if you really want to go that route.

---

<div class="post-metadata">

**Author:** ![CarlJohan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/carljohan/32/7016_2.png) [@CarlJohan](https://forum.mautic.org/u/CarlJohan)\
**Post date:** [August 31, 2023, 1:34pm UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/13 "2023-08-31T13:34:31Z")

</div>

I do this several times a day.

Like I said, I’ll be doing this in Excel, so it’s VBA, so the question is: “does anyone have any script example on how this can be done”.

I cant imagine that this is the first time someone is calling the Mautic API from Excel.

---

<div class="post-metadata">

**Author:** ![robm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/robm/32/260_2.png) [@robm](https://forum.mautic.org/u/robm)\
**Post date:** [August 31, 2023, 2:30pm UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/14 "2023-08-31T14:30:14Z")

</div>

I have connected Mautic and Google sheets via n8n using the api for both. No code option and probably too clumsy for what you need but is working well for me.

---

<div class="post-metadata">

**Author:** ![CarlJohan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/carljohan/32/7016_2.png) [@CarlJohan](https://forum.mautic.org/u/CarlJohan)\
**Post date:** [August 31, 2023, 2:36pm UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/15 "2023-08-31T14:36:51Z")

</div>

Great, thanks, then I know its doable!

Just have to figure out how…

---

<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:** [August 31, 2023, 2:41pm UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/16 "2023-08-31T14:41:51Z")

</div>

Well, you can always create a php script that reads excel,

> **[GitHub - PHPOffice/PhpSpreadsheet: A pure PHP library for reading and writing...](https://github.com/PHPOffice/PhpSpreadsheet)**
>
> A pure PHP library for reading and writing spreadsheet files - GitHub - PHPOffice/PhpSpreadsheet: A pure PHP library for reading and writing spreadsheet files

And then it’s just an API call to update

---

<div class="post-metadata">

**Author:** ![dirk\_s](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dirk_s/32/748_2.png) [@dirk\_s](https://forum.mautic.org/u/dirk_s)\
**Post date:** [August 31, 2023, 2:45pm UTC](https://forum.mautic.org/t/update-contacts-via-api/29089/17 "2023-08-31T14:45:13Z")

</div>

If you want to regularly sync and update and do some fancy stuff that Mautic can’t do - this might be an idea too for you @CarlJohan

Not directly Excel, but even a bit more I would say. We introduced it at the Mautic Conference together with Tape:

[How to connect Mautic with Tape - 🏗 Showcases & Guides - Tape Community (tapeapp.com)](https://community.tapeapp.com/t/how-to-connect-mautic-with-tape/294)
