Netlify Forms – enable form detection through API

Hi,

It seems something has changed recently with the way newly created sites deal with Netlify forms.

I’m creating sites through the API, and I noticed ‘Form detection’ is disabled by default. I need to manually go to the UI to enable it, redeploy, and only then it detects my forms.

How can I change this? Is there a property in the Netlify API I can send to enable forms whenever I create/update a site?

Hi @nvdb31, welcome and thanks for the post.
Based on the API documentation links below you cannot enable form detection via the API. You have to manually go to the UI to enable it.

Thanks.

That’s not true, @clarnx. Almost everything done by UI is basically something that can be handled by API. The relevant payload would be:

{
  "processing_settings": {
    "ignore_html_forms": false
  }
}

updateSite should work: Netlify API documentation

1 Like

Thank you so much @hrishikesh! That seemed to work. :slight_smile:

@hrishikesh, thanks for the correction.
However I honestly feel the Netlify Open API documentation needs an update as it’s very difficult to find information.
Most of the parameters are not explained and you can’t tell what it does.

Even the option "ignore_html_forms": false you provided is not available in the documentation. Correct me if I am wrong as I have searched the whole documentation.

I have raised it internally once or twice regarding the Open API spec being incomplete, but as far as I know there’s just not enough motivation and bandwidth to keep it up-to-date. I could be wrong though. This is why our most relevant guideline says, reverse-engineer the API endpoint by checking our UI: [Support Guide] Understanding and using Netlify’s API - Support / Support Guides - Netlify Support Forums

1 Like

Hi hrishikesh

I’d love to also confirm some extra details about this with regards to the netlify.toml file.
I know I could do this via the API and have written a script for that, but it would be more seamless if ignore_html_forms = false could be supplied via the netlify.toml file in the repo, or even for deploy previews from pull request.

I just haven’t worked out exactly how, yet.

One example I tried is this:

[build]
  publish = "dist/"
  command = "npm run build"

  [build.processing]
    ignore_html_forms = false

I can see in the deploy preview and when merged, the production deploy, both of these detect the form and begin to collect submitted form data.
However, the Netlify UI says the following:

Form detection is disabled. To continue using Netlify Forms, re‑enable form detection and redeploy your site.

The form submissions are being collected, but the warning above is also shown.
It’s alsmost as though the example netlify.toml I gave above half works but some other setting is missing?

The UI will read the data from the database and the database will mark the form detection as disabled. It’s the same as enabling asset optimization from netlify.toml BUT leaving it disabled in the UI. The TOML doesn’t change our database, so the UI won’t necessarily reflect that.