ListsClient

Client for the Kibana Security Lists API.

Value lists hold values of a single Elasticsearch type (ip, keyword, ip_range, …) that Security detection rule exceptions can reference, e.g. a list of known-bad IP addresses. A value list is a container; the individual values live in list items, which can be managed one by one or imported from a newline-separated text file.

Value lists are stored in per-space .lists-<space> and .items-<space> data streams that must exist before lists can be created. All Lists APIs are space-scoped: every method accepts an optional space_id to target a specific space.

class kibana._sync.client.lists.ListsClient(client, default_space_id=None, validate_spaces=True)[source]

Bases: NamespaceClient

Client for the Kibana Security Lists API.

Value lists (/api/lists) hold values of a single Elasticsearch type (ip, keyword, ip_range, …) that Security detection rule exceptions can reference, e.g. a list of malicious IP addresses. A value list is a container; the individual values live in list items (/api/lists/items), which can be managed one by one or imported from a newline-separated text file.

Value lists are stored in per-space .lists-<space> and .items-<space> data streams that must exist before lists can be created; see create_index() and get_index_status().

All Lists APIs are space-scoped: every method accepts an optional space_id to target a specific space (None targets the default space or the space the client is scoped to).

Example

>>> from kibana import Kibana
>>> client = Kibana("http://localhost:5601", api_key="...")
>>>
>>> # Make sure the value list data streams exist
>>> status = client.lists.get_index_status()
>>>
>>> # Create a list of bad IPs and add a value
>>> created = client.lists.create(
...     name="Bad ips", description="Known bad IPs", type="ip"
... )
>>> list_id = created.body["id"]
>>> client.lists.create_item(list_id=list_id, value="192.0.2.1")
>>>
>>> # Export the values and clean up
>>> exported = client.lists.export_items(list_id=list_id)
>>> client.lists.delete(id=list_id)

Preparing the Value List Data Streams

from kibana import Kibana
from kibana.exceptions import NotFoundError

client = Kibana("http://localhost:5601", api_key="your_api_key")

# Value lists live in per-space data streams; create them once
try:
    status = client.lists.get_index_status()
except NotFoundError:
    client.lists.create_index()

Managing Value Lists

# Create a list of bad IPs
created = client.lists.create(
    name="Bad ips",
    description="Known bad IP addresses",
    type="ip",
    id="bad-ips",
)

# Read, replace, patch and search
fetched = client.lists.get(id="bad-ips")
client.lists.update(
    id="bad-ips",
    name="Bad ips - updated",
    description="Latest bad IPs",
    _version=fetched.body["_version"],
)
client.lists.patch(id="bad-ips", name="Bad ips - patched")
found = client.lists.find(filter="type:ip", per_page=50)

# Deleting a list also deletes all of its items
client.lists.delete(id="bad-ips")

Managing List Items

# Add individual values
item = client.lists.create_item(
    list_id="bad-ips", value="192.0.2.1", refresh="wait_for"
)

# Look items up by ID, or by list_id + value (returns an array)
by_id = client.lists.get_item(id=item.body["id"])
by_value = client.lists.get_item(list_id="bad-ips", value="192.0.2.1")

# Update / patch / delete
client.lists.update_item(id=item.body["id"], value="192.0.2.2")
client.lists.patch_item(id=item.body["id"], value="192.0.2.3")
client.lists.delete_item(list_id="bad-ips", value="192.0.2.3")

# Paginate through a list's items
page = client.lists.find_items(list_id="bad-ips", per_page=100)

Importing and Exporting Values

# Import values into an existing list (newline-separated upload)
client.lists.import_items(
    file=["198.51.100.1", "198.51.100.2"],
    list_id="bad-ips",
    refresh="wait_for",
)

# Or create a brand-new list from a file: id/name come from filename
client.lists.import_items(
    file="203.0.113.1\n203.0.113.2\n",
    type="ip",
    filename="more-bad-ips.txt",
)

# Export values (one entry per item value)
exported = client.lists.export_items(list_id="bad-ips")
for value in exported:
    print(value)

Privileges

privileges = client.lists.get_privileges()
print(privileges.body["is_authenticated"])
__init__(client, default_space_id=None, validate_spaces=True)[source]

Initialize the ListsClient.

Parameters:
  • client (Kibana) – The parent Kibana client instance to delegate requests to.

  • default_space_id (str | None) – Optional default space ID for all operations.

  • validate_spaces (bool) – Whether to validate space existence before space-scoped operations (default: True).

Example

