CLI Reference
Global conventions, command families, and where each command is documented.
CLI reference
sb-mig [command]sb-mig is a Storyblok Management API CLI. Most commands read configuration
from the current project, then either inspect Storyblok state, write local JSON
artifacts, or write back to Storyblok.
Global commands
| Form | Behavior |
|---|---|
sb-mig | Show top-level help. |
sb-mig --help | Show top-level help. |
sb-mig help | Show top-level help. |
sb-mig <command> --help | Show help for one command family. |
sb-mig --version | Print the installed sb-mig package version. |
Command families
| Command | Purpose | Full reference |
|---|---|---|
sync | Synchronize components, roles, datasources, plugins, stories, and assets. | sync |
migrate | Run story or preset data migrations. | migrate |
inspect | Inspect Storyblok content with local query files. Beta: Needle in a haystack | inspection commands |
language-publish-state | Build a read-only language publish-state map. | inspection commands |
published-layer-export | Export draft/current and latest published story layers. | inspection commands |
story-versions | Inspect Management API story version history for one story. | inspection commands |
backup | Back up Storyblok resources to local JSON files. | backup, revert, remove |
revert | Restore stories from a local story backup file. | backup, revert, remove |
remove | Remove components or all stories from a space. | backup, revert, remove |
copy | Copy stories, folders, assets, and asset folders between spaces. | utility commands |
discover | Discover local component schemas and migration configs. | utility commands |
migrations | Recognize Backpack package upgrade migrations. | utility commands |
init | Initialize Storyblok environment settings. | utility commands |
debug | Print resolved config and dependency metadata. | utility commands |
Command matrix
Use Command Matrix as the coverage checklist. It lists every public command form, valid selectors, options, and write behavior.
Flag conventions
The public CLI uses long flags. Examples:
--dry-run
--migrate-from file
--publicationMode preserve-layers
--publicationLanguages default,fr,demeow, the CLI parser, exposes kebab-case flags as camelCase internally. The
docs show the form users should type in the shell.
Repeatable flags can be passed more than once:
--migration migration-a --migration migration-b
--withSlug blog/home --withSlug docs/getting-started
--storyId 111 --storyId 222Config fallback
Most Storyblok commands read storyblok.config.js or storyblok.config.mjs
from the current working directory and merge it with .env defaults.
Important environment values:
| Variable | Used for |
|---|---|
STORYBLOK_SPACE_ID | Default space ID when a command falls back to configured space. |
STORYBLOK_OAUTH_TOKEN | Management API access. |
STORYBLOK_ACCESS_TOKEN | Delivery API token for translated language publish-state checks. |
NEXT_PUBLIC_STORYBLOK_ACCESS_TOKEN | Delivery API fallback token. |
NEXT_PUBLIC_STORYBLOK_MANAGEMENT_API_URL | Management API URL override. |
NEXT_PUBLIC_STORYBLOK_DELIVERY_API_URL | Delivery API URL override. |
NEXT_PUBLIC_STORYBLOK_GRAPHQL_API_URL | GraphQL API URL override. |
Some commands say --from or --to is required. In implementation, several
older commands fall back to configured spaceId when the flag is omitted. For
production usage, pass explicit --from and --to so command logs and
artifacts are unambiguous.
Confirmation flags
--yes skips prompts for commands that call the confirmation helper. It is
used by:
sync components --all --ssot- destructive
sync contentdirections that delete target stories before sync migrate contentmigrate presetsmigrate continuerevert content
--dry-run skips writes only for commands that explicitly support it. It is
not a universal global flag.
Beta feature labels
Some commands are documented with a beta label when they ship as focused investigation tools before becoming broader workflows.
| Label | Meaning |
|---|---|
Beta: Needle in a haystack | A read-only beta inspection feature for finding rare Storyblok component patterns across many stories. |
sb-mig