Creating a content group should occur while adding a new content type via the Management API v2 (documentation here: https://docs.kontent.ai/reference/management-api-v2#operation/add-a-content-type )
From the documentation example, "Article Copy" and "Author" content groups are added to the newly created "Article" content type, and the groups are referenced in each element to indicate which group the respective element should fall under.
In the example from the documentation, focus on:
"content_groups": [
{
"name": "Article copy",
"external_id": "article-copy"
},
{
"name": "Author",
"codename": "author"
}
],
in data and:
"content_group": {
"external_id": "article-copy"
}
for each element in the elements array.
curl --request POST \
--url https://manage.kontent.ai/v2/projects/<YOUR_PROJECT_ID>/types
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-type: application/json' \
--data '
{
"external_id": "article",
"name": "Article",
"codename": "my_article",
"content_groups": [
{
"name": "Article copy",
"external_id": "article-copy"
},
{
"name": "Author",
"codename": "author"
}
],
"elements": [
{
"name": "Article title",
"codename": "title",
"type": "text",
"content_group": {
"external_id": "article-copy"
}
},
{
"name": "Article body",
"codename": "body",
"type": "rich_text",
"content_group": {
"external_id": "article-copy"
}
},
{
"name": "Author bio",
"codename": "bio",
"allowed_blocks": [
"images",
"text"
],
"type": "rich_text",
"content_group": {
"codename": "author"
}
}
]
}'