Get Knowledge
Retrieve detailed information about a specific knowledge item.
Endpoint
GET /v1/workspaces/{workspaceId}/knowledge/{knowledgeId}Authentication
Requires API key authentication with a valid access token.
Request
curl -X GET \
'https://api.sharely.ai/v1/workspaces/{workspaceId}/knowledge/{knowledgeId}' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-H 'organizationid: your-organization-id'Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
workspaceId | string (UUID) | Yes | The unique identifier of the workspace |
knowledgeId | string (UUID) | Yes | The unique identifier of the knowledge item |
Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer token with access token |
organizationid | string (UUID) | Yes | Your organization ID |
Content-Type | string | Yes | Must be application/json |
Response
Success Response (200 OK)
{
"id": "knowledge-uuid",
"workspaceId": "workspace-uuid",
"title": "Product Specification v2.0",
"description": "Detailed product specifications",
"type": "FILE",
"status": "COMPLETED",
"metadata": {
"filename": "product-spec-v2.pdf",
"fileSize": 2048576,
"mimeType": "application/pdf",
"language": "en",
"pageCount": 45,
"author": "Product Team"
},
"tags": ["product", "specification", "v2"],
"categories": [
{
"id": "category-uuid",
"name": "Product Documentation"
}
],
"roles": [
{
"id": "role-uuid",
"name": "Product Manager",
"metadata": {
"uniqueCustomerRoleId": "workspace-uuid.product-manager"
}
}
],
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-11-14T15:45:00Z",
"processedAt": "2024-01-15T10:31:30Z"
}Response Fields
| Field | Type | Description |
|---|---|---|
id | string (UUID) | Knowledge unique identifier |
workspaceId | string (UUID) | Parent workspace ID |
title | string | Knowledge title |
description | string | Knowledge description |
type | string | Type: FILE, LINK, or TEXT |
status | string | Processing status |
metadata | object | Type-specific metadata and custom fields |
tags | array of strings | Associated tags |
categories | array | Assigned categories with details |
roles | array | Assigned roles with details (RBAC) |
createdAt | string (ISO 8601) | Creation timestamp |
updatedAt | string (ISO 8601) | Last update timestamp |
processedAt | string (ISO 8601) | Processing completion timestamp |
Example Usage
Get Knowledge Details
const fetch = require('node-fetch');
async function getKnowledge(workspaceId, knowledgeId, accessToken, organizationId) {
const response = await fetch(
`https://api.sharely.ai/v1/workspaces/${workspaceId}/knowledge/${knowledgeId}`,
{
method: 'GET',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'organizationid': organizationId
}
}
);
if (!response.ok) {
throw new Error(`Failed to get knowledge: ${response.status}`);
}
return await response.json();
}Check Processing Status
async function waitForProcessing(workspaceId, knowledgeId, accessToken, organizationId) {
const maxAttempts = 30;
const pollInterval = 2000; // 2 seconds
for (let attempt = 0; attempt < maxAttempts; attempt++) {
const knowledge = await getKnowledge(workspaceId, knowledgeId, accessToken, organizationId);
if (knowledge.status === 'COMPLETED') {
console.log('Knowledge processing complete');
return knowledge;
}
if (knowledge.status === 'FAILED') {
throw new Error('Knowledge processing failed');
}
// Wait before checking again
await new Promise(resolve => setTimeout(resolve, pollInterval));
}
throw new Error('Knowledge processing timeout');
}Display Knowledge Info
async function displayKnowledgeInfo(workspaceId, knowledgeId, accessToken, organizationId) {
const knowledge = await getKnowledge(workspaceId, knowledgeId, accessToken, organizationId);
console.log('Title:', knowledge.title);
console.log('Type:', knowledge.type);
console.log('Status:', knowledge.status);
console.log('Language:', knowledge.metadata.language);
console.log('Categories:', knowledge.categories.map(c => c.name).join(', '));
console.log('Roles:', knowledge.roles.map(r => r.name).join(', '));
console.log('Created:', new Date(knowledge.createdAt).toLocaleString());
}Metadata by Type
FILE Metadata
{
"filename": "document.pdf",
"fileSize": 1048576,
"mimeType": "application/pdf",
"language": "en",
"pageCount": 10,
"wordCount": 2500
}LINK Metadata
{
"url": "https://example.com/article",
"domain": "example.com",
"language": "en",
"lastCrawled": "2024-11-14T15:00:00Z"
}TEXT Metadata
{
"language": "en",
"wordCount": 500,
"characterCount": 3200
}Error Responses
404 Not Found
{
"error": "Not Found",
"message": "Knowledge not found"
}401 Unauthorized
{
"error": "Unauthorized",
"message": "Invalid or missing access token"
}403 Forbidden
{
"error": "Forbidden",
"message": "Insufficient permissions to access this knowledge"
}Related Endpoints
- List Knowledge - Get all knowledge items
- Update Metadata - Update knowledge details
- Delete Knowledge - Remove knowledge
- Assign Roles - Manage RBAC assignments