Mautic Community Forums

Feature Request - Form submission via API / webhook

Feature Request - Form submission via API / webhook

Request is to enhance the API to support form submissions.

We manage alot of our integrations now via middleware software for websites such as Zapier or Integromat, we are missing a feature to be able to submit a form via these methods.

Currently we are having to submit upsert contacts with new tags which will then trigger to be submitted into a campaign.
There are a lot of features we are missing as a result of this, and we really need to use the forms if we are to do this successfully.

Officially we could submit it to the frontend form, but the requirements for serializing the data makes this a very complex task and very difficult to maintain via these middleware platforms.

Your software
My Mautic version is: 2.16.2
My PHP version is: 7.2

Your problem
My problem is: I am trying to Post form data using api through postman, I am using basic auth.

POST https://<my_mautic>/api/form/submit?formId=2

Body
{
“email”: “naveen@gmail.com”,
“firstname”: “naveen”
}

(It may be noted that api to create contact https://<my_mautic>/api/contacts/new is working fine)

These errors are showing in the log:
{

"errors": [

    {

        "message": "Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator!",

        "code": 404,

        "type": null

    }

],

"error": {

    "message": "Looks like I encountered an error (error #404). If I do it again, please report me to the system administrator! (`error` is deprecated as of 2.6.0 and will be removed in 3.0. Use the `errors` array instead.)",

    "code": 404

}

}

Steps I have tried to fix the problem:

Just a quick comment: after allowing basic auth, you need to clear the cache.

@joeyk Thanks for the reply.

I tried after clearing cache, but same problem still.

I am also interested in submitting a form thru the api, but I could not found the documentation for this end point, someone can post a link for me?

I could send a post request to

/form/submit?formId=XX

but in that case I would have to send a application/x-www-form-urlencoded content instead of JSON and parse the html response, by submitting thru an API I want to send json content and receive the json response to handle the response my way.

is it possible? I could not find the documentation for the end point mention in this post:
/api/form/submit?formId=xxx

  • Merged multiple topics into one /EG -

@tornmarketing I know it’s not the full thing but did you happen to look at

and
The simplest way how to submit a form data to Mautic | by John Linhart | Medium ?

Requires hosted code to run your submissions through, we are pulling form submissions from multiple 3rd party sources with webhooks already in place that hit and run through middleware (Zapier / Integromat).

This solution is just not suitable, and it would be far more logical for an API post so that all the logic is consistent. Mautic already has API connections and apps for all the major functions, just no clean way to submit a form which seems really silly.

Currently, we have to update a contact with a tag, then configure a campaign with a segment on that tag, then at the end of the campaign remove the tag to allow resubmission.

That action also requires us to call on a segment refresh, campaign refresh and trigger.

If it was via a form, all of this would become redundant and would simplify things 1000%.

sure, understood. As we are currently in a similar situation, we are considering using self-hosted n8n (rather than Zapier etc.) and hook the form submission code into that.

The way better option would obviously be to have the API, so… some research first.
→ What I am currently trying to find out is why it still doesn’t exist, why it has not been implemented from day one! Just an oversight? Or some nasty architectural challenges?

P.S. Turns out it was just not considered necessary at the time, so it should be straight-forward to add the API