>>> lists_client = ListsClient(kibana_client)
create(*, name, description, type, id=None, meta=None, version=None, space_id=None, validate_spaces=None)[source]

Create a value list.

POST /api/lists

Creates a new value list container. The value list data streams must exist first (see create_index()); otherwise Kibana responds with a 400 error.

Parameters:
  • name (str) – Value list’s name.

  • description (str) – Describes the value list.

  • type (str) – The Elasticsearch data type of the values the list holds, e.g. "ip", "ip_range", "keyword", "text", "date", "integer", "long", "double", and the other types accepted by the API.

  • id (str | None) – Optional identifier for the list (server-generated when omitted).

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list.

  • version (int | None) – The document version number (defaults to 1).

  • space_id (str | None) – Optional space ID to create the list in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the created list (id, name, description, type, version, _version, created_at/created_by, updated_at/updated_by, tie_breaker_id, immutable).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> created = client.lists.create(
...     name="Bad ips",
...     description="Known bad IPs",
...     type="ip",
...     id="bad-ips",
... )
>>> print(created.body["id"])
bad-ips
get(*, id, space_id=None, validate_spaces=None)[source]

Get value list details.

GET /api/lists

Gets the details of a value list using the list ID.

Parameters:
  • id (str) – Value list’s identifier.

  • space_id (str | None) – Optional space ID to read the list from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the value list.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> fetched = client.lists.get(id="bad-ips")
>>> print(fetched.body["type"])
ip
update(*, id, name, description, _version=None, meta=None, version=None, space_id=None, validate_spaces=None)[source]

Update a value list.

PUT /api/lists

Updates a value list using the list id. The original list is replaced, and all unspecified fields are deleted. You cannot modify the id value.

Parameters:
  • id (str) – Value list’s identifier.

  • name (str) – Value list’s name.

  • description (str) – Describes the value list.

  • _version (str | None) – The version id returned when the list was retrieved. Use it to ensure updates are done against the latest version.

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list.

  • version (int | None) – The document version number.

  • space_id (str | None) – Optional space ID to update the list in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the updated value list.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> updated = client.lists.update(
...     id="bad-ips",
...     name="Bad ips - updated",
...     description="Latest list of bad IPs",
... )
>>> print(updated.body["name"])
Bad ips - updated
patch(*, id, name=None, description=None, meta=None, _version=None, version=None, space_id=None, validate_spaces=None)[source]

Patch a value list.

PATCH /api/lists

Updates specific fields of an existing list using the list id; unspecified fields keep their current values.

Parameters:
  • id (str) – Value list’s identifier.

  • name (str | None) – New value list’s name.

  • description (str | None) – New description for the value list.

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list.

  • _version (str | None) – The version id returned when the list was retrieved. Use it to ensure updates are done against the latest version.

  • version (int | None) – The document version number.

  • space_id (str | None) – Optional space ID to patch the list in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the patched value list.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> patched = client.lists.patch(id="bad-ips", name="New name")
>>> print(patched.body["name"])
New name
delete(*, id, delete_references=None, ignore_references=None, space_id=None, validate_spaces=None)[source]

Delete a value list.

DELETE /api/lists

Deletes a value list using the list ID. When you delete a list, all of its list items are also deleted.

Parameters:
  • id (str) – Value list’s identifier.

  • delete_references (bool | None) – Determines whether exception items referencing this value list should be deleted (default: false).

  • ignore_references (bool | None) – Determines whether to delete the value list without performing any additional checks of where this list may be utilized (default: false).

  • space_id (str | None) – Optional space ID to delete the list from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the deleted value list.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> deleted = client.lists.delete(id="bad-ips")
>>> print(deleted.body["id"])
bad-ips
find(*, page=None, per_page=None, sort_field=None, sort_order=None, cursor=None, filter=None, space_id=None, validate_spaces=None)[source]

Get value lists.

GET /api/lists/_find

Gets a paginated subset of value lists. By default, the first page is returned, with 20 results per page.

Parameters:
  • page (int | None) – The page number to return.

  • per_page (int | None) – The number of value lists to return per page.

  • sort_field (str | None) – Determines which field is used to sort the results.

  • sort_order (str | None) – Determines the sort order ("asc" or "desc").

  • cursor (str | None) – Returns the lists that come after the last list returned in the previous call (use the cursor value returned in the previous response).

  • filter (str | None) – Filters the returned results according to the value of the specified field, using the <field>:<value> syntax.

  • space_id (str | None) – Optional space ID to search in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with data (array of lists), page, per_page, total and cursor.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> found = client.lists.find(filter="type:ip", per_page=50)
