Can I disable deploy previews when creating sites using the API?

Can I disable deploy previews when creating sites using the API or I need to change this behavior manually for every site?

Hi, @thidzz. Having research this before, I donā€™t think there is a way to override it on the create site API call but you can disable that setting using the API after the site is created. In other words, it takes two separate API calls (one for create site and one to change the deploy settings) but it can be done 100% using the API alone.

I recommend using the netlify/js-client library or the Netlify CLI (see netlify help api ) to simplify using our API.

If there are other questions about this, please let us know.

1 Like

Nice! Thank you for the answer! I can do this with an ā€œupdateSiteā€ call? I could not find a reference for deploy previews on the docs.

Hereā€™s the call you need to make:

fetch("https://api.netlify.com/api/v1/sites/<site-id>", {
  "headers": {
    "authorization": "Bearer <token>",
    "content-type": "application/json",
  },
  "body": "{\"build_settings\":{\"skip_prs\":true},\"cdp_enabled\":false}",
  "method": "PUT"
})

For future reference, you could simply check the dev tools in UI to see what call it makes.

1 Like

Thank you for the answer! Iā€™m really happy with the support iā€™m having here. It makes a big difference.