Storyblok CLI v4.14.0: Pull and Push Stories and Assets
Storyblok is the first headless CMS that works for developers & marketers alike.
With the latest release of the Storyblok CLI, we introduce powerful new stories and assets commands for pushing and pulling content.
The stories and assets commands enable advanced workflows, such as migrating content from a legacy CMS, transferring stories and assets from one space to another, or quickly making a local backup of your content. Weβre excited to see how you use these features to streamline your custom content workflows.
Migrate content from a third-party CMS
The new push commands make it straightforward to push local stories and assets from third-party CMS data to Storyblok, and the CLI handles mapping ID-based references from legacy CMS data structures to the IDs Storyblok generates.
Example: WordPress migration
The following example demonstrates how to quickly migrate content from WordPress to Storyblok using the CLI.
- Map your external content to the Storyblok story JSON structure.
{ "id": 12345, // source WordPress ID "uuid": 12345, // same as the source ID "name": "Hello WordPress", "slug": "hello-wordpress", "content": { "component": "page", "headline": "Hello from WP", "cta": { "fieldtype": "multilink", "linktype": "story", "id": 12346, // linked WP post ID (same as that story's uuid) "url": "" } } } - Place generated story files under
.storyblok/stories/TARGET_SPACE/{slug}_{ID}.json. - Ensure required components exist locally:
storyblok components pull --space TARGET_SPACE. - Run
storyblok stories push --space TARGET_SPACE(use-dry-runfirst to validate).
This approach allows you to programmatically import legacy data while maintaining relational integrity between your stories.
Space-to-space migrations
If you want to migrate stories and assets from one Storyblok space to another, the new stories and assets commands have you covered as well.
# 1. Pull assets from source space A:
storyblok assets pull --space SPACE_A
# 2. Push assets to target space B:
storyblok assets push --from SPACE_A --space SPACE_B With the commands above, we push all stories from space A to space B while keeping references and links intact.
Bulk updates
Imagine you need to update the alt meta information for an image and also update the meta information in all stories that reference it. Weβve added an --update-stories flag to do exactly this in one command:
storyblok assets push --space SPACE_ID image.png --data='{"id":1234,"meta_data":{"alt":"UPDATED!"}}' --update-stories When pushing a single image, the --data flag enables us to reference the particular asset ID where we want to update the image and the meta_data that we want to update. By default, when updating asset metadata in Storyblok, the metadata of this asset in stories that use it remain unchanged. However, with the --update-stories flag, we can update all stories that reference this asset, too.
Backups
Another use case the stories and assets commands enable is to quickly create a local backup of your content:
storyblok stories pull --space SPACE_ID
storyblok assets pull --space SPACE_ID .storyblok/
βββ assets/
β βββ SPACE/
β βββ folders/
β β βββ images_7ab3783a-c1a1-4330-b87b-9e8f171e9901.json
β β βββ ...
β βββ logo_f1a2b3c4-8c30-46d8-8100-bcc71f34808a.json
β βββ logo_f1a2b3c4-8c30-46d8-8100-bcc71f34808a.png
β βββ ...
βββ stories/
βββ SPACE/
βββ home_be6fe720-8c30-46d8-8100-bcc71f34808a.json
βββ ... Conclusion
Those are only some of the many use cases the new stories pull/push and assets pull/push commands enable. We canβt wait to see what youβll build with this new version of the Storyblok CLI.