Update contacts via API

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?

Sure but first: why not do an import?

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

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

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.

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

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.

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

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.

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 :slight_smile:

Well, Mautic have an API, right?

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.

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.

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.

Great, thanks, then I know its doable!

Just have to figure out how…

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

And then it’s just an API call to update

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 - :building_construction: Showcases & Guides - Tape Community (tapeapp.com)