>>> print(found.body["total"])
1
create_index(*, space_id=None, validate_spaces=None)[source]

Create value list data streams.

POST /api/lists/index

Creates the .lists-<space> and .items-<space> data streams that store value lists and their items in the target space. On Kibana 9.4.3 this call is idempotent and responds with {"acknowledged": true} even when the data streams already exist.

Parameters:
  • space_id (str | None) – Optional space ID to create the data streams in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with {"acknowledged": true}.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> result = client.lists.create_index()
>>> print(result.body["acknowledged"])
True
get_index_status(*, space_id=None, validate_spaces=None)[source]

Get the status of value list data streams.

GET /api/lists/index

Verifies that the .lists-<space> and .items-<space> data streams exist in the target space.

Parameters:
  • space_id (str | None) – Optional space ID to check.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with list_index and list_item_index booleans.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> status = client.lists.get_index_status()
>>> print(status.body["list_index"], status.body["list_item_index"])
True True
delete_index(*, space_id=None, validate_spaces=None)[source]

Delete value list data streams.

DELETE /api/lists/index

Deletes the .lists-<space> and .items-<space> data streams of the target space and all value lists and list items stored in them. Use with extreme caution: any detection rule exceptions that reference value lists in this space stop matching.

Parameters:
  • space_id (str | None) – Optional space ID whose data streams should be deleted.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with {"acknowledged": true}.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> result = client.lists.delete_index(space_id="sandbox")
>>> print(result.body["acknowledged"])
True
create_item(*, list_id, value, id=None, meta=None, refresh=None, space_id=None, validate_spaces=None)[source]

Create a value list item.

POST /api/lists/items

Creates a value list item and associates it with the specified value list. All list items in the same list must be the same type; e.g. each list item in an ip list must define a specific IP address.

Parameters:
  • list_id (str) – Value list’s identifier.

  • value (str) – The value used to evaluate exceptions.

  • id (str | None) – Optional identifier for the item (server-generated when omitted).

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list item.

  • refresh (str | None) – Determines when changes made by the request are made visible to search: "true", "false" or "wait_for".

  • space_id (str | None) – Optional space ID to create the item in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the created list item (id, list_id, type, value, _version, timestamps).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> item = client.lists.create_item(
...     list_id="bad-ips", value="192.0.2.1", refresh="wait_for"
... )
>>> print(item.body["value"])
192.0.2.1
get_item(*, id=None, list_id=None, value=None, space_id=None, validate_spaces=None)[source]

Get a value list item.

GET /api/lists/items

Gets the details of a value list item, either by the item’s id or by the pair of its list’s list_id and the item value.

Parameters:
  • id (str | None) – Value list item’s identifier. Required if list_id and value are not specified.

  • list_id (str | None) – Value list’s identifier. Required if id is not specified.

  • value (str | None) – The item value to look up. Required if id is not specified.

  • space_id (str | None) – Optional space ID to read the item from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the list item when queried by id, or an array of matching list items when queried by list_id and value.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> items = client.lists.get_item(
...     list_id="bad-ips", value="192.0.2.1"
... )
>>> print(items.body[0]["value"])
192.0.2.1
update_item(*, id, value, _version=None, meta=None, space_id=None, validate_spaces=None)[source]

Update a value list item.

PUT /api/lists/items

Updates a value list item using the list item ID. The original item is replaced, and all unspecified fields are deleted. You cannot modify the id value.

Parameters:
  • id (str) – Value list item’s identifier.

  • value (str) – The new value used to evaluate exceptions.

  • _version (str | None) – The version id returned when the item was retrieved. Use it to ensure updates are done against the latest version.

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list item.

  • space_id (str | None) – Optional space ID to update the item in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the updated list item.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> updated = client.lists.update_item(
...     id="item-id", value="192.0.2.2"
... )
>>> print(updated.body["value"])
192.0.2.2
patch_item(*, id, value=None, meta=None, _version=None, refresh=None, space_id=None, validate_spaces=None)[source]

Patch a value list item.

PATCH /api/lists/items

Updates specific fields of an existing value list item using the item id; unspecified fields keep their current values.

