# Importing from Contentful

Move a Contentful space to Mojimoto in two steps - import the space from the app, then run one command in your site's repository to move its code across.

Moving from Contentful takes two steps:

1. **Import the space.** In the app, give Mojimoto your space ID and a token. It brings the content model, every entry in every locale, drafts and all, and the files.
2. **Switch your site over.** Run one command in your site's repository. It finds where your code talks to Contentful and briefs your coding agent on moving it, with every content type and field already translated.

Nothing in Contentful is changed. The import only reads. You can run it again later to pick up what changed, so there is no rush between the two steps.

## Import the space

Open your project, go to **Get started** and choose **Import from Contentful**. You need two things from Contentful:

| What | Where to find it in Contentful |
| --- | --- |
| Space ID | **Settings**, then **General settings**. |
| Content Management API token | **Settings**, then **CMA tokens**, then **Create personal access token**. |

It has to be a Content Management API token. A delivery or preview key cannot read drafts or every locale at once, and is refused. The environment is `master` unless you change it.

**Check the space** shows what would come over, and changes nothing. **Import** starts it. A big space takes a few minutes, mostly copying files. You can leave the page and it carries on.

The token is used for this import only. It is kept encrypted while the import runs and deleted the moment it ends. You need a developer, admin or owner role on the project.

## What comes over

