Upload Doc Delete Doc New Category Delete Category List Categories

Delete Document

Remove a specific document from a category by its ID.

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

The unique ID of the document (from JSON "id" field)

PHP Code Example

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

$payload = [
    'category' => 'products',
    'documentId' => 'prod_001'
];

$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 "Document deleted: " . $result['documentId'] . "\n";
} else {
    echo "Error: " . ($result['error'] ?? 'Unknown error') . "\n";
}

/* Success Response (HTTP 200):
{
  "success": true,
  "message": "Document deleted successfully",
  "documentId": "prod_001",
  "category": "products",
  "document": {
    "id": "6e0c8226-6e7a-4d00-9951-d1cd47cc8b51",
    "title": "Product Name",
    "documentId": "prod_001"
  }
}

Error Response (HTTP 404):
{
  "error": "Document 'prod_001' not found in category 'products'"
}

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