Parameters:
  • id (str) – Value list item’s identifier.

  • value (str | None) – The new value used to evaluate exceptions.

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list item.

  • _version (str | None) – The version id returned when the item was retrieved. Use it to ensure updates are done against the latest version.

  • refresh (str | None) – Determines when changes made by the request are made visible to search: "true", "false" or "wait_for".

  • space_id (str | None) – Optional space ID to patch the item in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the patched list item.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> patched = client.lists.patch_item(
...     id="item-id", value="192.0.2.3"
... )
>>> print(patched.body["value"])
192.0.2.3
delete_item(*, id=None, list_id=None, value=None, refresh=None, space_id=None, validate_spaces=None)[source]

Delete a value list item.

DELETE /api/lists/items

Deletes a value list item, either by the item’s id or by the pair of its list’s list_id and the item value.

Parameters:
  • id (str | None) – Value list item’s identifier. Required if list_id and value are not specified.

  • list_id (str | None) – Value list’s identifier. Required if id is not specified.

  • value (str | None) – The item value to delete. Required if id is not specified.

  • refresh (str | None) – Determines when changes made by the request are made visible to search: "true", "false" or "wait_for" (default: "false").

  • space_id (str | None) – Optional space ID to delete the item from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the deleted list item when queried by id, or an array of deleted list items when queried by list_id and value.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> deleted = client.lists.delete_item(
...     list_id="bad-ips", value="192.0.2.1"
... )
find_items(*, list_id, page=None, per_page=None, sort_field=None, sort_order=None, cursor=None, filter=None, space_id=None, validate_spaces=None)[source]

Get value list items.

GET /api/lists/items/_find

Gets a paginated subset of the value list items of a list. By default, the first page is returned, with 20 results per page.

Parameters:
  • list_id (str) – Value list’s identifier.

  • page (int | None) – The page number to return.

  • per_page (int | None) – The number of list items to return per page.

  • sort_field (str | None) – Determines which field is used to sort the results.

  • sort_order (str | None) – Determines the sort order ("asc" or "desc").

  • cursor (str | None) – Returns the items that come after the last item returned in the previous call (use the cursor value returned in the previous response).

  • filter (str | None) – Filters the returned results according to the value of the specified field, using the <field>:<value> syntax.

  • space_id (str | None) – Optional space ID to search in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with data (array of list items), page, per_page, total and cursor.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> found = client.lists.find_items(list_id="bad-ips")
>>> print(found.body["total"])
2
export_items(*, list_id, space_id=None, validate_spaces=None)[source]

Export value list items.

POST /api/lists/items/_export

Exports the values of all items of a value list as a newline- separated text file.

Note: Kibana labels the response application/ndjson although the body is a plain newline-separated dump of the raw values (this matches the format import_items() accepts). The parsed response body is a list with one entry per exported value; values that are not valid JSON tokens (e.g. IP addresses) are returned as strings, while values that parse as JSON scalars (e.g. numbers) are returned as their parsed Python type.

Parameters:
  • list_id (str) – The id of the value list to export.

  • space_id (str | None) – Optional space ID to export from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

Response whose body is the list of exported item values (iterate over it, or join with newlines to rebuild the file).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> exported = client.lists.export_items(list_id="bad-ips")
>>> for value in exported:
...     print(value)
192.0.2.1
192.0.2.2
import_items(*, file, list_id=None, type=None, refresh=None, filename='import.txt', space_id=None, validate_spaces=None)[source]

Import value list items.

POST /api/lists/items/_import

Imports a list of item values from a newline-separated .txt or .csv file (uploaded as multipart/form-data). Values are imported into an existing list when list_id is given; otherwise a new list is created with id and name taken from filename and the type given by type.

Parameters:
  • file (bytes | str | list[str]) – The file content: raw bytes/str of newline- separated values, or a list of values which is encoded one-value-per-line automatically.

  • list_id (str | None) – The id of the list to import items into. Required when importing to an existing list.

  • type (str | None) – The type of the importing list (e.g. "ip", "keyword"). Required when importing a new list, i.e. when list_id is not specified.

  • refresh (str | None) – Determines when changes made by the request are made visible to search: "true", "false" or "wait_for".

  • filename (str) – Filename advertised in the multipart upload. When creating a new list it becomes the list’s id and name.

  • space_id (str | None) – Optional space ID to import into.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the list the items were imported into (the existing list, or the newly created one).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> result = client.lists.import_items(
...     file=["192.0.2.1", "192.0.2.2"],
...     list_id="bad-ips",
...     refresh="wait_for",
... )
>>> print(result.body["id"])
bad-ips
get_privileges(*, space_id=None, validate_spaces=None)[source]

Get value list privileges.

GET /api/lists/privileges

