# Replacement for legacy Forms API?

**URL:** <https://community.hubspot.com/t/replacement-for-legacy-forms-api/113422>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [July 31, 2024, 7:13pm UTC](https://community.hubspot.com/t/replacement-for-legacy-forms-api/113422 "2024-07-31T19:13:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Extreme](https://avatars.discourse-cdn.com/v4/letter/e/34f0e0/32.png) [@Extreme](https://community.hubspot.com/u/Extreme)\
**Post date:** [July 31, 2024, 7:13pm UTC](https://community.hubspot.com/t/replacement-for-legacy-forms-api/113422/1 "2024-07-31T19:13:58Z")

</div>

Hi,

We’re logging some GA4 events to the dataLayer when a form is submitted using the forms API guide here: [https://legacydocs.hubspot.com/docs/methods/forms/advanced\_form\_options](https://legacydocs.hubspot.com/docs/methods/forms/advanced_form_options)

Like so:

```lia-code-sample
window.hbspt.forms.create({
 // ...
 onFormSubmitted: () => {
 window.dataLayer = window.dataLayer || [];
 window.dataLayer.push({
 // ...
 });
 },
});

```

I noticed though that this is a legacy API, is it therefore deprecated and likely to removed in the future?

If so, is there a replacement for this API, or a suitable method to log events like this? I couldn’t find anything in the newer docs

Thanks

---

<div class="post-metadata">

**Author:** ![KenF](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kenf/32/78421_2.png) [@KenF](https://community.hubspot.com/u/KenF)\
**Post date:** [July 31, 2024, 11:51pm UTC](https://community.hubspot.com/t/replacement-for-legacy-forms-api/113422/2 "2024-07-31T23:51:21Z")

</div>

Here’s a link to the latest Forms API v3. Although it says it’s currently in development, it is the most current method to create a form through the Hubspot API.

> **[Accounts Dashboard | HubSpot](https://app.hubspot.com/myaccounts?next=developerdocs&redirect=%2Freference%2Fapi%2Fmarketing%2Fforms)**

Example:

`const FormDefinitionCreateRequestBase = { formType: "hubspot", name: "string", createdAt: "2024-07-31T23:46:17.606Z", updatedAt: "2024-07-31T23:46:17.606Z", archived: true, archivedAt: "2024-07-31T23:46:17.606Z", fieldGroups: [{"groupType":"default_group","richTextType":"text","richText":"string","fields":[]}], configuration, displayOptions, legalConsentOptions };const apiResponse = await hubspotClient.marketing.forms.formsApi.create(FormDefinitionCreateRequestBase);`

---

<div class="post-metadata">

**Author:** ![Extreme](https://avatars.discourse-cdn.com/v4/letter/e/34f0e0/32.png) [@Extreme](https://community.hubspot.com/u/Extreme)\
**Post date:** [August 1, 2024, 5:18pm UTC](https://community.hubspot.com/t/replacement-for-legacy-forms-api/113422/3 "2024-08-01T17:18:32Z")

</div>

Thanks @KenF , I’m not actually trying to create a form though - just set some options when its rendered.

There doesn’t seem to be any equivolent for the article I linked in the new documentation 🤔

---

<div class="post-metadata">

**Author:** ![KenF](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kenf/32/78421_2.png) [@KenF](https://community.hubspot.com/u/KenF)\
**Post date:** [August 1, 2024, 5:51pm UTC](https://community.hubspot.com/t/replacement-for-legacy-forms-api/113422/4 "2024-08-01T17:51:10Z")

</div>

Ahh I see, you’re right there isn’t anything in the current Forms API that captures the submit event.

Hopefully they will come out with some new Form event handling before they do any deprecation of the legacy Form API.
