Storyblok CLI
The storyblok CLI scaffolds Storyblok projects and facilitates Management API requests, such as pushing and pulling content and schemas.
Run storyblok --help to see available commands.
Requirements
Section titled “Requirements”- Node.js LTS (version 22.x or higher is recommended)
Installation
Section titled “Installation”# Global installationnpm install -g storyblok@latest# Local installation (per project)npm install -D storyblok@latestConfiguration
Section titled “Configuration”The CLI can be configured via configuration files, setting default values within a given context. This avoids having to pass the same flags repeatedly for every command.
Quick start
Section titled “Quick start”-
Create a
storyblok.config.tsfile in the project root. -
Export a configuration object using
defineConfigand apply the desired settings. For example:import { defineConfig } from "storyblok/config";export default defineConfig({space: "123456",}); -
Run any command, and the CLI will automatically apply the detected configuration settings. For example, the following command will automatically pull components from the space with the ID
123456:Terminal window storyblok components pull
File locations and layers
Section titled “File locations and layers”A configuration file must adhere to the naming convention {storyblok.}config.{ext}. Supported file extensions are .js, .mjs, .cjs, .ts, .mts, .cts, .json, .json5, .jsonc, .yaml, .yml, .toml.
Configuration layers
Section titled “Configuration layers”The CLI uses a layered configuration system that merges multiple config files, with more specific locations overriding more general ones. This allows for flexible configuration at different levels, such as globally for all projects, per workspace, or per individual project.
The CLI detects and merges configuration files at different levels. The resolution order is as follows:
- Home directory:
~/.storyblok/config.* - Workspace:
<workspace>/.storyblok/config.* - Project root:
<project>/storyblok.config.*
Note that configuration files placed inside a .storyblok folder should be named config.*, while configuration files placed in other locations (e.g., project root) should be named storyblok.config.* to be detected by the CLI.
Settings from all layers are merged, allowing for a combination of settings across layers. Conflicting settings are resolved based on the precedence rules outlined below.
Precedence rules
Section titled “Precedence rules”Values from higher layers override lower layers:
flags > project > workspace > home directory > built-in defaultsComplete example
Section titled “Complete example”// storyblok.config.tsimport { defineConfig } from "storyblok/config";
export default defineConfig({ // General settings region: "eu", // Storyblok region: 'eu', 'us', 'ap', 'ca', 'cn' verbose: false, // Enable verbose output
space: "123456", // Default space ID for commands that require it path: ".storyblok", // Base directory
// UI configuration ui: { enabled: true, // Enable UI output },
// API configuration api: { maxRetries: 3, // Maximum retry attempts for failed requests maxConcurrency: 6, // Maximum concurrent API requests },
// Logging configuration log: { console: { enabled: false, // Enable console logging level: "info", // Log level: 'info', 'warn', 'error', 'debug' }, file: { enabled: true, // Enable file logging level: "info", // File log level maxFiles: 10, // Maximum log files to keep }, },
// Report configuration report: { enabled: true, // Enable report generation maxFiles: 10, // Maximum report files to keep },
// Module-specific configuration modules: { components: { pull: { separateFiles: false, // Separate output per component filename: "components", // Filename for exports }, push: { dryRun: false, // Preview changes without pushing }, }, datasources: { pull: { separateFiles: false, }, push: { dryRun: false, }, }, migrations: { run: { dryRun: false, }, }, types: { generate: { output: "storyblok-component-types.d.ts", }, }, },});Environment variables
Section titled “Environment variables”Any configuration file runs in Node, and the CLI loads environment variables via dotenv. Access environment variables using process.env as follows.
export default defineConfig({ region: process.env.STORYBLOK_REGION ?? "eu", space: process.env.STORYBLOK_SPACE_ID, api: { maxRetries: Number(process.env.STORYBLOK_MAX_RETRIES ?? 5), },});Global options
Section titled “Global options”| Flag | Config | Type | Description |
|---|---|---|---|
--api-max-concurrency | api.maxConcurrency | integer | Maximum number of concurrent API requests. |
--api-max-retries | api.maxRetries | integer | Maximum number of retry attempts for failed HTTP requests. |
--log-console-enabled, --no-log-console-enabled | log.console.enabled | boolean | Enable or disable logging output to the console. |
--log-console-level | log.console.level | string | Minimum log level for console output (info, warn, error). Defaults to info. |
--log-file-enabled, --no-log-file-enabled | log.file.enabled | boolean | Enable or disable log generation. |
--log-file-level | log.file.level | string | Minimum log level for file-based logs (info, warn, error). Defaults to info. |
--log-file-max-files | log.file.maxFiles | integer | Maximum number of log files retained on disk. |
--path | path | string | The path to use for any local operations. |
--region | region | string | The region to use for API requests. |
--report-enabled, --no-report-enabled | report.enabled | boolean | Enable or disable report generation. |
--report-max-files | report.maxFiles | integer | Maximum number of report files retained on disk. |
--space | space | integer | The space ID to use. |
--ui-enabled, --no-ui-enabled | ui.enabled | boolean | Enable or disable interactive UI output. |
--verbose | verbose | boolean | Enable verbose output for additional diagnostic information. |
Commands
Section titled “Commands”assets pull
Section titled “assets pull”Downloads assets, asset metadata, and asset folders from a Storyblok space and saves them to a local directory.
The command saves to the following folder structure and recursively creates it if it doesn’t exist yet.
.storyblok/└── assets/ └── <space-id>/ ├── <asset>.jpg └── manifest.jsonl └── folders/ ├── <folder>.json └── manifest.jsonlstoryblok assets pull [flags]| Flag | Type | Description |
|---|---|---|
--space -s | integer | Required. The ID of the Storyblok space to pull assets from. |
--path, -p | string | Optional. Specify a custom path for asset files. Defaults to .storyblok/assets/<space-id>. |
--asset-token | string | Optional. Provide an asset token to access private assets. |
--query, -q | string | Optional. Filter assets using query parameters. |
--dry-run, -d | boolean | Optional. Preview changes without applying them to the local directory. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Pull all assets from a spacestoryblok assets pull# Pull all assets from a space using an asset token to access private assetsstoryblok assets pull --asset-token ASSET_TOKEN# Pull all assets from a space, filtering by query and previewing changes without applying themstoryblok assets pull --query "search=my-file.jpg&with_tags=tag1,tag2"assets push
Section titled “assets push”Pushes assets and asset metadata from a local directory or uploads single assets (local files or remote URLs) to a Storyblok space.
storyblok assets push [arguments] [flags]Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
| Asset path | string | Optional. The path to a single local file or remote URL to upload. If not provided, all assets from the local .storyblok/assets/<space-id>/ directory will be pushed. |
| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to push or upload assets to. |
--path, -p | string | Optional. Specify a custom path for asset files. Defaults to .storyblok/assets/<space-id>. |
--from, -f | integer | Optional. The ID of the source space from which the assets were originally pulled. If not provided, the origin space equals the target space specified via --space. |
--dry-run, -d | boolean | Optional. Preview changes without applying them to the Storyblok space. |
--short-filename | string | Optional. Override the filename of the uploaded asset. |
--folder | string | Optional. The ID of the folder to upload the asset to. |
--cleanup | boolean | Optional. Delete local assets and metadata after a successful push. |
--update-stories | boolean | Optional. Update stories that reference the uploaded asset. |
--data | string | Optional. Provide inline metadata. See the asset object for available options. |
--asset-token | string | Optional. Provide an asset token to access private assets. The asset token is needed for comparing the local assets with remote assets that are private. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Push assets from .storyblok/assets/<space>storyblok assets push# Push a single assetstoryblok assets push ./path/to/image.png# Upload a single remote URLstoryblok assets push https://example.com/assets/image.png# Upload a single local filestoryblok assets push ./path/to/image.png# Upload a single local file with inline metadata to a folder and override the filenamestoryblok assets push ./path/to/image.png \ --data='{"meta_data":{"alt":"Hero image"}}' \ --short-filename="hero.png" \ --folder=654321# Update a single existing file and stories referencing itstoryblok assets push ./path/to/image.png --update-storiesWhen uploading a single asset (local file or remote URL), the command supports an optional sidecar JSON file (with the same basename) to provide additional metadata, such as alt text and tags.
For example, ./path/to/image.png can have a sidecar file ./path/to/image.json with the following content:
{ "meta_data": { "alt": "Hero image", "title": "Homepage hero" }}See the asset object reference for all available metadata options.
Asset manifest
Section titled “Asset manifest”The command creates manifest files to keep track of asset changes and references when pushing assets (stored under .storyblok/assets/<space-id>/manifest.jsonl and .storyblok/assets/<space-id>/folders/manifest.jsonl). Specifically, they map source IDs and filenames to target asset IDs and filenames. This serves the following purposes:
- Idempotency: Prevent duplicate uploads of the same asset when running
assets pushmultiple times, recognizing existing assets and updating them instead. - Incremental workflows: As the relation between source and target assets is persisted, users can pull, modify, and push single or multiple assets incrementally.
- Migration: Mapping source and target IDs is crucial for space-to-space migrations in Storyblok as well as CMS migrations from third-party systems to Storyblok.
components pull
Section titled “components pull”Fetches components schemas, component groups, component presents, and component tags from a Storyblok space and saves them to a local directory.
The command saves to the following folder structure and recursively creates it if it doesn’t exist yet.
.storyblok/└── components/ └── <space-id>/ ├── components.json ├── groups.json ├── presets.json └── tags.jsonstoryblok components [arguments] [flags]Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
| Component name | string | Optional. The technical name of a single component to pull. If not provided, all components will be pulled. |
| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to pull components from. |
--filename, -f | string | Optional. Specify a custom filename. Defaults to components.json. Ignored when --separate-files is used. |
--separate-files, -sf | boolean | Optional. Save each component and each preset to a separate file. |
--suffix, -su | string | Optional. Specify a custom suffix for component files. |
--path, -p | string | Optional. Specify a custom path for component files. Defaults to .storyblok/components/<space-id>. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Pull all components from a spacestoryblok components pull# Pull a single component from a spacestoryblok components pull hero-section# Pull all components from a space, saving each to a separate file with a custom suffixstoryblok components pull --separate-files --suffix dev# Pull all components from a space, saving with a custom filenamestoryblok components pull --filename my-componentscomponents push
Section titled “components push”Pushes components schemas, component groups, component presents, and component tags, component whitelists, and datasources (excluding datasource entries) from a local directory to a Storyblok space.
Prerequisites
Section titled “Prerequisites”- The command expects schemas that have previously been pulled from a space using
components pull. - For components with fields that depend on datasources, first pull the datasources from the origin space and push them to the target space using
datasources pullanddatasources push. - Any flags used with
components pullprior (such as--suffixor--separate-files) need to be applied with the same values when pushing to ensure the files are found correctly.
storyblok components push [arguments] [flags]Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
| Component name | string | Optional. The technical name of a single component to push. If not provided, all components will be pushed. |
| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to push components to. |
--from, -f | integer | Optional. The ID of the source space from which the components were originally pulled. If not provided, the origin space equals the target space specified via --space. |
--filter, -fi | string | Optional. Glob pattern to filter components by their name (e.g., hero* will match all components starting with hero). |
--separate-files, -sf | boolean | Optional. Read components from individual files, rather than a consolidated components.json file. |
--suffix, -su | string | Optional. Specify a custom suffix for component files. |
--path, -p | string | Optional. Specify a custom path for component files. Defaults to .storyblok/components/<space-id>. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Push all components to a spacestoryblok components push --from 654321# Push a single component to a spacestoryblok components push hero-section --from 654321# Push all components to a space, reading each from a separate file with a custom suffixstoryblok components push --from 654321 --separate-files --suffix dev# Push all components to a space, filtering by component namestoryblok components push --filter "hero-*"create
Section titled “create”Scaffolds a new project using Storyblok with your preferred technology. Automatically generates the project structure, creates a Storyblok space, configures environment variables, integrates the project with Storyblok, and opens the new space in the browser.
If your account is associated with multiple organizations, you will be prompted to select the target organization for the new space.
Prerequisites
Section titled “Prerequisites”- Write access to the target directory
- Space creation permissions in your Storyblok account
storyblok create [arguments] [flags]Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
| Project path | string | Optional. Specify a custom path for the project. If not provided, the current working directory is used. |
| Flag | Type | Description |
|---|---|---|
--template | string | Optional. Select a template in your preferred technology. Possible values are react, vue, svelte, astro, nuxt, next, eleventy. Supported templates correspond to all core blueprints. |
--skip-space | boolean | Optional. Skip the creation of a new space. Defaults to false. If no --token is provided, none will be added to the .env file. |
--token | string | Optional. Specify the preview access token of an existing space. To be used in conjunction with the --skip-space flag. |
Examples
Section titled “Examples”# Interactive project creationstoryblok create# Create a Next.js project in the specified path and skip space creationstoryblok create ./my-nextjs-project --template nextjs --skip-space# Create an Astro project in the specified path, skip space creation, and use the preview access token of an existing spacestoryblok create ./my-astro-project --template astro --skip-space --token EXAMPLE_TOKENdatasources delete
Section titled “datasources delete”Deletes a datasource from a Storyblok space by name or ID. Asks for confirmation before deleting.
storyblok datasources delete [arguments] [flags]Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
| Datasource name | string | Required. The name of a single datasource to delete. Note that the actual name (including upper/lower case) is used, as opposed to the slug. |
| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to delete the datasource from. |
--id | integer | Optional. The ID of the Storyblok datasource to delete. If provided, the datasource ID takes priority over the datasource name. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Delete a datasource by namestoryblok datasources delete colors# Delete a datasource by IDstoryblok datasources delete --id 140731465546051datasources pull
Section titled “datasources pull”Downloads datasources and their entries from a Storyblok space, recursively creates a folder structure if it doesn’t exist, and saves them to a local directory.
The command saves to the following folder structure and recursively creates it if it doesn’t exist yet.
.storyblok/└── datasources/ └── <space-id>/ ├── <datasource-name>.jsonstoryblok datasources pull [flags]| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to pull datasources from. |
--filename, -f | string | Optional. Specify a custom filename. Defaults to datasources.json. Ignored when --separate-files is used. |
--separate-files, -sf | boolean | Optional. Save each datasource to a separate file. |
--suffix, -su | string | Optional. Specify a custom suffix for datasource files. |
--path, -p | string | Optional. Specify a custom path for datasource files. Defaults to .storyblok/datasources/<space-id>. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Pull all datasources from a spacestoryblok datasources pull# Pull all datasources from a space, saving each to a separate file with a custom suffixstoryblok datasources pull --separate-files --suffix dev# Pull all datasources from a space, saving with a custom filenamestoryblok datasources pull --filename my-datasourcesdatasources push
Section titled “datasources push”Uploads datasources and their entries from a local directory to a Storyblok space. The command will create new datasources and entries or update existing ones based on name matching.
Prerequisites
Section titled “Prerequisites”- The command expects datasources that have previously been pulled from a space using
datasources pull. - Any flags used with
datasources pullprior (such as--suffixor--separate-files) need to be applied with the same values when pushing to ensure the files are found correctly.
storyblok datasources push [flags]| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to push datasources to. |
--from, -f | integer | Optional. The ID of the source space from which the datasources were originally pulled. If not provided, the origin space equals the target space specified via --space. |
--filter, -fi | string | Optional. Glob pattern to filter datasources by their name (e.g., colors* will match all datasources starting with colors). |
--separate-files, -sf | boolean | Optional. Read datasources from individual files, rather than a consolidated datasources.json file. |
--suffix, -su | string | Optional. Specify a custom suffix for datasource files. |
--path, -p | string | Optional. Specify a custom path for datasource files. Defaults to .storyblok/datasources/<space-id>. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Push all datasources to a spacestoryblok datasources push --from 654321# Push all datasources to a space, reading each from a separate file with a custom suffixstoryblok datasources push --from 654321 --separate-files --suffix dev# Push all datasources to a space, filtering by datasource namestoryblok datasources push --filter "colors-*"languages pull
Section titled “languages pull”Downloads the list of used languages from a Storyblok space, recursively creates a folder structure, and saves the data to a local directory. The list includes the default language and the language code, display name, and AI translation code for each language.
storyblok languages pull [flags]| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to pull languages from. |
--filename, -f | string | Optional. Specify a custom filename. Defaults to languages.json. |
--suffix, -su | string | Optional. Specify a custom suffix for language files. |
--path, -p | string | Optional. Specify a custom path for language files. Defaults to .storyblok/languages/<space-id>. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Pull languages from a spacestoryblok languages pull# Pull languages from a space, saving with a custom filenamestoryblok languages pull --filename my-languagesAuthenticates a Storyblok user by email and password (supporting two-factor authentication) or personal access token and stores their credentials in ~/.storyblok/credentials.json. Using a personal access token is recommended for CI/CD environments and required for accounts using SSO.
storyblok login| Flag | Type | Description |
|---|---|---|
--token | string | Optional. A personal access token. |
--region | string | Optional. The region of the Storyblok space. Possible values are ‘eu’, ‘us’, ‘ca’, ‘au’, and ‘cn’. Must match the space region. Once logged in, the same region setting is used for all subsequent CLI commands. |
logout
Section titled “logout”Securely removes stored credentials and clear the current session to deauthenticate the logged-in Storyblok user.
storyblok logoutlogs list
Section titled “logs list”Lists all logs for CLI operations performed per Storyblok space. Logs are stored locally under .storyblok/logs/<space-id>/ (or at the location specified in the --path flag of a command that is logged) and include details such as the command executed, timestamp, and basic metadata.
To disable logging, use the --no-log-file-enabled flag when running the command, or change the global CLI configuration.
storyblok logs list [flags]| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to list logs for. |
logs prune
Section titled “logs prune”Deletes old logs for CLI operations performed per Storyblok space.
storyblok logs prune [flags]| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to list logs for. |
--keep | integer | Optional. The number of most recent logs to keep. If not specified, all logs are deleted. |
migrations generate
Section titled “migrations generate”Creates migration files for specific components of a Storyblok space. Migrations are useful for making changes to existing stories in a Storyblok space, such as updating component structures or content.
The command will recursively generate a folder structure and migration file for the specified component:
.storyblok/└── migrations/ └── <space-id>/ └── <component-name>[.<suffix>].jsThe generated migration file contains a template function with examples for common transformations. The function receives a block parameter that contains the components data. The function should return the updated block.
storyblok migrations generate <component-name> --space <source-space-id> [--suffix <suffix>]Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
| Component name | string | Required. The technical name of a single component to generate a migration for. |
| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space that contains the component to generate a migration for. |
--path | string | Optional. Specify a custom path for migration files. Defaults to .storyblok/migrations/<space-id>. |
--suffix | string | Optional. Specify a custom suffix for migration files. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Generate a migration for the "hero-section" component in the specified spacestoryblok migrations generate hero-section# Generate a migration for the "hero-section" component in the specified space, saving with a custom suffixstoryblok migrations generate hero-section --suffix devmigrations rollback
Section titled “migrations rollback”Reverts a previous migration that was executed with migrations run, restoring affected stories in a Storyblok space based on a snapshot saved by migrations run.
Prerequisites
Section titled “Prerequisites”- A snapshot file generated by
migrations runis required to perform the rollback.
storyblok migrations rollback [arguments] [flags]Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
| Snapshot file | string | Required. The full name of the snapshot file generated by migrations run. |
| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to perform the rollback for. |
--path | string | Optional. Specify a custom path for snapshot files. Defaults to .storyblok/migrations/<space-id>. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Rollback a migration in the specified spacestoryblok migrations rollback hero-section.1770129788914.jsmigrations run
Section titled “migrations run”Executes migration files for specific components in a Storyblok space, updating stories that use those components based on the defined migrations. Generates a component-specific snapshot of the space before applying the migrations to allow for rollback if needed.
Prerequisites
Section titled “Prerequisites”- Migration files generated by
migrations generateand updated with the desired changes must be present in the expected directory.
storyblok migrations run [arguments] [flags]Arguments
Section titled “Arguments”| Argument | Type | Description |
|---|---|---|
| Component name | string | Optional. The technical name of a single component to run the migration for. If omitted, all migrations found in the specified path are run in the space. |
| Flag | Type | Description |
|---|---|---|
--space, -s | integer | Required. The ID of the Storyblok space to run migrations for. |
--filter, -fi | string | Optional. Glob pattern to filter stories by their component name (e.g., hero* will match all stories starting with hero). |
--dry-run, -d | boolean | Optional. Preview changes without applying them. |
--query, -q | string | Optional. Filter stories using query parameters. |
--starts-with, -sw | string | Optional. A path prefix to filter stories to migrate. |
--publish | string | Optional. Specify a publication mode: all (publish all stories), published (only publish stories that were already published), or published-with-changes (only publish stories that have unpublished changes). |
--path, -p | string | Optional. Specify a custom path for migration files. Defaults to .storyblok/migrations/<space-id>. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Run migration for the "hero-section" component in the specified spacestoryblok migrations run hero-section# Run all migrations in the specified space, filtering by component name and previewing changes without applying themstoryblok migrations run --filter "hero-*" --dry-run# Run all migrations in the specified space, filtering by query and publishing stories that were already publishedstoryblok migrations run --publish published --query "[highlighted][in]=true"reports list
Section titled “reports list”Lists reports logs for CLI operations performed per Storyblok space. Logs are stored locally under .storyblok/logs/<space-id>/ (or at the location specified in the --path flag of a command that is logged) and include details such as the command executed, timestamp, and detailed metadata (such as the applied configuration and aggregated results).
To disable reports, use the --no-report-enabled flag when running the command, or change the global CLI configuration.
storyblok reports list [flags]| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to list reports for. |
reports prune
Section titled “reports prune”Deletes old reports for CLI operations performed per Storyblok space.
storyblok reports prune [flags]| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to list reports for. |
--keep | integer | Optional. The number of most recent reports to keep. If not specified, all reports are deleted. |
signup
Section titled “signup”Opens the Storyblok signup page in the browser. After signing up, run login to authenticate.
storyblok signupstories pull
Section titled “stories pull”Downloads stories from a Storyblok space and saves them to a local directory.
The command saves to the following folder structure and recursively creates it if it doesn’t exist yet. All stories are saved as individual JSON files ({slug}_{UUID}.json).
.storyblok/└── stories/ └── <space-id>/ └── <story>.jsonstoryblok stories pull [flags]| Flag | Type | Description |
|---|---|---|
--space -s | integer | Required. The ID of the Storyblok space to pull stories from. |
--path, -p | string | Optional. Specify a custom path for story files. Defaults to .storyblok/stories/<space-id>. |
--query, -q | string | Optional. Filter stories using query parameters. |
--dry-run, -d | boolean | Optional. Preview changes without applying them to the local directory. |
--starts-with, -sw | string | Optional. A path prefix to filter stories to pull. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Pull stories from a spacestoryblok stories pull# Pull stories from a space, filtering by query and previewing changes without applying them to the local directorystoryblok stories pull --query "[highlighted][in]=true" --dry-run# Pull stories from a space, filtering by path prefixstoryblok stories pull --starts-with "blog/"stories push
Section titled “stories push”Pushes stories from a local directory to a Storyblok space.
Prerequisites
Section titled “Prerequisites”- The command expects stories that have previously been pulled from a space using
stories pull. - Run
components pullto keep component schemas up-to-date, allowing for references to be resolved correctly.
storyblok stories push [flags]| Flag | Type | Description |
|---|---|---|
--space -s | integer | Required. The ID of the Storyblok space to push stories to. |
--from, -f | integer | Optional. The ID of the source space from which the stories were originally pulled. If not provided, the origin space equals the target space specified via --space. |
--path, -p | string | Optional. Specify a custom path for story files. Defaults to .storyblok/stories/<space-id>. |
--dry-run, -d | boolean | Optional. Preview changes without applying them to Storyblok. |
--cleanup | boolean | Optional. Delete local stories after a successful push. |
--publish | boolean | Optional. Publish stories after a successful push. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Push stories to a spacestoryblok stories push# Push stories to a space previewing changes without applying them to Storyblokstoryblok stories push --dry-runStory manifest
Section titled “Story manifest”The command creates a manifest file to keep track of story changes and references when pushing stories (stored under .storyblok/stories/<space-id>/manifest.jsonl). Specifically, it maps source IDs and filenames to target asset IDs and filenames. This serves the following purposes:
- Idempotency: Prevent duplicate uploads of the same story when running
stories pushmultiple times, recognizing existing stories and updating them instead. - Incremental workflows: As the relation between source and target stories is persisted, users can pull, modify, and push single or multiple stories incrementally.
- Migration: Mapping source and target IDs is crucial for space-to-space migrations in Storyblok as well as CMS migrations from third-party systems to Storyblok.
types generate
Section titled “types generate”Generates TypeScript type definitions (.d.ts files) for Storyblok components that have been generated with the components pull command. types generate must include any flags used when running components pull to ensure components are matched correctly.
By default, the command generates two files:
.storyblok/types/storyblok.d.ts: Base Storyblok types.storyblok/types/<space-id>/storyblok-component.d.ts: Space-specific component types
The command also creates types for any datasources that are referenced in the components’ schemas.
Prerequisites
Section titled “Prerequisites”- The command relies on the presence of component files generated by
components pullto create accurate type definitions.
types generate [flags]| Flag | Type | Description |
|---|---|---|
--space | integer | Required. The ID of the Storyblok space to generate types for. |
--strict | boolean | Optional. Enable strict mode for type generation, creating types that are more precise. |
--type-prefix | string | Optional. Prepend a prefix to the generated types. |
--filename | string | Optional. Specify a custom filename. Defaults to storyblok-components.d.ts. Ignored when --separate-files is used. |
--separate-files, -sf | boolean | Optional. Save component type definitions as separate file, plus a datasource-types.d.ts containing all datasource type definitions as well as a content-types.d.ts containing all content type type definitions. |
--suffix | string | Optional. Specify a custom suffix for type definition files. |
--path | string | Optional. Specify a custom path for type definitions. Defaults to .storyblok/types/<space-id>. |
--compiler-options | string | Optional. Specify a path to compiler options from json-schema-to-typescript. |
--custom-fields-parser | string | Optional. Specify a path to a parser for custom field types. |
Examples
Section titled “Examples”The following examples assume that a space has been defined in a configuration file.
# Generate types for all components from a spacestoryblok types generate# Generate types for all components from a space with strict mode enabledstoryblok types generate --strict# Generate types for all components from a space, reading each from a separate file with a custom suffixstoryblok types generate --separate-files --suffix dev# Generate types for all components from a space, saving with a custom filenamestoryblok types generate --filename my-typesChecks if a user is currently logged in and, if so, displays information about the authenticated Storyblok account, including the friendly name, email address, and active region.
storyblok userWas this page helpful?
This site uses reCAPTCHA and Google's Privacy Policy. Terms of Service apply.
Get in touch with the Storyblok community