Returns the value list and list item privileges of the calling user, including cluster and index privileges for the underlying data streams.

Parameters:
  • space_id (str | None) – Optional space ID to check privileges in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with lists, listItems and is_authenticated.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> privileges = client.lists.get_privileges()
>>> print(privileges.body["is_authenticated"])
True
perform_request(method, path, *, params=None, headers=None, body=None)

Perform an HTTP request via the parent client with space context enhancement.

Parameters:
  • method (str) – HTTP method (GET, POST, PUT, DELETE, etc.)

  • path (str) – API endpoint path

  • params (dict[str, Any] | None) – Query parameters

  • headers (dict[str, str] | None) – Request headers

  • body (dict[str, Any] | None) – Request body

Returns:

API response

Raises:

ApiError – If the API returns an error response (enhanced with space context)

Return type:

ObjectApiResponse[Any]

AsyncListsClient

Asynchronous version of the ListsClient for use with async/await syntax.

class kibana._async.client.lists.AsyncListsClient(client, default_space_id=None, validate_spaces=True)[source]

Bases: AsyncNamespaceClient

Async client for the Kibana Security Lists API.

Value lists (/api/lists) hold values of a single Elasticsearch type (ip, keyword, ip_range, …) that Security detection rule exceptions can reference, e.g. a list of malicious IP addresses. A value list is a container; the individual values live in list items (/api/lists/items), which can be managed one by one or imported from a newline-separated text file.

Value lists are stored in per-space .lists-<space> and .items-<space> data streams that must exist before lists can be created; see create_index() and get_index_status().

All Lists APIs are space-scoped: every method accepts an optional space_id to target a specific space (None targets the default space or the space the client is scoped to).

Example

>>> from kibana import AsyncKibana
>>> client = AsyncKibana("http://localhost:5601", api_key="...")
>>>
>>> # Make sure the value list data streams exist
>>> status = await client.lists.get_index_status()
>>>
>>> # Create a list of bad IPs and add a value
>>> created = await client.lists.create(
...     name="Bad ips", description="Known bad IPs", type="ip"
... )
>>> list_id = created.body["id"]
>>> await client.lists.create_item(list_id=list_id, value="192.0.2.1")
>>>
>>> # Export the values and clean up
>>> exported = await client.lists.export_items(list_id=list_id)
>>> await client.lists.delete(id=list_id)

Usage

The AsyncListsClient provides the same methods as ListsClient but all methods are async and must be awaited:

from kibana import AsyncKibana
import asyncio

async def main():
    async with AsyncKibana("http://localhost:5601") as client:
        # Create a list and add a value (async)
        created = await client.lists.create(
            name="Bad ips",
            description="Known bad IP addresses",
            type="ip",
        )
        list_id = created.body["id"]
        await client.lists.create_item(
            list_id=list_id, value="192.0.2.1", refresh="wait_for"
        )

        # Export and clean up (async)
        exported = await client.lists.export_items(list_id=list_id)
        await client.lists.delete(id=list_id)

asyncio.run(main())
__init__(client, default_space_id=None, validate_spaces=True)[source]

Initialize the AsyncListsClient.

Parameters:
  • client (AsyncKibana) – The parent AsyncKibana client instance to delegate requests to.

  • default_space_id (str | None) – Optional default space ID for all operations.

  • validate_spaces (bool) – Whether to validate space existence before space-scoped operations (default: True).

Example

>>> lists_client = AsyncListsClient(kibana_client)
async create(*, name, description, type, id=None, meta=None, version=None, space_id=None, validate_spaces=None)[source]

Create a value list.

POST /api/lists

Creates a new value list container. The value list data streams must exist first (see create_index()); otherwise Kibana responds with a 400 error.

Parameters:
  • name (str) – Value list’s name.

  • description (str) – Describes the value list.

  • type (str) – The Elasticsearch data type of the values the list holds, e.g. "ip", "ip_range", "keyword", "text", "date", "integer", "long", "double", and the other types accepted by the API.

  • id (str | None) – Optional identifier for the list (server-generated when omitted).

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list.

  • version (int | None) – The document version number (defaults to 1).

  • space_id (str | None) – Optional space ID to create the list in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the created list (id, name, description, type, version, _version, created_at/created_by, updated_at/updated_by, tie_breaker_id, immutable).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> created = await client.lists.create(
...     name="Bad ips",
...     description="Known bad IPs",
...     type="ip",
...     id="bad-ips",
... )
>>> print(created.body["id"])
bad-ips
async get(*, id, space_id=None, validate_spaces=None)[source]

