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
}
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
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?
Does anyone know if this has been added to the pipeline for next release ?
We are having a similar issue with 4.4.1 running php8.0. trying with endpoint /api/form/submit?formid=9
and receiving the following error code: Requested URL not found: /api/form/submit?formID=9
We are actually using n8n as well however the issue I foresee here is if we pass the form data via web hook and then use a connector to create the new contact inside Mautic we will not have the tracking history on that specific user.
Hi,
I don’t have time to build the exact code, but a HTTP POST request with the right field names should emulate the form submit.
This is something many WP plugins do: