Create a Category

PHP

$endpoint = 'https://app.knowledgeowl.com/api/head/category.json';
  
//base data you will most likely be using for all calls
$stdData = array(
      _authbykey => '[[API KEY]]', 
      project_id => '[[Knowledge Base ID]]' 
    )
  
$catData = $stdData;
   
/* ----------- REQUIRED FIELDS FOR CREATING CATEGORIES --------------- */
//only option here is active or deleted
$catData['status'] = 'active';
//title -- the 'en' designates english to later be able to translate
$catData['name'] = array (
      'en' : '[[Cateogry Title]]'
    );
//can be either basic, content, or faq
$catData['type'] = 'basic';
//can be either public, agents, or custom
$catData['visibility'] = 'public';
//Unique name to locate this category -- must be URI appropriate
$catData['url_hash'] = '[[Permalink]]'; 
   
/* -------------- OPTIONAL FIELDS ------------------------------------ */
//You can make this a subcategory by assiging a parent category ID
$catData["parent_id"]			= '[[Parent Category ID]]';
//Alternate title for the table of contents
$catData["toc_title"]			= '[[Short Title]]';
//Only applicable to FAQ type categoreis -- Either content or description
$catData["faq_display"] 		= [[boolean]];
//FAQ Navigation option to hide children of category in TOC
$catData["toc_hide_children"]	= [[boolean]];
//Short text description of what the category contains -- displayed using FAQ
$catData["description"]			= '[[Description]]';  
//Used to set where this category appears in the TOC
$catData["index"]	= [[Integer]];
//Overrides global_cat_toggle on project to collapse or open category in TOC
$catData["cat_toggle_override"] = '[[open / closed]]';
//Array of custom reader group IDs that can access this category
$catData["reader_roles"]		= ['[[Reader Group ID]]'];
//Don't display this category in the table of contents
$catData["hide_from_toc"]		= [[boolean]];
  
//create a new category
//POST the article
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$catData);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$buffer = curl_exec($ch);
curl_close($ch);