| In Contentful | In Mojimoto |
| --- | --- |
| Locales, their default and their fallbacks | Locales, with lower case codes: `en-US` becomes `en-us`. |
| Content types | Content types, each given a [format](#how-a-content-type-lands). |
| Fields, their names, help text, validations and field groups | Fields, labels, descriptions, rules and tabs. |
| Published entries | Published entries. |
| Draft entries | Drafts. |
| Entries with unpublished changes | The published version, with the changes as a draft on top. |
| Assets | Files in the media library, with the description as alt text. |
| Links between entries and to assets | References and media fields that point at what was brought over. |

These stay behind: archived entries, entries of a content type that was never activated, people and roles, webhooks, scheduled actions, tags, comments, tasks and apps.

## How a content type lands

Contentful has no formats, so each content type is given one from how it is used. You can change a format afterwards under **Content model**.

| The content type | Format | Each entry's `uid` |
| --- | --- | --- |
| Has a slug field | `page`, a collection | The slug. |
| Has no slug and is held in a list that takes several content types, such as a page's sections | `component` | None. |
| Has no slug and is only listed inside components | `component` | None. |
| Has no slug and exactly one entry | `single` | None. |
| Anything else | `page`, a collection | Made from the entry's title. |

The slug field is the one edited with Contentful's slug editor, or failing that a short text field with the id `slug`.

Ids are rewritten in snake_case, which is what Mojimoto uses:

| Contentful id | Mojimoto id |
| --- | --- |
| `blogPost` | `blog_post` |
| `heroImage` | `hero_image` |
| `SEOTitle` | `seo_title` |
| `2wKn6yEnZewu2SCCkus4as`, generated by Contentful for a type named "FAQ Entry" | `faq_entry`, from its name |

An id the project already uses for something else gets a number after it, such as `post_2`.

## How field types map

| Contentful field | Mojimoto field type | Notes |
| --- | --- | --- |
| Short text (`Symbol`) | `symbol` | Length and pattern rules are kept. |
| Short text with a list of allowed values | `select` | The values become the options. |
| Short text used as the slug | `slug` | It sets each entry's `uid`. |
| Long text (`Text`) | `text` | Markdown stays markdown, as a string. |
| Rich text | `rich_text` | See [Rich text](#rich-text). |
| Integer, Decimal | `number` | The range rule is kept. |
| Date and time | `date` | The string is kept as it is. |
| Boolean | `boolean` | |
| Location | `location` | |
| JSON object | `json` | |
| Media, one file | `media` | |
| Media, many files | `blocks` | One `file` block for each file, holding a `file` media field. |
| Reference, one entry | `reference` | |
| References, many entries | `references` | In the same order. |
| Short text, list | `json` | The same array of strings. |

A reference field that accepted any content type in Contentful accepts every imported content type here, because Mojimoto needs the list written out.

## Entries, uids and locales

- An entry in a collection is found by its `uid`, which is its slug. Contentful lets two entries of a type share a slug unless you forbade it. Here the second one gets `-2` on the end, in its `uid` and in its slug field.
- An entry has one `uid` for all its locales. A slug field that was translated in Contentful becomes a `symbol` field with the same content, and the default locale's slug becomes the `uid`.
- Contentful serves a field that is not translated in every locale, so its value is written into every locale here too.
- A locale that fell back to another in Contentful does so here. See [Locales](/docs/concepts/locales).
- In a project with no entries yet, the space's default locale replaces the project's. In a project that already has content, the project's locales are kept and the space's are added beside them.

## Rich text

Contentful stores rich text as a tree. Mojimoto stores a list of blocks, each with its text and the spans over it. See [Field types](/docs/concepts/field-types#rich-text).

| In Contentful | Becomes |
| --- | --- |
| Paragraphs, headings 1 to 6, bulleted and numbered lists, tables | The same. |
| Bold, italic, links | `strong`, `em` and `hyperlink` spans. |
| Code, underline, superscript, subscript | A `label` span named after the mark, such as `code`. Delivered, but lost if the field is saved in the editor. |
| A link to an entry | A `hyperlink` span with `link_type` `Document` and the entry's `id`, `type` and `uid`. |
| A link to an asset | A `hyperlink` span to the file. |
| An embedded image | An `image` block pointing at the copied file. |
| An embedded file that is not an image | A paragraph that links to the file. |
| A quote | An italic paragraph. |
| A nested list | A flat list. |
| A horizontal rule | Left out. |
| An embedded entry | A block of type `embedded-entry` holding the entry's `id`, `type` and `uid`. Delivered, but the editor cannot show it yet and saving that field in the editor removes it. |
| An entry embedded inside a line of text | Left out. |

When the import finishes it lists which of these happened and how many times.

## Files

Each file is copied into the project's media library. Its alt text is the asset's description, or its title when it has no description. A media field then links to the copy, so images are delivered with their alt text and dimensions.

A file is left where it is in three cases: it is over 20MB, it would not download, or the Free plan's media allowance is full. Fields that use it then hold its Contentful address, so your site keeps working. Move those files somewhere of your own before you close the space, or fix what stopped them and run the import again.

## Plans and limits

An entry or a file is one record. See [Technical limits](/docs/technical-limits) for what each plan includes.

| The project is on | A space that is too big |
| --- | --- |
| The Free plan | Is not imported. The check says how many records it needs, so you can upgrade first. |
| A trial, Starter or Pro | Is imported in full. Records past the plan's allowance are covered by usage packs, and the check says how many. |

A locale the plan has no room for is left behind, and the check names it. The space's default locale always comes.

## Run it again

Run the import a second time and it:

- adds entries, files, content types and fields that are new in Contentful,
- writes a new version of each entry whose content changed in Contentful,
- leaves everything else alone, including edits made in Mojimoto to an entry Contentful has not touched.

Nothing is ever made twice. This is how you catch up just before you switch your site over: import early, build against Mojimoto, then import again on the day.

## Switch your site over

Run this in your site's repository. The page shown when an import finishes has it ready to copy, with your project id and read token filled in:

```bash
npx @mojimoto/cli migrate contentful --project acme --token mjmt_your_read_token
```

It looks through the repository for every place your code talks to Contentful, then writes a brief for your coding agent: which files to change, and what each of your content types, fields and locales is called now. Tell the agent to follow it. The [CLI](/docs/tools/cli#migrate-contentful) page lists what it writes.

Doing it by hand, these are the calls to change:

| With Contentful's client | With `@mojimoto/client` |
| --- | --- |
| `createClient({ space, accessToken })` | `createClient({ endpoint, project, token })` |
| `getEntries({ content_type: 'blogPost' })` | `all({ type: 'blog_post' })`, or `query` for one page |
| `getEntries({ content_type: 'blogPost', 'fields.slug': slug })` | `byUid('blog_post', slug)` |
| `getEntry(id)` | `byId(id)`, with the entry's new id |
| `include: 2` | `depth: 2`. The most is 3. |
| `order: '-fields.publishedOn'` | `sort: '-fields.published_on'` |
| `limit` and `skip` | `perPage` and `page` |
| `locale: 'de-DE'` | `lang: 'de-de'` |

And these are the shapes that changed:

| In a Contentful response | In a Mojimoto response |
| --- | --- |
| `entry.sys.id` | `entry.id`, a number |
| `entry.sys.contentType.sys.id` | `entry.type` |
| `entry.fields.heroImage` | `entry.data.hero_image` |
| `entry.sys.updatedAt` | `entry.updated_at` |
| A linked entry, resolved from `includes` | The linked entry itself, in place. Past `depth` it is `{ id, type, uid }`. |
| `asset.fields.file.url`, with no `https:` | `media.url`, a full address |
| `asset.fields.description` | `media.alt` |
| `asset.fields.file.details.image.width` | `media.width` |
| A rich text document | An array of blocks. Render it with `MojiRichText` or `asHTML`. See [Rich text](/docs/frameworks/rich-text). |

Three things have no direct equivalent:

- **The GraphQL API.** Mojimoto has a REST API only. Replace each query with a client call. `depth` and `select` do what a query's shape did.
- **The Images API.** A file's address takes no resizing parameters. Use your framework's image component, such as `next/image`.
- **Filters on a linked entry's fields**, such as `fields.author.fields.name`. Find the linked entry first, then filter on its id.

The [JavaScript client](/docs/frameworks/javascript) page covers the rest, and so do the pages for [Next.js](/docs/frameworks/nextjs) and [Nuxt](/docs/frameworks/nuxt).

## Look up where something went

The map the import kept is served by the Delivery API, to any token that can read the project:

```http
GET /api/v1/{project}/migrations/contentful
```

```json
{
  "source": "contentful",
  "space": "x1y2z3",
  "space_name": "Acme",
  "imported_at": "2026-11-29T14:02:11+00:00",
  "locales": [{ "contentful": "en-US", "mojimoto": "en-us", "default": true }],
  "content_types": [
    {
      "contentful": "blogPost",
      "mojimoto": "blog_post",
      "name": "Blog post",
      "format": "page",
      "fields": [
        { "contentful": "heroImage", "mojimoto": "hero_image", "was": "Link<Asset>", "type": "media", "localized": false }
      ]
    }
  ]
}
```

Add `?include=ids` and it also returns `entries` and `assets`, each keyed by the Contentful id: an entry's new `id`, `type` and `uid`, and a file's new `id` and `url`. Use it to translate an entry id that is written into your code. It answers `404` until a space has been imported.
