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 SiteAPI endpoint to retrieve the site'sshortName. - Manually construct the staging domain as
https://shortName.webflow.io, since it's not returned by theList Domainsendpoint.
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 Endpoint:
GET 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
shortNamefrom the response of theGet Siteendpoint. - Combine it with
.webflow.ioto form the staging URL. - For example: If
"shortName": "demo-site", the staging URL will behttps://demo-site.webflow.io.
3. Notes and Considerations
- The
List Domainsendpoint 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.