How can we obtain the staging domain's URL when using the Webflow API command 'Publish site' and the 'List domains' command only returns custom domain names?

TL;DR
  • Use the Get Site API endpoint to retrieve the site's shortName.  
  • Manually construct the staging domain as https://shortName.webflow.io, since it's not returned by the List Domains endpoint.

The Webflow API's 'Publish Site' and 'List Domains' commands do not directly return the default staging domain (e.g., your-site.webflow.io). However, you can determine the staging domain using the site information available with another API call.

1. Use the ‘Get Site’ Endpoint

  • API EndpointGET https://api.webflow.com/sites/{site_id}
  • This endpoint provides metadata about the site, including the site name, which forms the basis of the Webflow staging domain.
  • The staging domain format is always site_name.webflow.io.

2. Construct the Staging Domain Manually

  • Take the value of shortName from the response of the Get Site endpoint.
  • Combine it with .webflow.io to form the staging URL.
  • For example: If "shortName": "demo-site", the staging URL will be https://demo-site.webflow.io.

3. Notes and Considerations

  • The List Domains endpoint only returns custom domains added in the Webflow Designer or site settings.
  • The Webflow staging domain is not treated as a “custom domain”, so it is not included in this list.
  • Ensure you're using the correct Authorization headers and API version when making requests to avoid 401 or 403 errors.

Summary

Use the Get Site API endpoint to retrieve the shortName of the project, and manually construct the staging domain as shortName.webflow.io. The Webflow API does not return this domain in the List Domains endpoint.

Rate this answer

Other Webflow Questions