API for submitting forms
S
Saad Ahmad Saddiqui
I want to create my own website using nextjs and style my own form and just submit data to GHL with the API.
Log In
Activity Feed
Sort by
A
Adam Emerson
Relying on the form embeds is not sufficient for developers who wish to offer custom landing pages and websites. We need a documented method on submitting forms via an API.
S
Spencer Grimes
We need this!
J
Jacob Roling
I found this is possible by submitting your form to https://backend.leadconnectorhq.com/forms/submit however whenever I try to submit a form with custom fields I get the response "Unprocessable Entity" and message "property <insert custom field id> should not exist"
Edit: I figured it out through some digging through GHL's Vue code. You can get it to work by stringifying your form data as JSON, creating a new form data object, and appending the stringified JSON to the key "formData" and
posting that to the above endpoint e.g.
const formData = new FormData(event.target)
const body = new FormData();
body.set("formData", JSON.stringify(Object.fromEntries(formData.entries())));
const res = await fetch(
{
method: "POST",
body,
},
);
const result = await res.json();
Note: just make sure that you are using the correct keys when using custom values because they tend to be random strings like "IvYfCvMkhGap6sTe1Uql" whereas fields like email and phone are just "email" and "phone".
S
Saad Ahmad Saddiqui
Jacob Roling Thank you so much Jacob! This is great!
Could I ask where you found this endpoint and if there is any documentation for it?
J
Jacob Roling
Saad Ahmad Saddiqui No worries, I found the endpoint by opening up the form preview, submitting the form and inspecting the network request that was made in the network tab of chrome’s developer tools. As far as documentation goes, unfortunately I couldn’t find any.
C
Carlos Guerrero
Jacob Roling I'm trying to submit, but keep getting the following error:
Authorization failed - please check your credentials
captchaV3 is required.
Have any idea why?
J
Joe Conlin
Did you find a solution for this?
T
Tim Jedrek
Looking for an answer as well. I haven't coded it yet, but my thinking pattern is that we first use the API to update/create a contact
from there, I can get the contact ID and then create a message with the form data, which theoretically will pop up in the conversations.
I was thinking of adding a tag to when a contact is created called "website-form" or something like that but it looks like it's getting deprecated end of the month. Which I don't really understand why they would do that...
So instead, we could add customField to the contacts.. say "source" and then have the value = "website-custom-form-1" or something like that.
At that point, since the form data is in GHL, theoretically from there I should be able to add the workflow automations.
Anyways.. I only need to do this for my legacy websites. Moving forward, it'd probably just be easier (and use less of my server resources) to implement a GHL form.
Or maybe just switch the form to the GHL form and use an iframe to embed. Keep it simple right...
K
Kamron Nelson
Tim Jedrek: Yeah, considering the form embed also. I'm not sure if your solution will still add to the "Activity" tab. I guess the conversation history would be a band-aid. I wonder what they are going to do about the tags...
D
Devon Angle
zapier and pabbly you can do this... webhook the form to pabbly, then use the Leadconnector V2 function to create a new contact. Sync all the fields from the form and the new contact details and boom done
K
Kamron Nelson
Devon Angle: Creating a contact via API is different than a form submission. Form submissions post data to the Activity tab on the Contact and includes the Attributions. When creating a contact using Pabbly/Zapier that information is not logged. Maybe I am missing details in the API when creating a contact? EventDataSchema?
K
Kamron Nelson
Been looking for this option. Would like to have form data as "Form Submission Detail" on the contact activity.
S
Saad Ahmad Saddiqui
An API for Calendar at that too. Preferably something that we can use a secret key for and it fills up any required tracking data for the request automatically. If not, give proper documentation on how we could achieve that.
G
Greg Budrow
I am surprised this is not possilbe
S
Saad Ahmad Saddiqui
Greg Budrow: Right? I am now feeling the need to have a calendar api too. I'm trying to collect info through looking at network tab and just calling it on my own, but surely I'm gonna miss out on a lot of data. Specially tracking data.