sync_knowledge_base

ArtificialIntelligenceApi.sync_knowledge_base(id, role_id, content_type=None, resource_ids=None, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)

Start a knowledge base sync job

Starts an asynchronous sync and returns JobRunId. Requires editor access. Unstructured: omit SourceIds to sync all attached sources (ExecutionScope KnowledgeBase). If SourceIds is present, those Bedrock source IDs are synced (ExecutionScope Datasource) and must already be attached. Structured: the body is ignored and the whole knowledge base is synced. Fails if a JobRun is already RUNNING, if no sources are attached, or if an unstructured embedding model is not assigned.

Parameters:
  • id (str) – Unique identifier of the knowledge base. (required)

  • role_id (str) – Amorphic role ID of the requesting user. Must be a role the authenticated user belongs to. (required)

  • content_type (str) – Request body media type.

  • resource_ids (ResourceIds) – Optional. Unstructured SourceIds selects specific sources; omit the body or SourceIds to sync all. Ignored for structured knowledge bases.

  • _request_timeout (int, tuple(int, int), optional) – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

  • _request_auth (dict, optional) – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.

  • _content_type (str, Optional) – force content-type for the request.

  • _headers (dict, optional) – set to override the headers for a single request; this effectively ignores the headers in the spec for a single request.

  • _host_index (int, optional) – set to override the host_index for a single request; this effectively ignores the host_index in the spec for a single request.

Return type:

SyncKnowledgeBase200Response

Returns:

Returns the result object.

Request and Response Examples

HTTP: POST /ai/knowledgebases/{id}/sync

Parameter examples

Name

In

Example

Content-Type

header

"application/json"

id

path

"ABCDEFGHIJ"

role_id

header

"custom-role-123e4567-e89b-12d3-a456-426614174000"

Request

Optional. Unstructured SourceIds selects specific sources; omit the body or SourceIds to sync all. Ignored for structured knowledge bases.

The request body is optional.

Sync all attached sources

{}

Sync selected unstructured sources

{
  "SourceIds": [
    "ABCDEFGHIJDS"
  ]
}

Success (HTTP 200)

Sync job started. Returns Message and JobRunId.

Request / response example

{
  "Message": "Knowledge base sync job started successfully",
  "JobRunId": "123e4567-e89b-12d3-a456-426614174000"
}

Errors

Documented error codes: IPV-1002, AI-1009, IPV-1078, AUTH-1001, AUTH-1012, AUTH-1011, GE-1085, DB-1002.

HTTP 400

Input validation or authorization failure. Body is {“Message”: “<CODE> - <text>”}. Codes: IPV-1002 (KB not found), AI-1009 (no sources or embedding model not assigned), IPV-1078 (sync already RUNNING or invalid SourceIds), AUTH-1001 (missing role_id), AUTH-1012 (editor required), AUTH-1011 (caller not authorized).

Missing role_id header

{
  "Message": "AUTH-1001 - Missing role information in event header"
}

Caller not authorized

{
  "Message": "AUTH-1011 - User does not have sufficient permission to perform this action"
}

Sync already in progress

{
  "Message": "IPV-1078 - There is a running sync job for the knowledge base. Please wait for the job to complete before starting a new sync."
}

HTTP 500

Backend failure. Body is {“Message”: “<CODE> - <text>”}. Codes: GE-1085 (unexpected backend failure), DB-1002 (persistence failure).

Unexpected backend failure

{
  "Message": "GE-1085 - An unexpected error occurred"
}