Upload Doc Delete Doc New Category Delete Category List Categories

Upload Files

Select JSON files to upload. JSON must be an array with at least id and title properties.

POST https://metisai.yoyek.com/api/documents
Each file must be valid JSON with "id" and "title" fields
Type a category name

PHP Code Example

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

// Read JSON file content
$jsonContent = file_get_contents('/path/to/your/file.json');

// Prepare request payload
$payload = [
    'category' => 'products',
    'files' => [
        [
            'filename' => 'products.json',
            'content' => $jsonContent
        ]
    ]
];

// 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 && $result['success']) {
    echo "Upload successful!\n";
    echo "Total files: " . $result['totalFiles'] . "\n";
    echo "Successful: " . $result['successCount'] . "\n";
    print_r($result['results']);
} else {
    echo "Error: " . ($result['error'] ?? 'Unknown error') . "\n";
}

/* Success Response (HTTP 200):
{
  "success": true,
  "results": [{
    "filename": "products.json",
    "category": "products",
    "success": true,
    "message": "Processed 2 out of 2 records",
    "processedCount": 2,
    "totalRecords": 2
  }],
  "totalFiles": 1,
  "successCount": 1,
  "failureCount": 0
}

Error Response (HTTP 400 - Invalid Category):
{
  "error": "Category 'invalid_category' not found for this client"
}

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