REST API Connector

Knowledge Management (KM) REST API Connector

The Leena AI REST API Connector allows enterprise developers to programmatically push articles and attachments into the Leena Knowledge Base. This provides full control over data synchronization from custom CMSs, internal wikis, or proprietary systems.


Getting Started

1. Connection Setup

  1. Navigate to the KM Integration Gallery in your Leena AI dashboard.

  2. Select the Custom API Connector card and click Connect.

  3. In the sidesheet, click Download Credentials.

[!IMPORTANT] A file containing your clientId, clientSecret, username, and password will download automatically. The "Download Credentials" button will disable immediately after download. If credentials are lost, you must disconnect and reset the entire flow.

2. Implementation Sequence (The Correct Flow)

To ensure data integrity, requests must be executed in this specific order:

StepActionEndpointDescription
1Authenticate/oauth/tokenObtain the Bearer token (expires every 30m).
2Push Contentapi/integration/articles/upload/`
4Initial Syncapi/integration/articles/sync/Critical: Triggers the background processing and indexing
5Finalizeapi/integration/articles/sync/complete/`

Technical Reference

Authentication

  • Endpoint: POST https://acl.leena.ai/api/v1.0/oauth/token
  • Header: Authorization: Basic <Base64(clientId:clientSecret)>
{
  "username": "your_provided_username",
  "password": "your_provided_password",
  "grant_type": "password"
}

Article Data Structure (POST .../upload-articles)

FieldTypeRequiredDescription
reference_idStringYesUnique ID (Format: <ArticleId>$<Language>)
nameStringYesTitle of the article
html_contentStringYesBody content in HTML format
attachmentsArrayNoList of attachment_id values from Step 3

Security & Reliability

The "Batch" Rule

[!WARNING] Atomic Integrity: Even if a single attachment fails, the entire batch is marked as failed. Do not call /sync/complete/ if you receive error codes during the upload phase. Instead, retry the complete article unit.

Webhook Verification

If using the V2 Async API, Leena AI sends callbacks to your URL. Verify the X-Leena-Signature header using your clientSecret via HMAC-SHA256.

Retry Strategy (Exponential Backoff)

  • Retry 1: 1s | Retry 2: 2s | Retry 3: 4s | Retry 4: 8s | Retry 5: 16s

Monitoring

  • Sync Logs: Found in the KM module; provides article-level success/failure logs.
  • Downstream: Once /sync/complete/ is successful, articles appear in the Conflict Dashboard and Smart Testing modules.