Knowledge Library Example

In this example, we create a knowledge library and learn how to work with data categories.

To complete this example, you must first get an access token and set up shell variables, as described in Get Started with ADL API.

This step creates a new knowledge library. You must specify the Knowledge object fields to index. The primaryIndexField1 and primaryIndexField2 fields are required and can’t be changed after creation.

All specified fields must exist on the Knowledge object (KnowledgeKAV) and be text-based types (STRING or TEXTAREA).

The curl command calls the einstein/data-libraries resource. For more information, see ADL Resource Reference in the Connect REST API Developer Guide.

Expected Response: JSON with libraryId and groundingSource fields.

To scope the library to specific data categories, set isDataCategoryRuleEnabled to true and provide either category IDs or category names. You can’t provide both in the same request. Data categories enable you to restrict what the knowledge library is allowed to search, ensuring strict governance.

Using category names (format: groupDeveloperName.categoryDeveloperName):

Using category IDs:

Category names are converted to IDs at creation time. Duplicate entries are silently de-duplicated.

Index the Knowledge articles in the library.

Expected Response: includes { "status": "IN_PROGRESS" }.

This command loops every 10 seconds until the status is READY or FAILED.

Expected Response: After a few minutes, the status transitions to READY. This script exits when the status is READY, FAILED, or all stages report SUCCESS. The READY status requires chunking/embedding to complete for the SearchIndex. ALL_STAGES_SUCCESS means that the ADL pipeline is done even if SearchIndex processing is still pending.

After the library reaches a READY status, you can update contentFields and data category configuration. The primaryIndexField1 and primaryIndexField2 fields are immutable after creation.

You can’t update a library while indexing is in progress.

Expected Response: Updated library details with the new configuration.

Expected Response: Library details including configuration and status.

Expected Response: Status of the library assets.

Expected Response: HTTP Status: 204.

A library can’t be deleted if it’s referenced by active resources such as agents.