Manage taxonomies via API

2025/09/11 1:59 PM

Hello,

We are in the process of migrating an old Kentico 11 site to Xperience by Kentico.

Part of this is migrating the media library to a content hub. We want to start using taxonomy (tags) to help categorize the media assets and make it easy for the content editors to manage all the media and its usage.

We've got most of the media library -> content hub migration set up using some basic API calls. We've now reached the taxonomy part (we want to create tags, etc.) but can't seem to find the right part of the API documentation that explains how to do this.

Are we missing something, or are there no docs available for this? If so, when will they become available, and what can we do to keep progressing in the meantime?

Thanks in advance.


Environment

Tags:
Taxonomies C# Software development

Answers

2025/09/11 7:31 PM

Take a look at the Kentico Community Portal, which programmatically assigns taxonomy tags to content items.


var existingBlogType = blogPostContent.BlogPostContentBlogType?.ToList() ?? [];
var existingDXTopics = blogPostContent.CoreTaxonomyDXTopics?.ToList() ?? [];

// ...

var manager = await contentItemManagerCreator.GetContentItemManager();
_ = await manager.TryCreateDraft(blogPostContent.SystemFields.ContentItemID, args.ContentLanguageName);

var data = new ContentItemData(new Dictionary<string, object>
{
    {
        nameof(BlogPostContent.BlogPostContentBlogType),
        currentBlogType
    },
    {
        nameof(BlogPostContent.CoreTaxonomyDXTopics),
        currentDXTopics
    }
});
_ = await manager.TryUpdateDraft(blogPostContent.SystemFields.ContentItemID, args.ContentLanguageName, data);

This code assigns two sets of tags (from different taxonomies) to two fields (BlogPostContentBlogType and CoreTaxonomyDXTopics) of a reusable content item in the Content hub.

2025/09/15 1:20 PM
Accepted answer

After re-reading your question I realize you were asking about the APIs to manage the tags themselves.

You can use a the IInfoProvider<T> generic service and CMS.ContentEngine.TagInfo and TaxonomyInfo APIs.

IInfoProvider<TaxonomyInfo> taxonomyProvider = // Get this service from dependency injection
IInfoProvider<TagInfo> tagProvider = // Get this service from dependency injection

var taxonomy = await taxonomyProvider.GetAsync("Taxonomy_Code_Name");
var existingParentTag = await tagProvider.GetAsync("Tag_Code_Name");
  
var tag = new TagInfo
{
    TagTitle = "Tag display name",
    TagName = "CodeName",
    TagDescription = "brief description",
    TagMetadata = "",
    TagParentID = existingParentTag.TagID,
    TagOrder = 10,
    TagTaxonomyID = taxonomy.TaxonomyID
};

await provider.SetAsync(tag);
2025/09/18 7:29 AM

Thank you Sean, this has helped us to solve this issue. We can now create all the appropriate tags during our (custom) media library migration and tag the content items as we go.

To response this discussion, you have to login first.