How to enable asset optimization?

Hi,

I’m creating site using Netlify API with curl with following options :
{“name”:“Dynamic 01”,“force_ssl”:false,“prerender”:“netlify”,“processing_settings”:{“skip”:false,“css”:{“bundle”:true,“minify”:true},“js”:{“bundle”:true,“minify”:true},“html”:{“pretty_urls”:true,“canonical_urls”:true},“images”:{“optimize”:true}}}

Site is well created, all options are enabled as expected, but checkbox “Disable asset optimization” is checked. Could you tell me how can I unchecked it please?

Thanks.

Hi @m3ways

Welcome to the forums :netliconfetti:

With an existing site, I was able to modify the asset optimisation settings (processing_settings in the API) using updateSite e.g

curl -X PATCH \
     -H "Authorization: Bearer API_TOKEN" \
     -H 'User-Agent: API_ID' \
     -H 'Content-Type: application/json' \
     -d '{"processing_settings": {"skip": false}}' \
     https://api.netlify.com/api/v1/sites/API_ID

Viewing the settings in the Netlify UI then shows

2 Likes

Hi,

Thanks for your welcome and your answer!

It works with updateSite but I would make it work with createSite. Isn’t it possible?
I think it should work as attributes are mentionned in createSite documentation, no?

I agree @m3ways, it certainly mentions the post processing under createSite, however like you, posting the same data sent to updateSite does not enable the settings, e.g.

{
  "processing_settings": {
    "skip": false
  }
}

I don’t know if other data is required as to enable this with createSite or if I (you/we) are doing something not-quite-right, or if there is an issue with how the API is interpreting the data.

I will endeavour to get an answer from someone more in the know.

1 Like

Thanks for flagging this for the Support Team, @coelmay. I have shared this with our Support Engineers! We will circle back once we have more info, @m3ways :slight_smile:

2 Likes

Hi, @m3ways. My experience with the createSite API endpoint has proven to me that not all options are parsed by the API. It appears that both you and @coelmay are seeing the same.

The API will accept some settings at site creation time but many settings will not be processed. Those site settings must then be changed using the updateSite endpoint.

To summarize, it won’t always be possible to configure all settings with createSite and two API calls (one to createSite and one to updateSite) will be required for specific settings.

I can enter a feature request for all settings to be configurable with createSite but I cannot say if that will become available or not. In the meantime, the workaround is to call both createSite and updateSite to change those settings.

2 Likes

Thanks for the clarification @luke.

I see no issue in having to make a call to updateSite to configure options not available during createSite.

I would like to only see those options explicitly available listed under the “Request Body Schema”.

1 Like

@luke thanks for your answer!

@coelmay I agree with you for clarification in documentation.

So, I will use updateSite after createSite.

Thanks for your time!