Forms: delete a form through the Netlify API

Hi all,

we are working on improving forms deletion and are pleased to let you know you are now able to delete forms (we are referring here to the actual forms, not form submissions) through the API. You now no longer have to ask a Support Engineer to delete your form for you!

Make an authenticated DELETE request to https://api.netlify.com/api/v1/sites/YOUR_SITE_ID/forms/YOUR_FORM_ID to delete a form and all its submissions. (You can also use the form name instead of the ID if you prefer). Please note that this will delete all existing submissions to the form, and future submissions to the form will result in a 404 error.

See also https://open-api.netlify.com/#operation/deleteSiteForm.

Please leave any problems you encounter below. We hope to add a UI button for this in the future and will update you when we do.

5 Likes

An example of how to do this using curl:

  1. create a personal auth token at https://app.netlify.com/user/applications#personal-access-tokens
  2. SAVE THAT TOKEN! There is no way to get it back if you don’t copy it from the creation page. (but, it’s free to make more if you do lose it :)). Please be aware that this token is like your password - gives FULL ACCESS TO ALL YOUR NETLIFY SITES AND TEAMS - so NEVER post it publicly here or anywhere!
  3. find your Site ID through the admin UI - it’s on the “General Settings” page for the site (last navigation entry above the white parts of the page, on the right hand side as of this writing)
  4. find your form’s ID through the admin UI - start on the site in question, select the “Forms” navigation link at the top of the page, click into the form you want to delete, and grab the identifier off the end of the URL. It will look something like 5b69cb61e470854baea3c3e8
  5. confirm that you have exported ANY data you need from submissions, as the next step WILL REMOVE ALL SUBMISSION DATA PERMANENTLY AND IRRETRIEVABLY
  6. now you’re ready!

curl -H "Authorization: Bearer YOUR_API_TOKEN_GOES HERE" -X DELETE https://api.netlify.com/api/v1/sites/YOUR_SITE_ID/forms/YOUR_FORM_ID

If you have trouble with this, let us know in the comments below but again please do NOT post your API token in any debugging output (but your site + form ID, plus the response from curl, WOULD be useful details :))

2 Likes

Thank you fool, it works

Let’s instead thank @benaiah who wrote the code that does the heavy lifting :wink: But thank you so much for confirming that the instructions were good enough for you to follow!