Almost EVERYONE who tried headless systems said they saw benefits. Download the state of CMS now!

O’Reilly Report: Decoupled Applications and Composable Web Architectures - Download Now

Empower your teams & get a 582% ROI: See Storyblok's CMS in action

Skip to main content

Storyblok Command Line Interface

Storyblok provides an official CLI for quickly scaffolding ambitious web projects.

Installation

        
      npm i storyblok -g
    

Section titled Commands Commands

Section titled undefinedLogin undefinedLogin

Sign into your account via the following command:

        
      storyblok login
    

Section titled Logout Logout

Sign out of your account with the following command:

        
      storyblok logout
    
hint:

if you encounter a 404 by executing any Storyblok CLI commands, logout & login again will help.

Section titled Select Select

Use select to kickstart a boilerplate, fieldtype, or theme.

        
      storyblok select 
    

After running the command, you will be prompted to name your new project, and select the type of project it will be:

TypeDescription
ThemeThis will prompt you to select pre-rendered themes that Storyblok has made. After selecting a theme, you will be prompted to type in your space ID so that the project can be tied to a space on Storyblok. Then, it will ask you for your domain URL and theme token. Finally, it will git-clone the repository for you with all your information pre-populated.
Boilerplate This will bring up a selection of boilerplates that can be used with your coding language of choice: JavaScript (Node.js and Vue.js), Python (Django), Ruby (Sinatra), and PHP (Silex). Then, the GitHub repo for the boilerplate of choice will be cloned. After, you will be prompted to type in your space ID so that the project can be tied to a space on Storyblok.
FieldtypeThis will automatically git-clone our fieldtype repo.

Download your space's components schema as json

The following command allows you to save your components schemas somewhere save (git, svn) and also allows you to migrate components between different spaces. Download your components json:

storyblok pull-components --space <SPACE_ID>

Use your Space ID to access this feature.
To access your space id go to {1} Settings, then {2} Space. Your {3} Space ID should be displayed.

1
2
3

Push your components file to your/another space

To push your downloaded components schema to another space you can execute the following command. Make sure to pass the right path/url of your components file you've downloaded as last parameter:

storyblok push-components --space <DEST_SPACE_ID> {{path/url}}

Section titled sync sync

You can sync components, folder, roles, datasources or stories between spaces.

        
      storyblok sync --type <COMMAND> --source <SPACE_ID> --target <SPACE_ID> 
    
OptionsDescription
typedescribe the command type to execute. Can be folders, components, stories, datasources or roles. It's possible pass multiple types separated by comma (,).
sourcethe source space to use to sync
targetthe target space to use to sync
regionyour space region (default: eu). If your space was created under the US region, you should use us instead. In general you can use one of the available region (Europe, US, Canada, Australia end China). More info about the region: https://www.storyblok.com/faq/define-specific-region-storyblok-api.
IMPORTANT:

Please note that it is currently not possible to use the CLI to synchronize information between spaces in different regions.

        
      /* Sync components from `00001` space to `00002` space */
storyblok sync --type components --source 00001 --target 00002

/* Sync components and stories from `00001` space to `00002` space */
storyblok sync --type components,stories --source 00001 --target 00002
    
hint:

You can sync multiple spaces! Tutorial: Setting Up Multiple Spaces with Storyblok CLI

Section titled quickstart quickstart

Create a space in Storyblok and select the boilerplate to use

        
      storyblok quickstart
    

Section titled spaces spaces

List all the spaces of the currently logged-in account

        
      storyblok spaces
    

Section titled import import

Imports flat content from .csv, .xml and .json files coming from other systems.

The attributes path and title are required.

        
      storyblok import --file <FILE_NAME> --type <TYPE_OF_CONTENT> --folder <FOLDER_ID> --delimiter <DELIMITER_TO_CSV_FILES> --space <SPACE_ID>
    
OptionsDescription
filename of the file
typename of the content type you want to use for the import
space ID number of your space
delimiter (optional)delimiter of the .cvs files, only necessary if you are uploading a csv file (Default value is ; )
folder (optional)id of the folder where you want to store the content in Storyblok

Section titled help help

For global help

        
      storyblok --help
    

For command help

        
      storyblok sync --help
    

Section titled version version

To check your current version of the Storyblok CLI

        
      storyblok -V 
/* or --version */
    

Section titled Migrations Migrations

Section titled generate-migration generate-migration

Create a migration file (with the name change_<COMPONENT>_<FIELD>.js) inside the migrations folder.

        
      storyblok generate-migration --space <SPACE_ID> --component <COMPONENT_NAME> --field <FIELD>
    
OptionsDescription
spacethe space of where the component is
componentcomponent name
fieldname of field

Section titled run-migration run-migration

Execute a specific migration file.

        
      storyblok run-migration --space <SPACE_ID> --component <COMPONENT_NAME> --field <FIELD> --dryrun
    
Option:

You can provide the publish parameter to publish content after saving.

Example:

        
      storyblok run-migration --publish published --space 1234 --component article --field image
    
OptionDescription
spacethe space ID number you get from the space settings area
componentcomponent name
fieldname of field
dryrunwhen passed as an argument, does not perform the migration
publish (optional)publish the content when update
  • all: publish all stories, even if they have not yet been published
  • published: only publish stories that already are published and don't have unpublished changes
  • published-with-changes: publish stories that are published and have unpublished changes
publish-languages (optional)publish specific languages. You can publish more than one language at a time by separating the languages by a comma ( ,).

Section titled rollback-migration rollback-migration

The rollback-migration command gives the ability to undo changes made from the execution of the last run-migrations command.

        
      storyblok rollback-migration --space 1234 --component Product --field title
    
Important:

The rollback-migration command will only work if there where changes done with run-migrations. Therefore running run-migrations command with the --dryrun flag will NOT create a rollback file.

OptionDescription
spacethe space ID number you get from the space settings area
componentcomponent name
fieldname of field