Get value list details.

GET /api/lists

Gets the details of a value list using the list ID.

Parameters:
  • id (str) – Value list’s identifier.

  • space_id (str | None) – Optional space ID to read the list from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the value list.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> fetched = await client.lists.get(id="bad-ips")
>>> print(fetched.body["type"])
ip
async update(*, id, name, description, _version=None, meta=None, version=None, space_id=None, validate_spaces=None)[source]

Update a value list.

PUT /api/lists

Updates a value list using the list id. The original list is replaced, and all unspecified fields are deleted. You cannot modify the id value.

Parameters:
  • id (str) – Value list’s identifier.

  • name (str) – Value list’s name.

  • description (str) – Describes the value list.

  • _version (str | None) – The version id returned when the list was retrieved. Use it to ensure updates are done against the latest version.

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list.

  • version (int | None) – The document version number.

  • space_id (str | None) – Optional space ID to update the list in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the updated value list.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> updated = await client.lists.update(
...     id="bad-ips",
...     name="Bad ips - updated",
...     description="Latest list of bad IPs",
... )
>>> print(updated.body["name"])
Bad ips - updated
async patch(*, id, name=None, description=None, meta=None, _version=None, version=None, space_id=None, validate_spaces=None)[source]

Patch a value list.

PATCH /api/lists

Updates specific fields of an existing list using the list id; unspecified fields keep their current values.

Parameters:
  • id (str) – Value list’s identifier.

  • name (str | None) – New value list’s name.

  • description (str | None) – New description for the value list.

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list.

  • _version (str | None) – The version id returned when the list was retrieved. Use it to ensure updates are done against the latest version.

  • version (int | None) – The document version number.

  • space_id (str | None) – Optional space ID to patch the list in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the patched value list.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> patched = await client.lists.patch(id="bad-ips", name="New name")
>>> print(patched.body["name"])
New name
async delete(*, id, delete_references=None, ignore_references=None, space_id=None, validate_spaces=None)[source]

Delete a value list.

DELETE /api/lists

Deletes a value list using the list ID. When you delete a list, all of its list items are also deleted.

Parameters:
  • id (str) – Value list’s identifier.

  • delete_references (bool | None) – Determines whether exception items referencing this value list should be deleted (default: false).

  • ignore_references (bool | None) – Determines whether to delete the value list without performing any additional checks of where this list may be utilized (default: false).

  • space_id (str | None) – Optional space ID to delete the list from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the deleted value list.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> deleted = await client.lists.delete(id="bad-ips")
>>> print(deleted.body["id"])
bad-ips
async find(*, page=None, per_page=None, sort_field=None, sort_order=None, cursor=None, filter=None, space_id=None, validate_spaces=None)[source]

Get value lists.

GET /api/lists/_find

Gets a paginated subset of value lists. By default, the first page is returned, with 20 results per page.

Parameters:
  • page (int | None) – The page number to return.

  • per_page (int | None) – The number of value lists to return per page.

  • sort_field (str | None) – Determines which field is used to sort the results.

  • sort_order (str | None) – Determines the sort order ("asc" or "desc").

  • cursor (str | None) – Returns the lists that come after the last list returned in the previous call (use the cursor value returned in the previous response).

  • filter (str | None) – Filters the returned results according to the value of the specified field, using the <field>:<value> syntax.

  • space_id (str | None) – Optional space ID to search in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with data (array of lists), page, per_page, total and cursor.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> found = await client.lists.find(filter="type:ip", per_page=50)
>>> print(found.body["total"])
1
async create_index(*, space_id=None, validate_spaces=None)[source]

Create value list data streams.

POST /api/lists/index

Creates the .lists-<space> and .items-<space> data streams that store value lists and their items in the target space. On Kibana 9.4.3 this call is idempotent and responds with {"acknowledged": true} even when the data streams already exist.

Parameters:
  • space_id (str | None) – Optional space ID to create the data streams in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with {"acknowledged": true}.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> result = await client.lists.create_index()
>>> print(result.body["acknowledged"])
True
async get_index_status(*, space_id=None, validate_spaces=None)[source]

Get the status of value list data streams.

GET /api/lists/index

Verifies that the .lists-<space> and .items-<space> data streams exist in the target space.

Parameters:
  • space_id (str | None) – Optional space ID to check.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with list_index and list_item_index booleans.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> status = await client.lists.get_index_status()
>>> print(status.body["list_index"], status.body["list_item_index"])
True True
async delete_index(*, space_id=None, validate_spaces=None)[source]

