Upload Doc Delete Doc New Category Delete Category List Categories

Create New Category

Create a new category for organizing your documents.

POST https://metisai.yoyek.com/api/categories
Lowercase letters, numbers, and underscores

PHP Code Example

<?php

$apiUrl = 'https://metisai.yoyek.com/api/categories';
$apiKey = 'client-api-key-here';

// Prepare category data
$payload = [
    'name' => 'products',        // Slug (lowercase, underscores)
    'label' => 'Products',       // Display name
    'description' => 'Product catalog and specifications' // Optional
];

// Initialize cURL
$ch = curl_init($apiUrl);
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'Accept: application/json',
        'X-API-Key: ' . $apiKey
    ],
    CURLOPT_POSTFIELDS => json_encode($payload)
]);

// Execute request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

// Process response
$result = json_decode($response, true);

if (($httpCode === 200 || $httpCode === 201) && $result['success']) {
    echo "Category created successfully!\n";
    echo "Category: " . $result['category']['name'] . "\n";
    echo "Label: " . $result['category']['label'] . "\n";
} else {
    echo "Error: " . ($result['error'] ?? 'Unknown error') . "\n";
}

/* Success Response (HTTP 201):
{
  "success": true,
  "category": {
    "id": "6e0c8226-6e7a-4d00-9951-d1cd47cc8b51",
    "clientId": "8a0d31c1-6029-4b57-930d-5daccfa34edd",
    "name": "products",
    "label": "Products",
    "description": "Product catalog and specifications",
    "active": true,
    "createdAt": "2025-11-04T19:23:34.862Z",
    "updatedAt": "2025-11-04T19:23:34.862Z"
  },
  "message": "Category created successfully"
}

Error Response (HTTP 409 - Duplicate):
{
  "error": "A category with this name already exists for this client"
}

Error Response (HTTP 401):
{
  "error": "Invalid or inactive API key"
}
*/