7
votes

Scenario: A new branch is created and desired code changes applied. The branch is later deployed to Netlify with a custom (Branch) URL. After testing, pull request is made and a deploy-preview is also deployed on Netlify with another custom URL. Then, merge request is approved and successfully merged the branch is fully deleted.

Consequences: However, even then the deploy-preview and branch-deploy specific deploys remain up and published.

Question:

  • How does one remove (purge) branch-specific deploy from Netlify?
  • Bonus: How does one remove (purge) deploy-preview deploy from Netlify?
2
Although the information to delete a site is good information, it does not answer your question correctly. "How to delete Netlify deployed branch". Marking that as the correct answer is going to confuse someone. - talves
I'm not sure if I get you right. It does answer the question, it provides an option to delete it. Each deployment has a unique ID, thus with an API call, you can remove it. - Lukas
Yes, the API calls will allow you to permanently delete a (WHOLE) site. I have not seen a documented API endpoint for deleting a specific deploy. That is the specific question you asked above. I was to believe by your comments in my answer that you were trying to delete specific branch deploys so they would not be crawled, but leave the production deploy still working. - talves
You were right. I mistook siteId for deployId. I have tested myself and the given Endpoint is specifically for the whole site. Thank you for bringing this up! - Lukas
Yeah, I think I will put in an issue to see if a feature can be added to delete the deploy using the ID the same as a site. Thanks for understanding and confirming yourself. - talves

2 Answers

7
votes

Currently (04/16/2018) there is not a documented method to delete a specific deploy on Netlify. There are methods to stop a branch from being seen (see notes) that you can implement s part of your build workflow.

Contact support to have something sensitive removed.

NOTE:

  • Netlify adds an HTTP header x-robots-tag: noindex to the response headers on all Deploy Previews (built for a Pull Request), so those won't be indexed.
  • You can password protect branch deploys by selectively following: https://www.netlify.com/blog/2017/04/07/selective-password-protection/
    Note that it requires planning; you have to set this up before you deploy:
2
votes

As of now only Netlify support can help to remove the deployed and published branch and it's created netlify domain.

Here you can see Netlify Support Engineer's comment in Netlify community. https://community.netlify.com/t/how-to-delete-branch-deploy/838/13