Importing to Kentico Cloud

If you have a lot of content and want to move it over to your Kentico Cloud project, you can leverage the Content Management API (CM API) to automate a one-time import. This usually means writing a script or an application that parses the content from its original format (be it a database from another CMS, or an XML, CSV or text file) into JSON and sends it to Kentico Cloud.

Premium feature

The Content Management API requires a Professional plan or higher. See Pricing for more details.

Table of contents

In this tutorial, you will import a single content item – imagine it as a single step in a longer content migration process. The Sample Project contains a group of Cafe content items. (If you do not have access to the Sample Project, a subscription admin can generate the project and invite you to it.) Here, you'll add one more coffee shop using the CM API.

Note: This tutorial works with the CM API v1, where you can only import content items, their language variants and assets. If you need to migrate content types or taxonomies (tags), the CM API v2 is available in BETA.

Preparing the structure of your project

Before importing your content you need to prepare the structure of your Kentico Cloud project. At minimum, that means defining the content types of the items you want to import and setting your project's languages.

The Sample Project already has the Cafe content type and two languages set up.

You can use a simple POST to /items request to Add the content item. But using an UPSERT operation and defining an external ID for your item has numerous advantages and makes the import process much smoother:

You can run the same request repeatedly. If the item doesn't exist, it will be created. If it does, it will be updated.

You can reference or link to your item, even if it hasn't been imported yet (and has no internal ID or codename). You might have other content items that reference this one in Rich text or Linked items elements. But if you are using external IDs you don't need to worry about the order in which the content items are imported.

Kentico Cloud will generate an internal ID and codename for the content item and include it in the response.

So far, you have only specified general attributes of the content item such as Name, Content type, External ID and Sitemap locations. In the next step, we will add the actual (localized) content.

2. Adding localized content

To add content in a specific language to your new content item, you need to perform another upsert operation.

In REST, this means sending a PUT request to the endpoint specifying the language variant you want to insert or update. The language variant will contain the values of individual content elements.

In the request URL, you need to specify the content item you are importing to (for example, {~/items/external-id/ext-cafe-brno-59713~}) and the language of the variant (for example, {~/variants/codename/en-US~}).

The request body must contain a single attribute, the {~elements~} object. In this object, you specify only the content elements you want to update. Omitted elements will remain unchanged.