Within Kentico is an app that shows API examples. If you search for API examples from your Kentico desktop then go to Content Management > Tags you will see code for adding tags to pages. I will paste it here, but if you need more help with the API then you can check out more of those examples
private bool AddTagToDocument()
{
TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
// Get the root document
TreeNode root = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/", null, true);
// Get tag group ID
TagGroupInfo updateGroup = TagGroupInfoProvider.GetTagGroupInfo("MyNewGroup", SiteContext.CurrentSiteID);
if ((root != null) && (updateGroup != null))
{
// Add tag to document
root.DocumentTags = "\"My New Tag\"";
// Add tag to document
root.DocumentTagGroupID = updateGroup.TagGroupID;
// Update document
root.Update();
return true;
}
return false;
}