Large-scale site management with Webflow Enterprise APIs

Managing multiple Webflow sites at scale requires consistency, efficiency, and compliance. Webflow Enterprise APIs help you automate site management, streamline workflows, and ensure all your projects stay in sync.

If you’re part of an enterprise team, a large agency, or a developer managing multiple Webflow sites, this guide is for you.

When to use these APIs

  • Deploying multiple sites consistently
    Apply the same settings and templates across all your sites to maintain brand and operational standards.
  • Migrating existing websites to Webflow
    Simplify the migration process by automating configurations and maintaining consistent structures during the transition.
  • Ensuring compliance across sites
    Use the APIs to enforce privacy, SEO, and other compliance-related settings efficiently

What you’ll learn

By the end of this guide, you’ll be able to programmatically:

  1. Set up and manage multiple Webflow sites
  2. Create rules for search engines and set a custom sitemap in robots.txt
  3. Setup 301 redirects
  4. Add .well-known files to your site
  5. Track activity and ensure compliance.

Prerequisites

RequirementDescription
Enterprise WorkspaceReady to scale? Contact us to get started with Webflow Enterprise.
API KeyYou’ll need an API key authorized for an entire Workspace with the following scopes: site_activity:read, site_config:write, workspace:write. Generate your key using our API Playground.
Workspace TemplateUse reusable templates to speed up site creation. Learn how to create a shared Workspace template.
API KnowledgeA basic understanding of RESTful APIs and how to make HTTP requests is required.
  • API Tools: Use tools like Postman to test API requests, or our API Playground on endpoint links.
  • Development Environment: Ensure Node.js is installed if you plan to run scripts. The JavaScript examples provided in this tutorial also demonstrate loops and other logic for programmatic usage.
  • Workspace Access: Confirm that you have permissions to create, modify, and manage sites in your Webflow Workspace.

Tutorial

In this tutorial, we’ll walk through programmatically creating and managing sites in an Enterprise Workspace using the Enterprise APIs. Throughout each workflow, we’ll take actions to ensure the sites are consistent in all aspects of branding, functionality, and compliance.

In this workflow, we’ll create three sites from a Workspace template.

1

Get Workspace information

Start by making a request to the “Authorization Information” endpoint to get your WorkspaceId. This ID will be used to create new sites within the desired Workspace. Save this WorkspaceId for later use.

1const axios = require('axios');
2
3const getWorkspaceId = async () => {
4 try {
5 const response = await axios.get('https://api.webflow.com/v2.0.0-beta/token/introspect', {
6 headers: {
7 'Authorization': 'Bearer YOUR_API_KEY',
8 'Content-Type': 'application/json'
9 }
10 });
11 const WorkspaceId = response.data.authorization.authorizedTo.WorkspaceIds[0];
12 console.log(`Workspace ID: ${WorkspaceId}`);
13 return WorkspaceId;
14 } catch (error) {
15 console.error('Error fetching Workspace ID:', error.response.data);
16 }
17};
2

Get the template name

Navigate to your Workspace settings under the ‘Templates & Libraries’ section to find the templateName you want to use. This will allow you to create sites based on an existing template, ensuring consistency across your sites.

3

Prepare site names

Create an array of the site names you want to use. These names should be unique and descriptive.

1const siteNames = ['The Heart of Gold', 'Milliways - The Restaurant at the End of the Universe', 'Magrathea Site'];
4

Create sites programmatically

Set up a loop to iterate through your array of site names and send a request to the “Create Site” endpoint for each. Save the siteId for each created site for use in future workflows.

Adding sites to folders

Optionally, you can pass a parentFolderId parameter, which allows you to create a site within a Workspace folder. To get this ID, navigate to the Workspace folder in your Dashboard and get the ID that appears after “folder/” in the URL.

1const createSite = async (name, WorkspaceId, templateName) => {
2 try {
3 const response = await axios.post(`https://api.webflow.com/beta/Workspaces/${WorkspaceId}/sites`, {
4 name: name,
5 templateName: templateName
6 }, {
7 headers: {
8 'Authorization': 'Bearer YOUR_API_KEY',
9 'Content-Type': 'application/json'
10 }
11 });
12 const siteId = response.data.id;
13 console.log(`Site created: ${response.data.displayName}, Site ID: ${siteId}`);
14 return siteId;
15 } catch (error) {
16 console.error(`Error creating site ${name}:`, error.response.data);
17 }
18};
19
20const createAllSites = async () => {
21 const WorkspaceId = await getWorkspaceId();
22 const siteIds = [];
23 for (const name of siteNames) {
24 const siteId = await createSite(name, WorkspaceId, templateName);
25 if (siteId) {
26 siteIds.push(siteId);
27 }
28 }
29 console.log('All site IDs:', siteIds);
30};
31
32createAllSites();

