Saving Category through API
You can get any validations errors on the category after you've attempted to save it with CategoryModel::getAllErrors() or \CModel::getErrors(). 

You're also setting the groupId on the Category's ContentModel, but this property is actually on the Category record itself as it sets the relationship directly.

$category = new CategoryModel();
$category-&gt;groupId = $this-&gt;category_group_id;

$category-&gt;SetContentFromPost(array(
    'title' =&gt; $data[0],
    'colorCode' =&gt; $data[1],
    'colorPreview' =&gt; $data[2],
));

if (craft()-&gt;categories-&gt;saveCategory($category))
{
    return true;
}
else
{
    // dump the error messages
    Craft::dd($category-&gt;getAllErrors());
}