# Migrate from Storyblok

> Import a Storyblok space into Galerne from the delivery API, with components from the Management API, or from a file, and export Galerne content as Storyblok JSON: options, mapping and losses.

The Storyblok source reads stories from the delivery API, in every language, both published and draft with a preview token. With a Management API token it also reads your components, so the schema matches your space exactly; without it, the schema is inferred from the content.

## Import

```bash
galerne import --from storyblok --source-token <preview-token> --management-token <token> --space 123456 --dry-run
galerne import --from storyblok --source-token <preview-token> --management-token <token> --space 123456
```

Options go after `--from` as flags in kebab case (`projectId` is `--project-id`). With the `import_from` tool, they go in `options`. See the [migration overview](/docs/migrate.md) for the shared flags, the report and re-runs.

| Option | What it is |
|---|---|
| `token` | A delivery token. A preview token also reads drafts. On the CLI: `--source-token` |
| `managementToken` | A Management API token, to read the components (needs `space`) |
| `space` | The space id |
| `region` | `eu` (default), `us`, `ap`, `ca` or `cn` |
| `languages` | Language codes, the default first. Default: read from the space |
| `file`, `data` | A bundle `{ components, languages, stories, translations }` instead of the API, such as one a Galerne export wrote |

## How content maps

| Storyblok | Galerne |
|---|---|
| Content type of a story (`content.component`) | Document type |
| Story `uuid` | Document id |
| Story slug | `slug`, unless the content has a slug field |
| Rich text, Markdown fields | Rich text |
| Nested bloks | `blocks`, with `_uid` as the key |
| Bloks inside rich text | Embeds; the field's allowed components become its `embeds` |
| Asset, multi-asset | `image` or `file`, blocks of images and files; the focus point becomes the hotspot when the image size is known |
| Link to a story | `reference` |
| Link field mixing stories and URLs | A URL string, story links written as their path |
| Email link | A `mailto:` URL |
| Table | `table` |
| Single and multi options of stories | References |
| Options | Strings |
| Translatable fields | Localized fields |

## What the import loses

The report lists each of these when it happens.

- Section and tab fields are dropped; unknown objects become JSON code fields, with a warning.
- Folders and stories without content are skipped.
- Options are dropped from the schema when stored values fall outside them.
- Folder-level translation is read as field-level: translatable fields become localized.

## Export to Storyblok

```bash
galerne export --to storyblok --out ./storyblok-export
```

The folder holds `storyblok.json` (the whole bundle, which the importer can read back with `--file`), `components.json`, `stories.json` with draft content to create through the Management API, assets under `assets/`, and a `README.md`.

The export loses:

- Document-level translations have no Storyblok equivalent: each translation becomes its own story, with a warning.
- The hotspot becomes a one-pixel focus box, and only when the media size is known.
- `title` and `slug` move onto the story's name and slug.
- Object fields become nested bloks. Embeds become bloks inside rich text, and the field allows their components.