As a Workspace Administrator, you can configure each site’s robots.txt file through the “Replace robots.txt” endpoint. This ensures search engines can access the right pages with consistent rules for userAgents, specifying which pages should be crawled and which should not.

1

Prepare rules for each user agent

To ensure consistent SEO behavior across all sites, you should define specific rules for different search engine user agents in the robots.txt file. Below are some example rules:

User-AgentRule TypeRulesReason
GooglebotDisallow/privatePrevent Google from indexing pages containing sensitive customer data or internal admin pages.
Allow/Ensure that all other pages are indexed to maximize site visibility.
BingbotDisallow/testingBlock Bing from indexing pages under development or testing to prevent unfinished content.
Allow/Allow the rest of the website to be indexed for improved reach and visibility on Bing.
All (*)Disallow/scriptsPrevent any search engine from indexing JavaScript files that do not provide useful content.
Disallow/tempTemporary files and pages should not be indexed to avoid clutter in search results.
Allow/Allow general content pages to be indexed to enhance user discovery through various search engines.

These rules help control which parts of your site are accessible to search engines, ensuring the correct balance between visibility and privacy.

2

Apply rules to each site

Now, send a request to the “Replace robots.txt” endpoint to apply these robots.txt rules to each of the newly created sites using the siteIds that were stored earlier. This will ensure that all sites follow the same SEO standards and protect sensitive content effectively.

1const updateRobotsTxt = async (siteId, rules) => {
2 try {
3 const response = await axios.put(`https://api.webflow.com/beta/sites/${siteId}/robots_txt`, {
4 rules: rules
5 }, {
6 headers: {
7 'Authorization': 'Bearer YOUR_API_KEY',
8 'Content-Type': 'application/json'
9 }
10 });
11 console.log(`Updated robots.txt for site: ${siteId}`, response.data);
12 } catch (error) {
13 console.error(`Error updating robots.txt for site ${siteId}:`, error.response.data);
14 }
15};
16
17const robotsRules = [
18 {
19 userAgent: 'googlebot',
20 allows: ['/'],
21 disallows: ['/private']
22 },
23 {
24 userAgent: 'bingbot',
25 allows: ['/'],
26 disallows: ['/testing']
27 },
28 {
29 userAgent: '*',
30 allows: ['/'],
31 disallows: ['/scripts', '/temp']
32 }
33];
34
35const updateAllSites = async (siteIds) => {
36 for (const siteId of siteIds) {
37 await updateRobotsTxt(siteId, robotsRules);
38 }
39};
40
41updateAllSites(siteIds);

Setting up URL redirects is crucial during site migrations or when restructuring a website to maintain SEO and provide a seamless experience for users. Redirects ensure that users and search engines can still access your content even if URLs have changed.

1

Create URL redirects for each site

Send a POST request to the “Create URL Redirect” endpoint to create a single redirect rule. Below is a JavaScript example of how to create redirects programmatically for each site:

1const createRedirect = async (siteId, oldPath, newPath) => {
2 try {
3 const response = await axios.post(`https://api.webflow.com/beta/sites/${siteId}/redirects`, {
4 fromUrl: oldPath,
5 toUrl: newPath
6 }, {
7 headers: {
8 'Authorization': 'Bearer YOUR_API_KEY',
9 'Content-Type': 'application/json'
10 }
11 });
12 console.log(`Redirect created: ${oldPath} -> ${newPath} for site: ${siteId}`, response.data);
13 } catch (error) {
14 console.error(`Error creating redirect for site ${siteId}:`, error.response.data);
15 }
16};
17
18const redirects = [
19 { oldPath: '/old-products-page', newPath: '/new-products-page' },
20 { oldPath: '/contact-us-old', newPath: '/contact-us' }
21];
22
23const createRedirectsForAllSites = async (siteIds) => {
24 for (const siteId of siteIds) {
25 for (const redirect of redirects) {
26 await createRedirect(siteId, redirect.oldPath, redirect.newPath);
27 }
28 }
29};
30
31createRedirectsForAllSites(siteIds);
2

Important considerations for redirects

  • Testing: Always test the redirects after setting them up to ensure they work as intended.
  • Avoid Redirect Chains: Redirect chains (redirects that point to other redirects) can harm SEO and reduce page load speed.
  • Review Regularly: Set up a plan for regularly reviewing redirects to remove outdated rules and avoid bloating.

If your site has a paired Apple app experience, you can ensure seamless integration between your site and your app by uploading well-known files like Apple associated domain files.

1

Identify the well-known file to upload

Determine which well-known file needs to be uploaded. For a site with a paired Apple app, you’ll need to upload an Apple associated domain file (apple-app-site-association). This file helps ensure the app works correctly with your site, such as enabling Universal Links.

2

Upload the well-known file

Use the “Set a Well-Known File” endpoint to upload the well-known file to each site.

