Get started with the Webflow Pulumi Provider in Python. Deploy your first Webflow resource (RobotsTxt) in under 10 minutes.
- Pulumi CLI - Install
- Python - Install Python 3.8 or later
- pip - Comes with Python
- Webflow account - With API access enabled
- Webflow API token - Create one in Account Settings > API Tokens
- Webflow Site ID - Find in Webflow Designer > Project Settings > API & Webhooks
# Create a virtual environment (recommended)
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtThis installs:
pulumi- Pulumi SDKpulumi-webflow- Webflow provider
# Set your Webflow API token (encrypted in Pulumi.dev.yaml)
pulumi config set webflow:apiToken --secret
# When prompted, paste your Webflow API token and press Enter# Set your Webflow Site ID
pulumi config set siteId --secret
# When prompted, paste your 24-character site ID and press EnterNeed your Site ID?
- Open Webflow Designer
- Go to Project Settings → API & Webhooks
- Copy your Site ID (24-character hex string like
5f0c8c9e1c9d440000e8d8c3)
# Create a dev stack
pulumi stack init dev
# Or select existing stack
pulumi stack select dev# Preview what will be created
pulumi preview
# Deploy to your Webflow site
pulumi up
# When prompted, select 'yes' to confirmExpected output:
Previewing update (dev):
Type Name Plan
+ webflow:RobotsTxt my-robots create
Resources:
+ 1 to create
Do you want to perform this update? yes
Type Name Plan Status
+ webflow:RobotsTxt my-robots create created
Outputs:
deployed_site_id: "5f0c8c9e1c9d440000e8d8c3"
robots_txt_id: "xyz123"
Resources:
+ 1 created
Duration: 3s
- Open Webflow Designer
- Go to Project Settings → SEO → robots.txt
- You should see the robots.txt content you deployed!
The main program is in __main__.py:
import pulumi
import pulumi_webflow as webflow
config = pulumi.Config()
site_id = config.require_secret("siteId")
# Create a RobotsTxt resource
robots_txt = webflow.RobotsTxt(
"my-robots",
site_id=site_id,
content="""User-agent: *
Allow: /""",
)
pulumi.export("deployed_site_id", site_id)Change the robots.txt content:
Edit the content parameter in __main__.py:
robots_txt = webflow.RobotsTxt(
"my-robots",
site_id=site_id,
content="""User-agent: *
Disallow: /admin/
Allow: /public/""",
)Then deploy:
pulumi upDeploy to a different site:
# Update the site ID
pulumi config set siteId --secret
# Paste your new site ID
# Deploy to the new site
pulumi upRemove the resource from Webflow:
pulumi destroy
# When prompted, select 'yes' to confirmThis removes the RobotsTxt resource from your Webflow site.
It's recommended to use Python virtual environments to isolate dependencies:
# Create virtual environment
python3 -m venv venv
# Activate it
source venv/bin/activate # Linux/macOS
# or
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# When done, deactivate
deactivateError: Unauthorized - Invalid or expired Webflow API token
Solution:
- Verify your token in Webflow Account Settings > API Tokens
- Update your Pulumi config:
pulumi config set webflow:apiToken --secret
Error: Invalid or malformed siteId
Solution:
- Get the correct site ID from Webflow Designer > Project Settings > API & Webhooks
- Update your Pulumi config:
pulumi config set siteId --secret
Error: Plugin webflow not found
Solution:
pulumi plugin install resource webflowModuleNotFoundError: No module named 'pulumi_webflow'
Solution:
# Make sure you've activated your virtual environment
source venv/bin/activate
# Reinstall dependencies
pip install -r requirements.txt- Explore other resource types (Redirects, Sites, etc.)
- Check the main README for comprehensive documentation
- View other examples in the examples/ folder
- Learn Pulumi concepts at pulumi.com/docs
__main__.py- Main Pulumi programPulumi.yaml- Project configurationrequirements.txt- Python dependencies.gitignore- Files to exclude from GitREADME.md- This file