---
type: api
title: Applies a bulk action to multiple Knowledge Base Entries
description: The bulk action is applied to all Knowledge Base Entries that match the filter or to the list of Knowledge Base Entries by their IDs.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-performknowledgebaseentrybulkaction
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-performknowledgebaseentrybulkaction
products:
  - Kibana
---

# Applies a bulk action to multiple Knowledge Base Entries

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/security_ai_assistant/knowledge_base/entries/_bulk_action`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v0/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v0/authentication#basicauth)

## Description

The bulk action is applied to all Knowledge Base Entries that match the filter or to the list of Knowledge Base Entries by their IDs.

## Request Body

`application/json`

- `create` ([] union) — optional
  List of Knowledge Base Entries to create.
  - **DocumentEntryCreateFields**
    - `global` (boolean) — optional
      Whether this Knowledge Base Entry is global, defaults to false.
    - `name` (string) — required
      Name of the Knowledge Base Entry.
    - `namespace` (string) — optional
      Kibana Space, defaults to 'default' space.
    - `users` ([] object) — optional
      Users who have access to the Knowledge Base Entry, defaults to current user. Empty array provides access to all users.
      - `id` (string) — optional
        User id.
      - `name` (string) — optional
        User name.
    - `kbResource` (enum) — required
      Knowledge Base resource name for grouping entries, e.g. 'security_labs', 'user', etc.
      Values: `security_labs`, `defend_insights`, `user`
    - `source` (string) — required
      Source document name or filepath.
    - `text` (string) — required
      Knowledge Base Entry content.
    - `type` (enum) — required
      Entry type.
      Values: `document`
    - `required` (boolean) — optional
      Whether this resource should always be included, defaults to false.
    - `vector` ({}) — optional
      Object containing Knowledge Base Entry text embeddings and modelId used to create the embeddings.
      - `modelId` (string) — required
        ID of the model used to create the embeddings.
      - `tokens` (map string to number) — required
        Tokens with their corresponding values.
  - **IndexEntryCreateFields**
    - `global` (boolean) — optional
      Whether this Knowledge Base Entry is global, defaults to false.
    - `name` (string) — required
      Name of the Knowledge Base Entry.
    - `namespace` (string) — optional
      Kibana Space, defaults to 'default' space.
    - `users` ([] object) — optional
      Users who have access to the Knowledge Base Entry, defaults to current user. Empty array provides access to all users.
      - `id` (string) — optional
        User id.
      - `name` (string) — optional
        User name.
    - `description` (string) — required
      Description for when this index or data stream should be queried for Knowledge Base content. Passed to the LLM as a tool description.
    - `field` (string) — required
      Field to query for Knowledge Base content.
    - `index` (string) — required
      Index or Data Stream to query for Knowledge Base content.
    - `queryDescription` (string) — required
      Description of query field used to fetch Knowledge Base content. Passed to the LLM as part of the tool input schema.
    - `type` (enum) — required
      Entry type.
      Values: `index`
    - `inputSchema` ([] object) — optional
      Array of objects defining the input schema, allowing the LLM to extract structured data to be used in retrieval.
      - `description` (string) — required
        Description of the field.
      - `fieldName` (string) — required
        Name of the field.
      - `fieldType` (string) — required
        Type of the field.
    - `outputFields` ([] string) — optional
      Fields to extract from the query result, defaults to all fields if not provided or empty.
- `delete` (object) — optional
  - `ids` ([] string · min: 1) — optional
    Array of Knowledge Base Entry IDs.
  - `query` (string) — optional
    Query to filter Knowledge Base Entries.
- `update` ([] union) — optional
  List of Knowledge Base Entries to update.
  - **DocumentEntryUpdateFields**
    - `global` (boolean) — optional
      Whether this Knowledge Base Entry is global, defaults to false.
    - `id` (string · min: 1) — required
      A string that does not contain only whitespace characters.
    - `name` (string) — required
      Name of the Knowledge Base Entry.
    - `namespace` (string) — optional
      Kibana Space, defaults to 'default' space.
    - `users` ([] object) — optional
      Users who have access to the Knowledge Base Entry, defaults to current user. Empty array provides access to all users.
      - `id` (string) — optional
        User id.
      - `name` (string) — optional
        User name.
    - `kbResource` (enum) — required
      Knowledge Base resource name for grouping entries, e.g. 'security_labs', 'user', etc.
      Values: `security_labs`, `defend_insights`, `user`
    - `source` (string) — required
      Source document name or filepath.
    - `text` (string) — required
      Knowledge Base Entry content.
    - `type` (enum) — required
      Entry type.
      Values: `document`
    - `required` (boolean) — optional
      Whether this resource should always be included, defaults to false.
    - `vector` ({}) — optional
      Object containing Knowledge Base Entry text embeddings and modelId used to create the embeddings.
      - `modelId` (string) — required
        ID of the model used to create the embeddings.
      - `tokens` (map string to number) — required
        Tokens with their corresponding values.
  - **IndexEntryUpdateFields**
    - `global` (boolean) — optional
      Whether this Knowledge Base Entry is global, defaults to false.
    - `id` (string · min: 1) — required
      A string that does not contain only whitespace characters.
    - `name` (string) — required
      Name of the Knowledge Base Entry.
    - `namespace` (string) — optional
      Kibana Space, defaults to 'default' space.
    - `users` ([] object) — optional
      Users who have access to the Knowledge Base Entry, defaults to current user. Empty array provides access to all users.
      - `id` (string) — optional
        User id.
      - `name` (string) — optional
        User name.
    - `description` (string) — required
      Description for when this index or data stream should be queried for Knowledge Base content. Passed to the LLM as a tool description.
    - `field` (string) — required
      Field to query for Knowledge Base content.
    - `index` (string) — required
      Index or Data Stream to query for Knowledge Base content.
    - `queryDescription` (string) — required
      Description of query field used to fetch Knowledge Base content. Passed to the LLM as part of the tool input schema.
    - `type` (enum) — required
      Entry type.
      Values: `index`
    - `inputSchema` ([] object) — optional
      Array of objects defining the input schema, allowing the LLM to extract structured data to be used in retrieval.
      - `description` (string) — required
        Description of the field.
      - `fieldName` (string) — required
        Name of the field.
      - `fieldType` (string) — required
        Type of the field.
    - `outputFields` ([] string) — optional
      Fields to extract from the query result, defaults to all fields if not provided or empty.

## Responses

#### `200`

Successful bulk operation request

`application/json`

- `attributes` (object)
  - `errors` ([] object)
    List of errors encountered during the bulk action.
    - `err_code` (string)
      Specific error code for the issue.
    - `knowledgeBaseEntries` ([] object)
      List of Knowledge Base Entries that encountered the error.
      - `id` (string)
        ID of the Knowledge Base Entry that encountered an error.
      - `name` (string)
        Name of the Knowledge Base Entry that encountered an error.
    - `message` (string)
      Error message describing the issue.
    - `statusCode` (integer)
      HTTP status code associated with the error.
  - `results` ({})
    - `created` ([] union)
      List of Knowledge Base Entries that were successfully created.
      - **DocumentEntry**
        - `global` (boolean)
          Whether this Knowledge Base Entry is global, defaults to false.
        - `name` (string)
          Name of the Knowledge Base Entry.
        - `namespace` (string)
          Kibana Space, defaults to 'default' space.
        - `users` ([] object)
          Users who have access to the Knowledge Base Entry, defaults to current user. Empty array provides access to all users.
          - `id` (string)
            User id.
          - `name` (string)
            User name.
        - `createdAt` (string)
          Time the Knowledge Base Entry was created.
        - `createdBy` (string)
          User who created the Knowledge Base Entry.
        - `id` (string · min: 1)
          A string that does not contain only whitespace characters.
        - `updatedAt` (string)
          Time the Knowledge Base Entry was last updated.
        - `updatedBy` (string)
          User who last updated the Knowledge Base Entry.
        - `kbResource` (enum)
          Knowledge Base resource name for grouping entries, e.g. 'security_labs', 'user', etc.
          Values: `security_labs`, `defend_insights`, `user`
        - `source` (string)
          Source document name or filepath.
        - `text` (string)
          Knowledge Base Entry content.
        - `type` (enum)
          Entry type.
          Values: `document`
        - `required` (boolean)
          Whether this resource should always be included, defaults to false.
        - `vector` ({})
          Object containing Knowledge Base Entry text embeddings and modelId used to create the embeddings.
          - `modelId` (string)
            ID of the model used to create the embeddings.
          - `tokens` (map string to number)
            Tokens with their corresponding values.
      - **IndexEntry**
        - `global` (boolean)
          Whether this Knowledge Base Entry is global, defaults to false.
        - `name` (string)
          Name of the Knowledge Base Entry.
        - `namespace` (string)
          Kibana Space, defaults to 'default' space.
        - `users` ([] object)
          Users who have access to the Knowledge Base Entry, defaults to current user. Empty array provides access to all users.
          - `id` (string)
            User id.
          - `name` (string)
            User name.
        - `createdAt` (string)
          Time the Knowledge Base Entry was created.
        - `createdBy` (string)
          User who created the Knowledge Base Entry.
        - `id` (string · min: 1)
          A string that does not contain only whitespace characters.
        - `updatedAt` (string)
          Time the Knowledge Base Entry was last updated.
        - `updatedBy` (string)
          User who last updated the Knowledge Base Entry.
        - `description` (string)
          Description for when this index or data stream should be queried for Knowledge Base content. Passed to the LLM as a tool description.
        - `field` (string)
          Field to query for Knowledge Base content.
        - `index` (string)
          Index or Data Stream to query for Knowledge Base content.
        - `queryDescription` (string)
          Description of query field used to fetch Knowledge Base content. Passed to the LLM as part of the tool input schema.
        - `type` (enum)
          Entry type.
          Values: `index`
        - `inputSchema` ([] object)
          Array of objects defining the input schema, allowing the LLM to extract structured data to be used in retrieval.
          - `description` (string)
            Description of the field.
          - `fieldName` (string)
            Name of the field.
          - `fieldType` (string)
            Type of the field.
        - `outputFields` ([] string)
          Fields to extract from the query result, defaults to all fields if not provided or empty.
    - `deleted` ([] string)
      List of IDs of Knowledge Base Entries that were successfully deleted.
    - `skipped` ([] object)
      List of Knowledge Base Entries that were skipped during the bulk action.
      - `id` (string)
        ID of the skipped Knowledge Base Entry.
      - `name` (string)
        Name of the skipped Knowledge Base Entry.
      - `skip_reason` (enum)
        Reason why a Knowledge Base Entry was skipped during the bulk action.
        Values: `KNOWLEDGE_BASE_ENTRY_NOT_MODIFIED`
    - `updated` ([] union)
      List of Knowledge Base Entries that were successfully updated.
      Same options as `created` in `results`
  - `summary` ({})
    - `failed` (integer)
      Number of Knowledge Base Entries that failed during the bulk action.
    - `skipped` (integer)
      Number of Knowledge Base Entries that were skipped during the bulk action.
    - `succeeded` (integer)
      Number of Knowledge Base Entries that were successfully processed during the bulk action.
    - `total` (integer)
      Total number of Knowledge Base Entries involved in the bulk action.
- `knowledgeBaseEntriesCount` (integer)
  Total number of Knowledge Base Entries processed.
- `message` (string)
  Message describing the result of the bulk action.
- `statusCode` (integer)
  HTTP status code of the response.
- `success` (boolean)
  Indicates whether the bulk action was successful.
#### `400`

Bad Request response.

`application/json`

- `error` (string)
  Error type or category.
- `message` (string)
  Detailed error message.
- `statusCode` (number)
  HTTP status code of the error.
## Code Examples

#### curl

```curl
curl \
 --request POST 'http://localhost:5601/api/security_ai_assistant/knowledge_base/entries/_bulk_action' \
 --header "Authorization: $API_KEY" \
 --header "Content-Type: application/json" \
 --data '{"create":[{"name":"Runbook","type":"document","kbResource":"user","source":"manual","text":"Steps to triage an alert."}]}'