1const uploadWellKnownFile = async (siteId, wellKnownFileData) => {
2 try {
3 const response = await axios.put(`https://api.webflow.com/beta/sites/${siteId}/well_known`, wellKnownFileData, {
4 headers: {
5 'Authorization': 'Bearer YOUR_API_KEY',
6 'Content-Type': 'application/json'
7 }
8 });
9 console.log(`Uploaded well-known file for site: ${siteId}`, response.data);
10 } catch (error) {
11 console.error(`Error uploading well-known file for site ${siteId}:`, error.response.data);
12 }
13};
14
15const wellKnownFileData = {
16 applinks: {
17 apps: [],
18 details: [
19 {
20 appID: 'ABCDE12345.com.example.app',
21 paths: ['/*']
22 }
23 ]
24 }
25};
26
27const uploadWellKnownFilesForAllSites = async (siteIds) => {
28 for (const siteId of siteIds) {
29 await uploadWellKnownFile(siteId, wellKnownFileData);
30 }
31};
32
33uploadWellKnownFilesForAllSites(siteIds);
3

Verify the uploaded file

After uploading, verify that the well-known file is accessible at the appropriate URL (e.g., https://yourdomain.com/.well-known/apple-app-site-association). This ensures that the app can properly link with your site and function as expected.

As a Site or Workspace administrator, it’s essential to maintain visibility and control over changes within your environment.

Webflow’s Site Activity log provides comprehensive tracking of important site changes, helping you ensure compliance and monitor for any potential issues. With the Enterprise APIs, you can export these logs to an external monitoring service, allowing you to integrate activity tracking into your broader compliance and auditing processes.

1

Send an API request for Site Activity Logs

Use the “Get Site Activity logs” endpoint to get information on changes made to a site. You could set this up as a scheduled task to run at a regular interval to continuously monitor the activity on your Webflow sites.

1const fetchActivityLogs = async (siteId) => {
2 try {
3 const response = await axios.get(`https://api.webflow.com/beta/sites/${siteId}/activity`, {
4 headers: {
5 'Authorization': 'Bearer YOUR_API_KEY'
6 }
7 });
8 console.log(`Site activity logs for site: ${siteId}`, response.data);
9 } catch (error) {
10 console.error(`Error retrieving activity logs for site ${siteId}:`, error.response.data);
11 }
12};
13
14fetchActivityLogs('YOUR_SITE_ID');
2

Integrate logs with your logging software

Once you retrieve the logs, you could forward them to your existing logging software (such as Datadog, Splunk, or ELK Stack) using an API or webhook. This ensures that Webflow activity is captured alongside other application and infrastructure logs.

3

Set up compliance alerts

Within your logging platform, configure compliance alerts to flag specific activities of interest. Refer to the Site Activity log response schema for a complete list of available resourceOperation and event values you can monitor. Here are some recommended activities to track:

Created operations

Alert TypeDescription
Alert for Resource CreationSet up alerts for the creation of critical resources such as pages, CMS collections, or branches. This is particularly important when managing large projects to avoid unintended content duplication or unauthorized additions.
Frequency AlertIf an unusual number of resources are created in a short time frame (e.g., 10+ pages within an hour), trigger an alert. This could indicate a potential automation error or unintended activity.

Modified operations

Alert TypeDescription
Custom Code ChangesAlert whenever custom code is modified (e.g., page_custom_code_modified, site_custom_code_modified). Such changes can introduce vulnerabilities, impact SEO, or cause user experience issues.
Content Updates MonitoringSet up an alert for large-scale content modifications (e.g., modifications to multiple pages or CMS collections within a short period). This can help detect possible unauthorized changes or mistakes during bulk edits.

Published operations

Alert TypeDescription
Publishing AlertNotify when key pages (e.g., homepage or landing pages) are published. Publishing can have a significant impact on SEO and user visibility, so these events should be monitored closely.

Unpublished operations

Alert TypeDescription
Unpublishing Critical ResourcesTrigger an alert if critical content such as high-traffic pages or important collections are unpublished. This may affect SEO rankings or cause broken user flows.
Track Unpublishing TrendsMonitor for repeated unpublishing actions within a short timeframe to identify potential workflow or publishing errors.

Deleted operations

Alert TypeDescription
Critical Resource Deletion AlertsSet up alerts for deletion events involving important resources like CMS items, branches, or key pages. Resource deletion can be challenging to recover from and should be closely monitored.
Backup VerificationWhenever a DELETE operation is logged, ensure that recent backups are available for recovery if necessary. This can help mitigate data loss risks.

Conclusion

You’ve now gained the skills and knowledge to programmatically set up multiple Webflow sites, apply consistent settings, and monitor site activity to ensure compliance and scalability.

To take the next steps, start experimenting with these APIs in your enterprise projects. Visit our API Reference Documentation to explore additional endpoints and functionality that can help further streamline your workflows.

Additional Resources:

If you encounter challenges or have questions, feel free to reach out to our support team or join the Webflow Developer Community to connect with others working on similar projects.

Was this page helpful?
Built with