Select JSON files to upload. JSON must be an array with at least id and title properties.
<?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"
}
*/
Create a new category for organizing your documents.
<?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"
}
*/
View all available categories for your client.
<?php
$apiUrl = 'https://metisai.yoyek.com/api/categories';
$apiKey = 'client-api-key-here';
// Initialize cURL
$ch = curl_init($apiUrl);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Accept: application/json',
'X-API-Key: ' . $apiKey
]
]);
// 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 "Client: " . $result['clientName'] . "\n";
echo "Total categories: " . count($result['categories']) . "\n\n";
foreach ($result['categories'] as $category) {
echo "Name: " . $category['name'] . "\n";
echo "Label: " . $category['label'] . "\n";
if (!empty($category['description'])) {
echo "Description: " . $category['description'] . "\n";
}
echo "---\n";
}
} else {
echo "Error: " . ($result['error'] ?? 'Unknown error') . "\n";
}
/* Success Response (HTTP 200):
{
"success": true,
"categories": [
{
"id": "35824745-a9a8-4b70-8e49-dd0ba1276912",
"name": "products",
"label": "Products",
"description": "Brick It product catalog"
},
{
"id": "c4ad5b1d-f88f-4908-a990-9985107b41d4",
"name": "documents",
"label": "Documents",
"description": "Technical documents and specifications"
}
],
"count": 2,
"clientId": "8a0d31c1-6029-4b57-930d-5daccfa34edd",
"clientName": "Brick It"
}
Error Response (HTTP 401):
{
"error": "Invalid or inactive API key"
}
*/
Remove a specific document from a category by its ID.
<?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"
}
*/
?>
Remove a category and all its documents.
Warning: Deleting a category will permanently remove ALL documents in that category. This action cannot be undone.
<?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"
}
*/
?>