16# Optional: Webhook secret for validating Storyblok webhooks
17STORYBLOK_WEBHOOK_SECRET=your_webhook_secret
Configuration Options
Option
Type
Required
Default
Description
โ
-
Storyblok Access Token for Content Delivery API (read-only)
โ
-
Personal Access Token for Management API (write access)
โ
-
Your Storyblok Space ID
โ
-
Storyblok region of your space
โ
-
Folder ID where product stories will be created
โ
-
Folder name (usually "products")
โ
Version of stories to fetch
โ
-
Secret for validating Storyblok webhooks
โ
Delete Medusa product when Storyblok story is deleted
โ
-
Image optimization settings
โ
Target image width in pixels
โ
Image quality (1-100)
โ
-
Custom function to transform image URLs
Why Two Access Tokens?
Access Token ():
Used for reading content from Storyblok (Content Delivery API)
Read-only access
Found in: Storyblok โ Settings โ Access Tokens
Personal Access Token ():
Used for creating, updating, and deleting stories (Management API)
Required to grant write access for syncing products
How to get it:
Go to your Storyblok account (top-right corner)
Click on "My Account"
Go to "Account Settings"
Navigate to "Personal Access Tokens"
Create a new token with appropriate permissions
Important: Make sure you are working with the correct , since the PAT grants write access to all of your Storyblok spaces.
Storyblok Setup
1. Create a Products Folder
In Storyblok, go to the Content tab and create a folder where all product stories will be stored (e.g., "products")
Open the folder and note the Folder ID from the URL:
Use this ID for in your configuration
Use the name of the folder for
2. Create Required Bloks
Gallery Image Blok
Create a blok named with the following fields:
Field Name
Type
Required
Description
Asset (Image)
โ
The image asset
Boolean
โ
Whether this image is the thumbnail
Product Variant Blok
Create a blok named with the following fields:
Field Name
Type
Required
Description
Text
โ
Variant title/name
Text
โ
Medusa variant ID (for syncing)
Blocks
โ
Gallery of images (accepts blok)
Product Content Type
Create a content type named with the following fields:
Field Name
Type
Required
Description
Text
โ
Medusa product ID (for syncing)
Text
โ
Product title/name
Blocks
โ
Product image gallery (accepts blok)
Blocks
โ
Product variants (accepts blok)
Note: You can add any additional fields you need for your content management (description, SEO fields, custom attributes, etc.)
3. Configure Webhooks (Optional but Recommended)
To enable bi-directional sync (Storyblok โ Medusa), set up webhooks:
Go to Storyblok โ Settings โ Webhooks
Create webhooks with the following URLs (replace with your backend URL):
Select the appropriate events:
Story published (for update webhook)
Story deleted (for delete webhook)
Note: The webhook secret is passed as a query parameter in the URL
Admin UI
The plugin provides a comprehensive admin UI for managing product synchronization with Storyblok.
Product Page Widget
On each product detail page in Medusa Admin, you'll see a Storyblok widget with:
When Product is Synced:
๐ข Green "Synced" status badge
"Open in Storyblok" button - Opens the product story in Storyblok (new tab)
When Product is Not Synced:
๐ด Red "Not Synced" status badge
"Sync to Storyblok" button - Creates the story in Storyblok with all variants and images
Storyblok Management Page
Access via Medusa Admin sidebar โ "Storyblok"
This dedicated page shows all your Medusa products with their sync status:
Features:
Product List - View all products with sync status
Individual Sync - Each row has a "Sync" or "Open in Storyblok" button
Bulk Selection - Checkboxes to select multiple products
Sync Selected - Sync only checked products
Sync All - Bulk sync all products at once
Status Indicators:
๐ข Synced - Product exists in Storyblok, shows "Open in Storyblok" button
๐ด Not Synced - Product doesn't exist in Storyblok, shows "Sync" button
How It Works
Medusa โ Storyblok Sync
1. Product Creation
When a product is created in Medusa:
โ A new story is created in Storyblok with the product data
โ A dedicated asset folder is created (named after product slug)
โ Product thumbnail is uploaded to the folder
โ All product images are uploaded to the folder
โ Images are added to the product's gallery with proper thumbnail marking
โ Product variants are NOT created automatically (see below)
2. Product Update
When a product is updated in Medusa:
โ Only the product handle (slug) is synced to Storyblok
โ Other fields (title, images, etc.) are NOT synced from Medusa to Storyblok
Important: Once a product is synced to Storyblok, content management should happen in Storyblok. Updates will sync back to Medusa via webhooks.
3. Product Deletion
When a product is deleted in Medusa:
โ The Storyblok story is deleted
โ The product's asset folder is deleted
โ All images in the folder are deleted
โ Complete cleanup - no orphaned assets
4. Variant Creation
When a variant is created in Medusa:
โ Variant is added to the product story in Storyblok
โ Variant thumbnail is uploaded (if exists)
โ Variant images are uploaded to the product's folder
โ Images are added to the variant's gallery
Important: When a new product is created, the plugin will automatically also create its default variant (or the multiple variants you have added during creation), and it will upload the images added to the product or variants during creation
5. Variant Deletion
When a variant is deleted in Medusa:
โ The variant is removed from the product story in Storyblok
โ ๏ธ Associated images remain in the folder (may be used by product or other variants)
Storyblok โ Medusa Sync
When a product story is published in Storyblok:
โ Product handle is synced back to Medusa
โ Product thumbnail URL is synced to Medusa
โ Product images are synced to Medusa
โ Variant thumbnails are synced to Medusa
โ Image URLs point to optimized Storyblok CDN URLs
This enables your storefront to use Storyblok's CDN for images without additional fetches.
Image Management
Smart Deduplication
The plugin intelligently handles image uploads:
โ Checks if an image already exists in the folder before uploading
โ Reuses existing assets when the same image is used across variants
โ Prevents duplicate uploads when variants share product images
โ Case-insensitive filename matching
Folder Organization
Each product gets its own asset folder:
Image Optimization
Images served from Storyblok are automatically optimized:
Configurable width and quality
Automatic WebP conversion
CDN delivery
Custom transformation functions supported
Troubleshooting
Products not syncing
Check that all required environment variables are set
Verify your Personal Access Token has write permissions
Check Medusa logs for error messages
Ensure the products parent folder exists in Storyblok
Images not uploading
Verify product images have valid URLs
Check that the asset folder exists (created automatically)
Review Storyblok asset limits for your plan
Check Medusa logs for upload errors
Webhooks not working
Verify webhook URL is publicly accessible
Check webhook secret matches in both Storyblok and Medusa config
Review webhook logs in Storyblok dashboard
Ensure webhook events are configured correctly
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
MIT
Support
For issues and questions:
Discord Community: Join our Discord - Get help, share feedback, and connect with other users