Upload Doc Delete Doc New Category Delete Category List Categories

Delete Category

Remove a category and all its documents.

DELETE https://metisai.yoyek.com/api/categories

Warning: Deleting a category will permanently remove ALL documents in that category. This action cannot be undone.

PHP Code Example

<?php
$apiUrl = 'https://metisai.yoyek.com/api/categories';
$apiKey = 'your-api-key-here';

$payload = [
    'category' => 'products'
];

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

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

$result = json_decode($response, true);

if ($httpCode === 200 && $result['success']) {
    echo "Category deleted successfully!\n";
    echo "Category: " . $result['category'] . "\n";
    echo "Documents deleted: " . $result['documentsDeleted'] . "\n";
} else {
    echo "Error: " . ($result['error'] ?? 'Unknown error') . "\n";
}

/* Success Response (HTTP 200):
{
  "success": true,
  "message": "Category 'products' deleted successfully",
  "category": "products",
  "documentsDeleted": 5
}

Error Response (HTTP 404):
{
  "error": "Category 'products' not found for this client"
}

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