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

ParameterTypeRequiredDescription
workspaceIdstring (UUID)YesThe unique identifier of the workspace
knowledgeIdstring (UUID)YesThe unique identifier of the knowledge item

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token with access token
organizationidstring (UUID)YesYour organization ID
Content-TypestringYesMust 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

FieldTypeDescription
idstring (UUID)Knowledge unique identifier
workspaceIdstring (UUID)Parent workspace ID
titlestringKnowledge title
descriptionstringKnowledge description
typestringType: FILE, LINK, or TEXT
statusstringProcessing status
metadataobjectType-specific metadata and custom fields
tagsarray of stringsAssociated tags
categoriesarrayAssigned categories with details
rolesarrayAssigned roles with details (RBAC)
createdAtstring (ISO 8601)Creation timestamp
updatedAtstring (ISO 8601)Last update timestamp
processedAtstring (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