```

## Request Examples

#### Perform knowledge base entry bulk action

```json
{
  "create": [
    {
      "kbResource": "user",
      "name": "New Entry",
      "source": "manual",
      "text": "This is the content of the new entry.",
      "type": "document"
    }
  ],
  "delete": {
    "ids": [
      "789"
    ]
  },
  "update": [
    {
      "id": "123",
      "kbResource": "user",
      "name": "Updated Entry",
      "source": "manual",
      "text": "Updated content.",
      "type": "document"
    }
  ]
}
```

## Response Examples

#### Perform knowledge base entry bulk action response200

```json
{
  "attributes": {
    "results": {
      "created": [
        {
          "createdAt": "2024-01-15T10:00:00.000Z",
          "createdBy": "user@example.com",
          "global": false,
          "id": "456",
          "kbResource": "user",
          "name": "New Entry",
          "namespace": "default",
          "source": "manual",
          "text": "This is the content of the new entry.",
          "type": "document",
          "updatedAt": "2024-01-15T10:00:00.000Z",
          "updatedBy": "user@example.com"
        }
      ],
      "deleted": [
        "789"
      ],
      "skipped": [],
      "updated": [
        {
          "createdAt": "2024-01-14T09:00:00.000Z",
          "createdBy": "user@example.com",
          "global": false,
          "id": "123",
          "kbResource": "user",
          "name": "Updated Entry",
          "namespace": "default",
          "source": "manual",
          "text": "Updated content.",
          "type": "document",
          "updatedAt": "2024-01-15T10:00:00.000Z",
          "updatedBy": "user@example.com"
        }
      ]
    },
    "summary": {
      "failed": 0,
      "skipped": 0,
      "succeeded": 3,
      "total": 3
    }
  },
  "knowledgeBaseEntriesCount": 3,
  "message": "Bulk action completed successfully.",
  "statusCode": 200,
  "success": true
}
```

#### Perform knowledge base entry bulk action response400

```json
{
  "error": "Bad Request",
  "message": "Invalid request body.",
  "statusCode": 400
}
```

