# Introduction

## Goal

Migrate content stored in a different CMS to Bloomreach Content using the Content Batch Import API.

## Background

When coming from a different CMS, a lot of content might need to be migrated into Bloomreach Content.

Our goal is to support this use case and make it as easy as possible for developers to quickly migrate into Bloomreach Content.

We solve the migration of data problem by offering a [Content Batch Import API](🔗). It enables developers to import large amounts of content into a Bloomreach project.

In this tutorial, we'll walk you through the process step by step with examples showing how to import content into Bloomreach Content. You can import both documents and/or pages in the batch request.

## Prerequisites

Before starting:

  • Familiarize yourself with how to set up a [Development Environment](🔗) with a channel created using the [Reference SPA](🔗) template.

  • Have the [Content Batch Import API](🔗) reference documentation handy.

  • Optionally, have the [Project Management API](🔗) and the [Site Management API](🔗) reference documentation handy if you want to use the APIs to perform project and channel operations related to the content import (instead of using the UI).

To make the API requests in this tutorial, we recommend using the [Postman Collection](🔗) to make the API requests. However, you can use any other method or tool you like such as curl or httpies.

# Step by Step Tutorial

## 1. Convert Your Content to Our Format

The batch import works by uploading a JSON lines file, also known as an NDJSON or new line delimited JSON file. Each line of the file contains a JSON object representing a single document or page, in the same format used by the [Content Management API](🔗).

You can follow our detailed Recipe on what each field means in the batch import format:

Import batch of content
Open Recipe

In case you just want to see it working for yourself and quickly try out with some dummy content, consider the following example (here represented as a regular JSON array for readability) for a channel named "my-channel":

When converted to NDJSON (for example using this [JSON to NDJSON Online Converter](🔗)) it looks like this:

Save the above NDJSON data to a file, for example `content.ndjson`.

## 2. Create a Development Project

The content must be imported into a specific [development project](🔗). This constraint is to guarantee that all operations are performed without having any chances of affecting the live website, since all write operations are performed on the unpublished variant of a page or document associated with the development project.

Therefore the first step is to create a development project and add your channel to the project. You can do this using the [Projects](🔗) app in the UI or using the [Management APIs](🔗).

To create a new development project, use a POST request to the [Project Management API](🔗)'s [Project endpoint](🔗):

Use the following JSON payload:

You should receive a 201 response with a body similar to the following:

Note the project ID (`vTnTj` in the example above), you'll need it in the next steps.

Now add your channel to the project using the [Site Management API](🔗)'s [Channels endpoint](🔗):

Use the following JSON payload, substituting in the IDs of your project and your channel:

You'll need the project ID for the actual content import. If you used to UI to create the project and add your channel, you can retrieve the project ID (for example `vTnTj`) in the _Projects_ app, the _Site development_ app, or the [Site Management API](🔗).

In the latter case, use the endpoint [Get all channels](🔗).

The channel's `branch` property contains the project ID.

## 3. Import Content into the Development Project

Send a POST request to the [Content Batch Import API](🔗)'s [Create content endpoint](🔗), uploading the previously saved NDJSON file as body:

(Make sure to substitute your project ID)

When sending the content, no validation is performed against the content model.

You'll receive a response similar to the following:

Note the `operationId`, you'll need this in the next step.

## 4. Check the Status of the Import via API

You can retrieve a list of all import operations via [List all operations](🔗). This will return a list of IDs that represent the jobs that are running

Then, you can get the details of each of the jobs using the [Get operation details](🔗) endpoint, substituting in your import operation's ID:

You should receive a response similar to the one below. If there were any errors, they are listed in the `errorLog` array.

## 5. Check the Imported Content in the UI

Using the _Projects_ app, you can preview the imported pages and documents in the development project and approve them so that a merge can be done.

## 6. Merge the Project

When merging the development project, all the imported content will be published into Core.

You can also use the Project Management API to approve all changes and merge the project in a single request:

Use the following JSON payload:

# Error Handling

In case something goes wrong during the batch import process, there is the option of [deleting](🔗) the project before it's merged and starting over from scratch in a new development project.