REST API Payload to create a new contact

Hello,

I am new to mautic and I am trying to leverage the API to programmatically create contacts, but I can not find any documentation on the payload for POSTs. I don’t intent to use the php client, as I will be calling the API from a node code project. I am not interested in the forms option either, as the contacts need to be created server-side.



I have the API working with basic auth and I can successfully create an empty contact (I am receiving a 201 response, and everytime the contact id is increased), but I can not successfully pass the information I need (email, firstname, lastname, ipaddress, etc).

What is the payload format that I should use? Should I send a json payload?



I think it would really help adding a curl example to the API documentation, so everyone using it from a different programming language has a reference.



Thank you in advance,

Marco

Hello,
I am new to mautic and I am trying to leverage the API to programmatically create contacts, but I can not find any documentation on the payload for POSTs. I don’t intent to use the php client, as I will be calling the API from a node code project. I am not interested in the forms option either, as the contacts need to be created server-side.

I have the API working with basic auth and I can successfully create an empty contact (I am receiving a 201 response, and everytime the contact id is increased), but I can not successfully pass the information I need (email, firstname, lastname, ipaddress, etc).
What is the payload format that I should use? Should I send a json payload?

I think it would really help adding a curl example to the API documentation, so everyone using it from a different programming language has a reference.

Thank you in advance,
Marco

Did you try JSON you mention?
Raw payload:

{ "firstname": "Test Name", "email": "email@example.com" }

Thank you Patrykkalinowski, I figured it out. The JSON format is straightforward, exactly as you put in the example. I had tried that, but I was missing the “Content-Type: application/json” header.

Without the header, I got a 201 and an empty contact was created, so I was focusing on the payload format, trying different options and I didn’t notice I was missing the header.

Works like a charm now! Thank you :slight_smile:

HI

I am new to mautic and API world…
can you pl give me HTTP URL API which i can try firing out for my instance ?

Thanks
Ashish