Site publish via API to both Staging and Production domains

Hello,

We have a problem with publishing a site via API command ‘Publish site’.

We read the domains associated with a site using the ‘List domains’ command. Then, we use these names as the parameter of ‘Publish site’. However, this command returns only the names of the custom domains - not the WF’s staging domain.

What is the best way to obtain the staging domain’s URL, please?

It seems that if we use the ‘Get site’ command, one of the fields it returns is called ‘short name’ which seems to be the variable part in the staging domain’s URL (https://[short name].webflow.io). If this is always true, we could reconstruct the staging URL this way. However, it seems like a clumsy and perhaps uncertain way…

Thanks for any tips!
Pataka

1 Like

Having the same problem!

Yes, the staging site is always shortname.webflow.io.
However I’ve not tried publishing only the staging site through the API-
And the current behavior I think is that if you publish to any custom domain, staging will always be published to as well.

Even though the domains list is indicated as required, have you tried not supplying one, or supplying an empty array? It might publish to staging only.

Hi @memetican and @Graffiki ,
Thanks for replying (and sorry for my not noticing…:roll_eyes:)!

In our experience, publishing to the custom domains via API does NOT publish to the staging automatically.

Here is why we find publishing always to ALL domains crucial. We have observed that ‘Publish site’ overrides the current settings of ‘Choose publish destination’ specified in the Designer.

This is what happens:

  1. In the Designer, all publish destinations are selected, including the staging.

  2. We insert or update products via API. Products are correctly inserted/updated (result #200).

  3. We read domains using ‘List domains’, receiving only the names of the custom domains.

  4. We publish the site using ‘Publish site’, with only custom domains as parameters. The new products appear on the live custom domains. All good so far.

  5. The site does not get published to the staging domain and also the ‘Choose publish destination’ settings are changed to ‘custom domains only’.

  6. We repeat the process the next day. However, inserting new products does NOT work this time, returning the error #400 (‘Site is published to multiple domains at different times’) - because when the publishing options of the site are ‘split’ (i.e. not all domains are selected in the Designer), API has a trouble with it, apparently.

  7. No product updates are carried out ever since, until all publish domains are selected again manually in the Designer. NOT GOOD, obviously…

That’s why it seems the only way to keep publishing consistent is to ‘reconstruct’ the staging URL (shortname.webflow.io, as you say) and include it in Publish site.

As a side note, the way Webflow API deals with product inserts/updates, not allowing pushing these changes live without a global site publish, is unfortunate, in my opinion. While automatic product updates may be happening on the background daily, it is not always desirable to publish the whole site, including possible work in progress in the Designer.

But perhaps somebody has found a better process to update products…?
Thank you!