Import content model
Learn how to import content model using Management API. You'll go step by step and create a basic content type with several elements, a content type snippet, and a taxonomy.
Content model overview
Before creating the content type, create the snippet and taxonomy group. This way you can include them in the type as elements later on. When importing your content, starting with the smaller parts (taxonomy group and snippet with elements) before you tie them together is better. When you think about re-using content, for example, using the same content elements in multiple items, it is easier to create the snippet with those elements and then include the snippet in all types the elements needs to be in. Rather than creating the types and adding the elements to them. In the diagram below, there's a Blogpost type with elements divided in three content groups. The first Content content group has some general fields such as title and blog content. In the Metadata content group, there's a snippet which can be re-used across multiple types. The third group named Topic contains a taxonomy, which can be used for tagging and organizing content.1. Add a content type snippet
Let's start with adding the snippet called Metadata with two elements. To add a snippet, make a POST request with the following properties:- Name which serves as a display name of the snippet.
- An array of content elements you want to have in the snippet.
curl--request POST\
--url https: //manage.kontent.ai/v2/projects/<YOUR_ENVIRONMENT_ID>/snippets \
--header 'Authorization: Bearer <YOUR_MANAGEMENT_API_KEY>'\
--header 'Content-type: application/json'\
--data '
{
"name": "Metadata",
"codename": "metadata",
"elements": [
{
"name": "Title",
"codename": "title",
"type": "text"
},
{
"name": "Keywords",
"codename": "keywords",
"type": "text"
},
{
"name": "Description",
"codename": "description",
"type": "text"
}
]
}'
2. Add a taxonomy group
Now you can move onto adding a taxonomy group along with its terms. In this example, the taxonomy is called blogpost topic with terms like sport and technology stack. Both of these terms will serve as subgroups that will hold actual sports and programming languages. Taxonomies allow you to organize your content into hierarchies. The sample taxonomy hierarchy looks like this:- Blogpost topic
- Sport
- Soccer
- Ice hockey
- Rugby
- Technology stack
- JavaScript
- C#
- MVC
- Sport
- Name which serves as a display name of the taxonomy group.
- An array of taxonomy terms which can have more terms within them, like JavaScript under Technology stack.
curl--request POST\
--url https: //manage.kontent.ai/v2/projects/<YOUR_ENVIRONMENT_ID>/taxonomies \
--header 'Authorization: Bearer <YOUR_MANAGEMENT_API_KEY>'\
--header 'Content-type: application/json'\
--data '
{
"name": "Blogpost topic",
"codename": "blog_topic",
"terms": [
{
"name": "Sport",
"codename": "sport",
"terms": [
{
"name": "Soccer",
"external_id": "soccer",
"terms": []
},
{
"name": "Ice hockey",
"external_id": "hockey",
"terms": []
},
{
"name": "Rugby",
"external_id": "rugby",
"terms": []
}
]
},
{
"name": "Technology stack",
"codename": "tech",
"terms": [
{
"name": "JavaScript",
"codename": "js",
"terms": []
},
{
"name": "C#",
"codename": "c",
"terms": []
},
{
"name": "MVC",
"codename": "mvc",
"terms": []
}
]
}
]
}'
3. Add a content type
Sign in with your Kontent.ai credentials or sign up for free to unlock the full lesson, track your progress, and access exclusive expert insights and tips!