Delete value list data streams.

DELETE /api/lists/index

Deletes the .lists-<space> and .items-<space> data streams of the target space and all value lists and list items stored in them. Use with extreme caution: any detection rule exceptions that reference value lists in this space stop matching.

Parameters:
  • space_id (str | None) – Optional space ID whose data streams should be deleted.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with {"acknowledged": true}.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> result = await client.lists.delete_index(space_id="sandbox")
>>> print(result.body["acknowledged"])
True
async create_item(*, list_id, value, id=None, meta=None, refresh=None, space_id=None, validate_spaces=None)[source]

Create a value list item.

POST /api/lists/items

Creates a value list item and associates it with the specified value list. All list items in the same list must be the same type; e.g. each list item in an ip list must define a specific IP address.

Parameters:
  • list_id (str) – Value list’s identifier.

  • value (str) – The value used to evaluate exceptions.

  • id (str | None) – Optional identifier for the item (server-generated when omitted).

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list item.

  • refresh (str | None) – Determines when changes made by the request are made visible to search: "true", "false" or "wait_for".

  • space_id (str | None) – Optional space ID to create the item in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the created list item (id, list_id, type, value, _version, timestamps).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> item = await client.lists.create_item(
...     list_id="bad-ips", value="192.0.2.1", refresh="wait_for"
... )
>>> print(item.body["value"])
192.0.2.1
async get_item(*, id=None, list_id=None, value=None, space_id=None, validate_spaces=None)[source]

Get a value list item.

GET /api/lists/items

Gets the details of a value list item, either by the item’s id or by the pair of its list’s list_id and the item value.

Parameters:
  • id (str | None) – Value list item’s identifier. Required if list_id and value are not specified.

  • list_id (str | None) – Value list’s identifier. Required if id is not specified.

  • value (str | None) – The item value to look up. Required if id is not specified.

  • space_id (str | None) – Optional space ID to read the item from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the list item when queried by id, or an array of matching list items when queried by list_id and value.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> items = await client.lists.get_item(
...     list_id="bad-ips", value="192.0.2.1"
... )
>>> print(items.body[0]["value"])
192.0.2.1
async update_item(*, id, value, _version=None, meta=None, space_id=None, validate_spaces=None)[source]

Update a value list item.

PUT /api/lists/items

Updates a value list item using the list item ID. The original item is replaced, and all unspecified fields are deleted. You cannot modify the id value.

Parameters:
  • id (str) – Value list item’s identifier.

  • value (str) – The new value used to evaluate exceptions.

  • _version (str | None) – The version id returned when the item was retrieved. Use it to ensure updates are done against the latest version.

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list item.

  • space_id (str | None) – Optional space ID to update the item in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the updated list item.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> updated = await client.lists.update_item(
...     id="item-id", value="192.0.2.2"
... )
>>> print(updated.body["value"])
192.0.2.2
async patch_item(*, id, value=None, meta=None, _version=None, refresh=None, space_id=None, validate_spaces=None)[source]

Patch a value list item.

PATCH /api/lists/items

Updates specific fields of an existing value list item using the item id; unspecified fields keep their current values.

Parameters:
  • id (str) – Value list item’s identifier.

  • value (str | None) – The new value used to evaluate exceptions.

  • meta (dict[str, Any] | None) – Placeholder for metadata about the value list item.

  • _version (str | None) – The version id returned when the item was retrieved. Use it to ensure updates are done against the latest version.

  • refresh (str | None) – Determines when changes made by the request are made visible to search: "true", "false" or "wait_for".

  • space_id (str | None) – Optional space ID to patch the item in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the patched list item.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> patched = await client.lists.patch_item(
...     id="item-id", value="192.0.2.3"
... )
>>> print(patched.body["value"])
192.0.2.3
async delete_item(*, id=None, list_id=None, value=None, refresh=None, space_id=None, validate_spaces=None)[source]

Delete a value list item.

DELETE /api/lists/items

Deletes a value list item, either by the item’s id or by the pair of its list’s list_id and the item value.

Parameters:
  • id (str | None) – Value list item’s identifier. Required if list_id and value are not specified.

  • list_id (str | None) – Value list’s identifier. Required if id is not specified.

  • value (str | None) – The item value to delete. Required if id is not specified.

  • refresh (str | None) – Determines when changes made by the request are made visible to search: "true", "false" or "wait_for" (default: "false").

  • space_id (str | None) – Optional space ID to delete the item from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the deleted list item when queried by id, or an array of deleted list items when queried by list_id and value.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> deleted = await client.lists.delete_item(
...     list_id="bad-ips", value="192.0.2.1"
... )
async find_items(*, list_id, page=None, per_page=None, sort_field=None, sort_order=None, cursor=None, filter=None, space_id=None, validate_spaces=None)[source]

Get value list items.

GET /api/lists/items/_find

Gets a paginated subset of the value list items of a list. By default, the first page is returned, with 20 results per page.

Parameters:
  • list_id (str) – Value list’s identifier.

  • page (int | None) – The page number to return.

  • per_page (int | None) – The number of list items to return per page.

  • sort_field (str | None) – Determines which field is used to sort the results.

  • sort_order (str | None) – Determines the sort order ("asc" or "desc").

  • cursor (str | None) – Returns the items that come after the last item returned in the previous call (use the cursor value returned in the previous response).

  • filter (str | None) – Filters the returned results according to the value of the specified field, using the <field>:<value> syntax.

  • space_id (str | None) – Optional space ID to search in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with data (array of list items), page, per_page, total and cursor.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> found = await client.lists.find_items(list_id="bad-ips")
>>> print(found.body["total"])
2
async export_items(*, list_id, space_id=None, validate_spaces=None)[source]

Export value list items.

POST /api/lists/items/_export

Exports the values of all items of a value list as a newline- separated text file.

Note: Kibana labels the response application/ndjson although the body is a plain newline-separated dump of the raw values (this matches the format import_items() accepts). The parsed response body is a list with one entry per exported value; values that are not valid JSON tokens (e.g. IP addresses) are returned as strings, while values that parse as JSON scalars (e.g. numbers) are returned as their parsed Python type.

Parameters:
  • list_id (str) – The id of the value list to export.

  • space_id (str | None) – Optional space ID to export from.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

Response whose body is the list of exported item values (iterate over it, or join with newlines to rebuild the file).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> exported = await client.lists.export_items(list_id="bad-ips")
>>> for value in exported:
...     print(value)
192.0.2.1
192.0.2.2
async import_items(*, file, list_id=None, type=None, refresh=None, filename='import.txt', space_id=None, validate_spaces=None)[source]

Import value list items.

POST /api/lists/items/_import

Imports a list of item values from a newline-separated .txt or .csv file (uploaded as multipart/form-data). Values are imported into an existing list when list_id is given; otherwise a new list is created with id and name taken from filename and the type given by type.

Parameters:
  • file (bytes | str | list[str]) – The file content: raw bytes/str of newline- separated values, or a list of values which is encoded one-value-per-line automatically.

  • list_id (str | None) – The id of the list to import items into. Required when importing to an existing list.

  • type (str | None) – The type of the importing list (e.g. "ip", "keyword"). Required when importing a new list, i.e. when list_id is not specified.

  • refresh (str | None) – Determines when changes made by the request are made visible to search: "true", "false" or "wait_for".

  • filename (str) – Filename advertised in the multipart upload. When creating a new list it becomes the list’s id and name.

  • space_id (str | None) – Optional space ID to import into.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse containing the list the items were imported into (the existing list, or the newly created one).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> result = await client.lists.import_items(
...     file=["192.0.2.1", "192.0.2.2"],
...     list_id="bad-ips",
...     refresh="wait_for",
... )
>>> print(result.body["id"])
bad-ips
async get_privileges(*, space_id=None, validate_spaces=None)[source]

Get value list privileges.

GET /api/lists/privileges

Returns the value list and list item privileges of the calling user, including cluster and index privileges for the underlying data streams.

Parameters:
  • space_id (str | None) – Optional space ID to check privileges in.

  • validate_spaces (bool | None) – Override space validation setting for this operation.

Returns:

ObjectApiResponse with lists, listItems and is_authenticated.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> privileges = await client.lists.get_privileges()
>>> print(privileges.body["is_authenticated"])
True
async perform_request(method, path, *, params=None, headers=None, body=None)

Perform an async HTTP request via the parent client with space context enhancement.

Parameters:
  • method (str) – HTTP method (GET, POST, PUT, DELETE, etc.)

  • path (str) – API endpoint path

  • params (dict[str, Any] | None) – Query parameters

  • headers (dict[str, str] | None) – Request headers

  • body (dict[str, Any] | None) – Request body

Returns:

API response

Raises:

ApiError – If the API returns an error response (enhanced with space context)

Return type:

ObjectApiResponse[Any]