EndpointClient

Client for the Kibana Security Endpoint Management API.

The Endpoint Management API (/api/endpoint/...) drives Elastic Defend. It lists enrolled endpoint hosts and their metadata, runs response actions against them (isolate/release a host, terminate or suspend a process, list running processes, retrieve or upload a file, run a command or a script, scan for malware, generate a memory dump, or cancel a pending action), inspects action history/status, reads endpoint policy responses, manages the protection-updates note on a Defend package policy, and manages the reusable scripts library.

Response actions require the target hosts to have the Elastic Defend integration installed and enrolled. Against a stack with no enrolled endpoints those routes return an HTTP 400 (The host does not have Elastic Defend integration installed).

All Endpoint Management APIs are space-scoped resources: every method accepts an optional space_id to target a specific space.

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

Bases: NamespaceClient

Client for the Kibana Security Endpoint Management API.

The Endpoint Management API (/api/endpoint/...) drives Elastic Defend: it lists enrolled endpoint hosts and their metadata, runs response actions against them (isolate/release a host, terminate or suspend a process, list running processes, retrieve or upload a file, run a command or a script, scan for malware, generate a memory dump, or cancel a pending action), inspects action history and status, reads endpoint policy responses, manages the protection-updates note on a Defend package policy, and manages the reusable scripts library.

All Endpoint Management 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).

Note

Response actions require the target hosts to have the Elastic Defend integration installed and enrolled. Against a stack with no enrolled endpoints these routes return an HTTP 400 (The host does not have Elastic Defend integration installed).

Example

>>> from kibana import Kibana
>>> client = Kibana("http://localhost:5601", api_key="...")
>>>
>>> # List enrolled endpoint hosts
>>> hosts = client.endpoint.get_metadata_list(host_statuses=["healthy"])
>>>
>>> # Isolate a host
>>> action = client.endpoint.isolate(
...     endpoint_ids=["endpoint-id-1"],
...     comment="Investigating suspicious activity",
... )

Listing Hosts and Actions

from kibana import Kibana

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

# List enrolled endpoint hosts
hosts = client.endpoint.get_metadata_list(
    host_statuses=["healthy"], page_size=50
)
print(hosts.body["total"])

# Metadata for a single host
host = client.endpoint.get_metadata(id="endpoint-id-1")

# Response-actions state and history
state = client.endpoint.get_actions_state()
actions = client.endpoint.get_actions_list(commands=["isolate"])
status = client.endpoint.get_actions_status(agent_ids=["agent-id-1"])
details = client.endpoint.get_action_details(action_id="action-id-1")

Running Response Actions

# Isolate / release a host
client.endpoint.isolate(
    endpoint_ids=["endpoint-id-1"], comment="Investigating"
)
client.endpoint.unisolate(endpoint_ids=["endpoint-id-1"])

# Terminate or suspend a process
client.endpoint.kill_process(
    endpoint_ids=["endpoint-id-1"], parameters={"pid": 123}
)
client.endpoint.suspend_process(
    endpoint_ids=["endpoint-id-1"], parameters={"entity_id": "abc"}
)

# Collect data
client.endpoint.get_running_processes(endpoint_ids=["endpoint-id-1"])
client.endpoint.get_file(
    endpoint_ids=["endpoint-id-1"], parameters={"path": "/etc/passwd"}
)
client.endpoint.execute(
    endpoint_ids=["endpoint-id-1"],
    parameters={"command": "ls -la", "timeout": 600},
)
client.endpoint.scan(
    endpoint_ids=["endpoint-id-1"], parameters={"path": "/opt"}
)

# Upload a file to the host (multipart)
action = client.endpoint.upload(
    endpoint_ids=["endpoint-id-1"],
    file=b"#!/bin/sh\necho hi\n",
    filename="fix.sh",
    parameters={"overwrite": True},
)

# Retrieve a file produced by a get_file / scan action
info = client.endpoint.get_action_file_info(
    action_id="action-id-1", file_id="file-id-1"
)
blob = client.endpoint.download_action_file(
    action_id="action-id-1", file_id="file-id-1"
)

# Cancel a pending action
client.endpoint.cancel(
    endpoint_ids=["endpoint-id-1"], parameters={"id": "action-id-1"}
)

Policy Response and Protection Updates Note

resp = client.endpoint.get_policy_response(agent_id="agent-id-1")

client.endpoint.create_update_protection_updates_note(
    package_policy_id="package-policy-id-1",
    note="Pinned to 2024-01-01 protection artifacts",
)
note = client.endpoint.get_protection_updates_note(
    package_policy_id="package-policy-id-1"
)

Managing the Scripts Library

created = client.endpoint.create_script(
    name="collect-logs",
    platform=["linux"],
    file_type="script",
    file=b"#!/bin/sh\necho hi\n",
    filename="collect.sh",
    tags=["threatHunting"],
)
script_id = created.body["data"]["id"]

client.endpoint.get_scripts(page_size=50)
client.endpoint.get_script(script_id=script_id)
client.endpoint.update_script(
    script_id=script_id, description="Updated"
)
client.endpoint.download_script(script_id=script_id)
client.endpoint.delete_script(script_id=script_id)
__init__(client, default_space_id=None, validate_spaces=True)[source]

Initialize the EndpointClient.

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).

get_metadata_list(*, host_statuses=None, page=None, page_size=None, kuery=None, sort_field=None, sort_direction=None, space_id=None, validate_spaces=None)[source]

Get a metadata list of enrolled endpoint hosts.

GET /api/endpoint/metadata

Parameters:
  • host_statuses (list[str] | None) – Filter by agent health statuses. Any of healthy, offline, updating, inactive, unenrolled. In the 9.4.3 spec this is marked required, but the live server accepts requests without it.

  • page (int | None) – Page number (default 1).

  • page_size (int | None) – Number of items per page (1-100, default 10).

  • kuery (str | None) – A KQL string to filter the hosts.

  • sort_field (str | None) – Field to sort by (e.g. enrolled_at, metadata.host.hostname, host_status, last_checkin).

  • sort_direction (str | None) – asc or desc.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse whose body has data (list of host metadata), total, page, pageSize, sortField and sortDirection.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> hosts = client.endpoint.get_metadata_list(
...     host_statuses=["healthy"], page_size=50
... )
>>> print(hosts.body["total"])
get_metadata(*, id, space_id=None, validate_spaces=None)[source]

Get metadata for a single endpoint host.

GET /api/endpoint/metadata/{id}

Parameters:
  • id (str) – The endpoint host ID.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the host metadata document.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> host = client.endpoint.get_metadata(id="endpoint-id-1")
get_actions_list(*, page=None, page_size=None, commands=None, agent_ids=None, user_ids=None, start_date=None, end_date=None, agent_types=None, with_outputs=None, types=None, space_id=None, validate_spaces=None)[source]

Get a list of all response actions.

GET /api/endpoint/action

Parameters:
  • page (int | None) – Page number.

  • page_size (int | None) – Number of items per page.

  • commands (list[str] | None) – Filter by response action command names (e.g. isolate, unisolate, kill-process, execute).

  • agent_ids (str | list[str] | None) – A single agent ID or list of agent IDs (max 250).

  • user_ids (str | list[str] | None) – A single user ID or list of user IDs (max 50).

  • start_date (str | None) – Start date (ISO 8601 or date-math) to filter actions.

  • end_date (str | None) – End date (ISO 8601 or date-math) to filter actions.

  • agent_types (str | None) – Agent type to filter by (endpoint, sentinel_one, crowdstrike, microsoft_defender_endpoint).

  • with_outputs (str | list[str] | None) – A single action ID or list of action IDs whose full output should be included (max 50).

  • types (list[str] | None) – List of response action types (automated, manual).

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the paginated action list.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> actions = client.endpoint.get_actions_list(
...     commands=["isolate"], page_size=20
... )

Note

On a stack that has never run a response action the backing index does not yet exist and the live server answers HTTP 404 (index_not_found_exception) until the first action is created.

get_actions_status(*, agent_ids, space_id=None, validate_spaces=None)[source]

Get the response actions status for one or more agents.

GET /api/endpoint/action_status

Parameters:
  • agent_ids (str | list[str]) – A single agent ID or list of agent IDs (max 50).

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing per-agent action status data.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> status = client.endpoint.get_actions_status(
...     agent_ids=["agent-id-1", "agent-id-2"]
... )
get_action_details(*, action_id, space_id=None, validate_spaces=None)[source]

Get the details of a single response action.

GET /api/endpoint/action/{action_id}

Parameters:
  • action_id (str) – The ID of the response action.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the action details.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> details = client.endpoint.get_action_details(
...     action_id="action-id-1"
... )
get_actions_state(*, space_id=None, validate_spaces=None)[source]

Get the overall response-actions state.

GET /api/endpoint/action/state

Reports whether the current license/configuration allows response actions to be encrypted (data.canEncrypt).

Parameters:
  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse whose body has data with canEncrypt.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> state = client.endpoint.get_actions_state()
>>> print(state.body["data"]["canEncrypt"])
get_action_file_info(*, action_id, file_id, space_id=None, validate_spaces=None)[source]

Get information about a file produced by a response action.

GET /api/endpoint/action/{action_id}/file/{file_id}

Parameters:
  • action_id (str) – The ID of the response action that produced the file.

  • file_id (str) – The ID of the file.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the file metadata.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> info = client.endpoint.get_action_file_info(
...     action_id="action-id-1", file_id="file-id-1"
... )
download_action_file(*, action_id, file_id, space_id=None, validate_spaces=None)[source]

Download a file produced by a response action.

GET /api/endpoint/action/{action_id}/file/{file_id}/download

The response body is the raw file (typically a password-protected zip archive), returned as bytes.

Parameters:
  • action_id (str) – The ID of the response action that produced the file.

  • file_id (str) – The ID of the file to download.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

Response whose body is the raw file content.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> resp = client.endpoint.download_action_file(
...     action_id="action-id-1", file_id="file-id-1"
... )
>>> open("collected.zip", "wb").write(resp.body)
isolate(*, endpoint_ids, agent_type=None, alert_ids=None, case_ids=None, comment=None, parameters=None, space_id=None, validate_spaces=None)[source]

Isolate one or more endpoint hosts from the network.

POST /api/endpoint/action/isolate

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs to isolate (1-250).

  • agent_type (str | None) – Agent type (endpoint, sentinel_one, crowdstrike, microsoft_defender_endpoint). Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • parameters (dict[str, Any] | None) – Optional parameters object.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.isolate(
...     endpoint_ids=["endpoint-id-1"], comment="Quarantine"
... )
unisolate(*, endpoint_ids, agent_type=None, alert_ids=None, case_ids=None, comment=None, parameters=None, space_id=None, validate_spaces=None)[source]

Release an isolated endpoint host back onto the network.

POST /api/endpoint/action/unisolate

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs to release (1-250).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • parameters (dict[str, Any] | None) – Optional parameters object.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.unisolate(
...     endpoint_ids=["endpoint-id-1"]
... )
kill_process(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Terminate a process on one or more endpoint hosts.

POST /api/endpoint/action/kill_process

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Process selector. One of {"pid": <int>}, {"entity_id": <str>}, or {"process_name": <str>} (process_name is SentinelOne only).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.kill_process(
...     endpoint_ids=["endpoint-id-1"], parameters={"pid": 123}
... )
suspend_process(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Suspend a process on one or more endpoint hosts.

POST /api/endpoint/action/suspend_process

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Process selector. One of {"pid": <int>} or {"entity_id": <str>}.

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.suspend_process(
...     endpoint_ids=["endpoint-id-1"], parameters={"pid": 123}
... )
get_running_processes(*, endpoint_ids, agent_type=None, alert_ids=None, case_ids=None, comment=None, parameters=None, space_id=None, validate_spaces=None)[source]

List the running processes on one or more endpoint hosts.

POST /api/endpoint/action/running_procs

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • parameters (dict[str, Any] | None) – Optional parameters object.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.get_running_processes(
...     endpoint_ids=["endpoint-id-1"]
... )
get_file(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Retrieve a file from one or more endpoint hosts.

POST /api/endpoint/action/get_file

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Must include path (the absolute path of the file to retrieve on the host).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action (poll the file info/download routes with the returned action ID once complete).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.get_file(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"path": "/etc/passwd"},
... )
execute(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Run a shell command on one or more endpoint hosts.

POST /api/endpoint/action/execute

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Must include command (the command line to run) and may include timeout (seconds).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.execute(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"command": "ls -la", "timeout": 600},
... )
scan(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Scan a file or directory on one or more endpoint hosts.

POST /api/endpoint/action/scan

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Must include path (the folder or file to scan).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.scan(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"path": "/opt"},
... )
generate_memory_dump(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Generate a memory dump from one or more endpoint hosts.

POST /api/endpoint/action/memory_dump

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Dump selector. Either {"type": "kernel"} for a full kernel dump, or {"type": "process", "pid": <int>} / {"type": "process", "entity_id": <str>} for a process.

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.generate_memory_dump(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"type": "kernel"},
... )

Note

This action is gated behind a feature flag; on a stack where it is disabled the live server answers HTTP 400 ([request body.agent_type]: feature is disabled).

run_script(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Run a script on one or more endpoint hosts.

POST /api/endpoint/action/run_script

The shape of parameters depends on the agent_type:

  • Elastic Defend (endpoint): {"scriptId": <str>, "scriptInput": <str>} referencing a scripts-library entry.

  • CrowdStrike raw: {"raw": <str>, "commandLine": <str>, "timeout": <int>}.

  • CrowdStrike host path: {"hostPath": <str>, ...}.

  • CrowdStrike cloud file: {"cloudFile": <str>, ...}.

  • SentinelOne / Microsoft Defender variants also supported.

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Script selector (see above).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.run_script(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"scriptId": "script-id-1"},
... )
cancel(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Cancel a pending response action.

POST /api/endpoint/action/cancel

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Must include id (the action ID to cancel).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created cancellation action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.cancel(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"id": "action-id-1"},
... )
upload(*, endpoint_ids, file, filename='upload.bin', agent_type=None, alert_ids=None, case_ids=None, comment=None, parameters=None, space_id=None, validate_spaces=None)[source]

Upload a file to one or more endpoint hosts.

POST /api/endpoint/action/upload

This is a multipart/form-data request: the file bytes are sent in the file part while the action fields are sent as JSON-encoded form parts.

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • file (bytes) – Raw bytes of the file to upload.

  • filename (str) – Filename advertised for the uploaded file part.

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • parameters (dict[str, Any] | None) – Optional parameters object (e.g. {"overwrite": True}).

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = client.endpoint.upload(
...     endpoint_ids=["endpoint-id-1"],
...     file=b"#!/bin/sh\necho hi\n",
...     filename="fix.sh",
...     parameters={"overwrite": True},
... )
get_policy_response(*, agent_id, space_id=None, validate_spaces=None)[source]

Get the most recent policy response for an endpoint host.

GET /api/endpoint/policy_response

Parameters:
  • agent_id (str) – The endpoint agent ID whose policy response to fetch.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the policy response document.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> resp = client.endpoint.get_policy_response(agent_id="agent-1")
get_protection_updates_note(*, package_policy_id, space_id=None, validate_spaces=None)[source]

Get the protection-updates note for a Defend package policy.

GET /api/endpoint/protection_updates_note/{package_policy_id}

Parameters:
  • package_policy_id (str) – The ID of the Elastic Defend package policy.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the note.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> note = client.endpoint.get_protection_updates_note(
...     package_policy_id="policy-id-1"
... )
create_update_protection_updates_note(*, package_policy_id, note=None, space_id=None, validate_spaces=None)[source]

Create or update the protection-updates note for a Defend policy.

POST /api/endpoint/protection_updates_note/{package_policy_id}

Parameters:
  • package_policy_id (str) – The ID of the Elastic Defend package policy.

  • note (str | None) – The note text.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created/updated note.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> client.endpoint.create_update_protection_updates_note(
...     package_policy_id="policy-id-1",
...     note="Pinned to 2024-01-01 protection artifacts",
... )
get_scripts(*, page=None, page_size=None, sort_field=None, sort_direction=None, kuery=None, space_id=None, validate_spaces=None)[source]

Get a list of scripts from the scripts library.

GET /api/endpoint/scripts_library

Parameters:
  • page (int | None) – Page number (default 1).

  • page_size (int | None) – Number of items per page (1-1000, default 10).

  • sort_field (str | None) – Field to sort by (name, createdAt, createdBy, updatedAt, updatedBy, fileSize).

  • sort_direction (str | None) – asc or desc.

  • kuery (str | None) – A KQL query string to filter the scripts.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse whose body has data (list of scripts), total, page, pageSize, sortField and sortDirection.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> scripts = client.endpoint.get_scripts(page_size=50)
>>> print(scripts.body["total"])
get_script(*, script_id, space_id=None, validate_spaces=None)[source]

Get a single script from the scripts library.

GET /api/endpoint/scripts_library/{script_id}

Parameters:
  • script_id (str) – The ID of the script.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the script metadata.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> script = client.endpoint.get_script(script_id="script-id-1")
create_script(*, name, platform, file_type, file, filename='script.sh', description=None, example=None, instructions=None, path_to_executable=None, requires_input=None, tags=None, space_id=None, validate_spaces=None)[source]

Create a script in the scripts library.

POST /api/endpoint/scripts_library

This is a multipart/form-data request: the script/archive bytes are sent in the file part; the platform and tags arrays and the requiresInput boolean are JSON-encoded form parts.

Parameters:
  • name (str) – Name of the script.

  • platform (list[str]) – Platforms supported by the script (any of linux, macos, windows).

  • file_type (str) – script for a single script file, or archive for a .zip (in which case path_to_executable is required).

  • file (bytes) – Raw bytes of the script/archive file.

  • filename (str) – Filename advertised for the uploaded file part.

  • description (str | None) – Description of the script.

  • example (str | None) – Example usage of the script.

  • instructions (str | None) – Usage instructions, including supported input args.

  • path_to_executable (str | None) – For archive uploads, the relative path to the executable within the archive.

  • requires_input (bool | None) – Whether the script requires input arguments.

  • tags (list[str] | None) – Categorization tags. Valid values include remediationAction, dataCollection, networkDiagnostics, networkAction, systemInventory, forensicCollection, threatHunting, discovery, systemManagement, userManagement, troubleshooting.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse whose body has data with the created script, including its id, fileId, fileHash and downloadUri.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> created = client.endpoint.create_script(
...     name="collect-logs",
...     platform=["linux"],
...     file_type="script",
...     file=b"#!/bin/sh\necho hi\n",
...     filename="collect.sh",
... )
>>> print(created.body["data"]["id"])
update_script(*, script_id, file=None, filename='script.sh', name=None, platform=None, file_type=None, description=None, example=None, instructions=None, path_to_executable=None, requires_input=None, tags=None, space_id=None, validate_spaces=None)[source]

Update a script in the scripts library.

PATCH /api/endpoint/scripts_library/{script_id}

This is a multipart/form-data request. All fields are optional; a new file part is only sent when file is provided.

Parameters:
  • script_id (str) – The ID of the script to update.

  • file (bytes | None) – Optional new script/archive bytes.

  • filename (str) – Filename advertised for the uploaded file part (only used when file is provided).

  • name (str | None) – New name.

  • platform (list[str] | None) – New supported platforms.

  • file_type (str | None) – New file type (script or archive).

  • description (str | None) – New description.

  • example (str | None) – New example usage.

  • instructions (str | None) – New usage instructions.

  • path_to_executable (str | None) – New relative path to executable (archives).

  • requires_input (bool | None) – Whether the script requires input arguments.

  • tags (list[str] | None) – New categorization tags.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse whose body has data with the updated script.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> client.endpoint.update_script(
...     script_id="script-id-1",
...     description="Updated description",
... )
delete_script(*, script_id, space_id=None, validate_spaces=None)[source]

Delete a script from the scripts library.

DELETE /api/endpoint/scripts_library/{script_id}

Parameters:
  • script_id (str) – The ID of the script to delete.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse with an empty body on success.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> client.endpoint.delete_script(script_id="script-id-1")
download_script(*, script_id, space_id=None, validate_spaces=None)[source]

Download the file backing a scripts-library entry.

GET /api/endpoint/scripts_library/{script_id}/download

The response body is the raw script/archive file content.

Parameters:
  • script_id (str) – The ID of the script to download.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

Response whose body is the raw file content (the exact type depends on the uploaded file: text scripts come back as str, binary archives as bytes).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> resp = client.endpoint.download_script(script_id="script-id-1")
>>> open("script.sh", "wb").write(
...     resp.body if isinstance(resp.body, bytes)
...     else resp.body.encode()
... )
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]

AsyncEndpointClient

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

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

Bases: AsyncNamespaceClient

Async client for the Kibana Security Endpoint Management API.

The Endpoint Management API (/api/endpoint/...) drives Elastic Defend: it lists enrolled endpoint hosts and their metadata, runs response actions against them (isolate/release a host, terminate or suspend a process, list running processes, retrieve or upload a file, run a command or a script, scan for malware, generate a memory dump, or cancel a pending action), inspects action history and status, reads endpoint policy responses, manages the protection-updates note on a Defend package policy, and manages the reusable scripts library.

All Endpoint Management 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).

Note

Response actions require the target hosts to have the Elastic Defend integration installed and enrolled. Against a stack with no enrolled endpoints these routes return an HTTP 400 (The host does not have Elastic Defend integration installed).

Example

>>> from kibana import AsyncKibana
>>> client = AsyncKibana("http://localhost:5601", api_key="...")
>>>
>>> # List enrolled endpoint hosts
>>> hosts = await client.endpoint.get_metadata_list(host_statuses=["healthy"])
>>>
>>> # Isolate a host
>>> action = await client.endpoint.isolate(
...     endpoint_ids=["endpoint-id-1"],
...     comment="Investigating suspicious activity",
... )

Usage

The AsyncEndpointClient provides the same methods as EndpointClient 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:
        # List hosts and read actions state (async)
        hosts = await client.endpoint.get_metadata_list()
        state = await client.endpoint.get_actions_state()

        # Create and clean up a library script (async)
        created = await client.endpoint.create_script(
            name="collect-logs",
            platform=["linux"],
            file_type="script",
            file=b"#!/bin/sh\necho hi\n",
            filename="collect.sh",
        )
        await client.endpoint.delete_script(
            script_id=created.body["data"]["id"]
        )

        # Isolate a host (async)
        await client.endpoint.isolate(endpoint_ids=["endpoint-id-1"])

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

Initialize the AsyncEndpointClient.

Parameters:
  • client (AsyncKibana) – 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).

async get_metadata_list(*, host_statuses=None, page=None, page_size=None, kuery=None, sort_field=None, sort_direction=None, space_id=None, validate_spaces=None)[source]

Get a metadata list of enrolled endpoint hosts.

GET /api/endpoint/metadata

Parameters:
  • host_statuses (list[str] | None) – Filter by agent health statuses. Any of healthy, offline, updating, inactive, unenrolled. In the 9.4.3 spec this is marked required, but the live server accepts requests without it.

  • page (int | None) – Page number (default 1).

  • page_size (int | None) – Number of items per page (1-100, default 10).

  • kuery (str | None) – A KQL string to filter the hosts.

  • sort_field (str | None) – Field to sort by (e.g. enrolled_at, metadata.host.hostname, host_status, last_checkin).

  • sort_direction (str | None) – asc or desc.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse whose body has data (list of host metadata), total, page, pageSize, sortField and sortDirection.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> hosts = await client.endpoint.get_metadata_list(
...     host_statuses=["healthy"], page_size=50
... )
>>> print(hosts.body["total"])
async get_metadata(*, id, space_id=None, validate_spaces=None)[source]

Get metadata for a single endpoint host.

GET /api/endpoint/metadata/{id}

Parameters:
  • id (str) – The endpoint host ID.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the host metadata document.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> host = await client.endpoint.get_metadata(id="endpoint-id-1")
async get_actions_list(*, page=None, page_size=None, commands=None, agent_ids=None, user_ids=None, start_date=None, end_date=None, agent_types=None, with_outputs=None, types=None, space_id=None, validate_spaces=None)[source]

Get a list of all response actions.

GET /api/endpoint/action

Parameters:
  • page (int | None) – Page number.

  • page_size (int | None) – Number of items per page.

  • commands (list[str] | None) – Filter by response action command names (e.g. isolate, unisolate, kill-process, execute).

  • agent_ids (str | list[str] | None) – A single agent ID or list of agent IDs (max 250).

  • user_ids (str | list[str] | None) – A single user ID or list of user IDs (max 50).

  • start_date (str | None) – Start date (ISO 8601 or date-math) to filter actions.

  • end_date (str | None) – End date (ISO 8601 or date-math) to filter actions.

  • agent_types (str | None) – Agent type to filter by (endpoint, sentinel_one, crowdstrike, microsoft_defender_endpoint).

  • with_outputs (str | list[str] | None) – A single action ID or list of action IDs whose full output should be included (max 50).

  • types (list[str] | None) – List of response action types (automated, manual).

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the paginated action list.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> actions = await client.endpoint.get_actions_list(
...     commands=["isolate"], page_size=20
... )

Note

On a stack that has never run a response action the backing index does not yet exist and the live server answers HTTP 404 (index_not_found_exception) until the first action is created.

async get_actions_status(*, agent_ids, space_id=None, validate_spaces=None)[source]

Get the response actions status for one or more agents.

GET /api/endpoint/action_status

Parameters:
  • agent_ids (str | list[str]) – A single agent ID or list of agent IDs (max 50).

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing per-agent action status data.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> status = await client.endpoint.get_actions_status(
...     agent_ids=["agent-id-1", "agent-id-2"]
... )
async get_action_details(*, action_id, space_id=None, validate_spaces=None)[source]

Get the details of a single response action.

GET /api/endpoint/action/{action_id}

Parameters:
  • action_id (str) – The ID of the response action.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the action details.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> details = await client.endpoint.get_action_details(
...     action_id="action-id-1"
... )
async get_actions_state(*, space_id=None, validate_spaces=None)[source]

Get the overall response-actions state.

GET /api/endpoint/action/state

Reports whether the current license/configuration allows response actions to be encrypted (data.canEncrypt).

Parameters:
  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse whose body has data with canEncrypt.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> state = await client.endpoint.get_actions_state()
>>> print(state.body["data"]["canEncrypt"])
async get_action_file_info(*, action_id, file_id, space_id=None, validate_spaces=None)[source]

Get information about a file produced by a response action.

GET /api/endpoint/action/{action_id}/file/{file_id}

Parameters:
  • action_id (str) – The ID of the response action that produced the file.

  • file_id (str) – The ID of the file.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the file metadata.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> info = await client.endpoint.get_action_file_info(
...     action_id="action-id-1", file_id="file-id-1"
... )
async download_action_file(*, action_id, file_id, space_id=None, validate_spaces=None)[source]

Download a file produced by a response action.

GET /api/endpoint/action/{action_id}/file/{file_id}/download

The response body is the raw file (typically a password-protected zip archive), returned as bytes.

Parameters:
  • action_id (str) – The ID of the response action that produced the file.

  • file_id (str) – The ID of the file to download.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

Response whose body is the raw file content.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> resp = await client.endpoint.download_action_file(
...     action_id="action-id-1", file_id="file-id-1"
... )
>>> open("collected.zip", "wb").write(resp.body)
async isolate(*, endpoint_ids, agent_type=None, alert_ids=None, case_ids=None, comment=None, parameters=None, space_id=None, validate_spaces=None)[source]

Isolate one or more endpoint hosts from the network.

POST /api/endpoint/action/isolate

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs to isolate (1-250).

  • agent_type (str | None) – Agent type (endpoint, sentinel_one, crowdstrike, microsoft_defender_endpoint). Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • parameters (dict[str, Any] | None) – Optional parameters object.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.isolate(
...     endpoint_ids=["endpoint-id-1"], comment="Quarantine"
... )
async unisolate(*, endpoint_ids, agent_type=None, alert_ids=None, case_ids=None, comment=None, parameters=None, space_id=None, validate_spaces=None)[source]

Release an isolated endpoint host back onto the network.

POST /api/endpoint/action/unisolate

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs to release (1-250).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • parameters (dict[str, Any] | None) – Optional parameters object.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.unisolate(
...     endpoint_ids=["endpoint-id-1"]
... )
async kill_process(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Terminate a process on one or more endpoint hosts.

POST /api/endpoint/action/kill_process

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Process selector. One of {"pid": <int>}, {"entity_id": <str>}, or {"process_name": <str>} (process_name is SentinelOne only).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.kill_process(
...     endpoint_ids=["endpoint-id-1"], parameters={"pid": 123}
... )
async suspend_process(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Suspend a process on one or more endpoint hosts.

POST /api/endpoint/action/suspend_process

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Process selector. One of {"pid": <int>} or {"entity_id": <str>}.

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.suspend_process(
...     endpoint_ids=["endpoint-id-1"], parameters={"pid": 123}
... )
async get_running_processes(*, endpoint_ids, agent_type=None, alert_ids=None, case_ids=None, comment=None, parameters=None, space_id=None, validate_spaces=None)[source]

List the running processes on one or more endpoint hosts.

POST /api/endpoint/action/running_procs

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • parameters (dict[str, Any] | None) – Optional parameters object.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.get_running_processes(
...     endpoint_ids=["endpoint-id-1"]
... )
async get_file(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Retrieve a file from one or more endpoint hosts.

POST /api/endpoint/action/get_file

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Must include path (the absolute path of the file to retrieve on the host).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action (poll the file info/download routes with the returned action ID once complete).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.get_file(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"path": "/etc/passwd"},
... )
async execute(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Run a shell command on one or more endpoint hosts.

POST /api/endpoint/action/execute

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Must include command (the command line to run) and may include timeout (seconds).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.execute(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"command": "ls -la", "timeout": 600},
... )
async scan(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Scan a file or directory on one or more endpoint hosts.

POST /api/endpoint/action/scan

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Must include path (the folder or file to scan).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.scan(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"path": "/opt"},
... )
async generate_memory_dump(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Generate a memory dump from one or more endpoint hosts.

POST /api/endpoint/action/memory_dump

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Dump selector. Either {"type": "kernel"} for a full kernel dump, or {"type": "process", "pid": <int>} / {"type": "process", "entity_id": <str>} for a process.

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.generate_memory_dump(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"type": "kernel"},
... )

Note

This action is gated behind a feature flag; on a stack where it is disabled the live server answers HTTP 400 ([request body.agent_type]: feature is disabled).

async run_script(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Run a script on one or more endpoint hosts.

POST /api/endpoint/action/run_script

The shape of parameters depends on the agent_type:

  • Elastic Defend (endpoint): {"scriptId": <str>, "scriptInput": <str>} referencing a scripts-library entry.

  • CrowdStrike raw: {"raw": <str>, "commandLine": <str>, "timeout": <int>}.

  • CrowdStrike host path: {"hostPath": <str>, ...}.

  • CrowdStrike cloud file: {"cloudFile": <str>, ...}.

  • SentinelOne / Microsoft Defender variants also supported.

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Script selector (see above).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.run_script(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"scriptId": "script-id-1"},
... )
async cancel(*, endpoint_ids, parameters, agent_type=None, alert_ids=None, case_ids=None, comment=None, space_id=None, validate_spaces=None)[source]

Cancel a pending response action.

POST /api/endpoint/action/cancel

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • parameters (dict[str, Any]) – Must include id (the action ID to cancel).

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created cancellation action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.cancel(
...     endpoint_ids=["endpoint-id-1"],
...     parameters={"id": "action-id-1"},
... )
async upload(*, endpoint_ids, file, filename='upload.bin', agent_type=None, alert_ids=None, case_ids=None, comment=None, parameters=None, space_id=None, validate_spaces=None)[source]

Upload a file to one or more endpoint hosts.

POST /api/endpoint/action/upload

This is a multipart/form-data request: the file bytes are sent in the file part while the action fields are sent as JSON-encoded form parts.

Parameters:
  • endpoint_ids (list[str]) – List of endpoint IDs (1-250).

  • file (bytes) – Raw bytes of the file to upload.

  • filename (str) – Filename advertised for the uploaded file part.

  • agent_type (str | None) – Agent type. Defaults to endpoint.

  • alert_ids (list[str] | None) – Optional alert IDs to associate with the action.

  • case_ids (list[str] | None) – Optional case IDs to log the action against.

  • comment (str | None) – Optional comment.

  • parameters (dict[str, Any] | None) – Optional parameters object (e.g. {"overwrite": True}).

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created action.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> action = await client.endpoint.upload(
...     endpoint_ids=["endpoint-id-1"],
...     file=b"#!/bin/sh\necho hi\n",
...     filename="fix.sh",
...     parameters={"overwrite": True},
... )
async get_policy_response(*, agent_id, space_id=None, validate_spaces=None)[source]

Get the most recent policy response for an endpoint host.

GET /api/endpoint/policy_response

Parameters:
  • agent_id (str) – The endpoint agent ID whose policy response to fetch.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the policy response document.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> resp = await client.endpoint.get_policy_response(agent_id="agent-1")
async get_protection_updates_note(*, package_policy_id, space_id=None, validate_spaces=None)[source]

Get the protection-updates note for a Defend package policy.

GET /api/endpoint/protection_updates_note/{package_policy_id}

Parameters:
  • package_policy_id (str) – The ID of the Elastic Defend package policy.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the note.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> note = await client.endpoint.get_protection_updates_note(
...     package_policy_id="policy-id-1"
... )
async create_update_protection_updates_note(*, package_policy_id, note=None, space_id=None, validate_spaces=None)[source]

Create or update the protection-updates note for a Defend policy.

POST /api/endpoint/protection_updates_note/{package_policy_id}

Parameters:
  • package_policy_id (str) – The ID of the Elastic Defend package policy.

  • note (str | None) – The note text.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the created/updated note.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> await client.endpoint.create_update_protection_updates_note(
...     package_policy_id="policy-id-1",
...     note="Pinned to 2024-01-01 protection artifacts",
... )
async get_scripts(*, page=None, page_size=None, sort_field=None, sort_direction=None, kuery=None, space_id=None, validate_spaces=None)[source]

Get a list of scripts from the scripts library.

GET /api/endpoint/scripts_library

Parameters:
  • page (int | None) – Page number (default 1).

  • page_size (int | None) – Number of items per page (1-1000, default 10).

  • sort_field (str | None) – Field to sort by (name, createdAt, createdBy, updatedAt, updatedBy, fileSize).

  • sort_direction (str | None) – asc or desc.

  • kuery (str | None) – A KQL query string to filter the scripts.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse whose body has data (list of scripts), total, page, pageSize, sortField and sortDirection.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> scripts = await client.endpoint.get_scripts(page_size=50)
>>> print(scripts.body["total"])
async get_script(*, script_id, space_id=None, validate_spaces=None)[source]

Get a single script from the scripts library.

GET /api/endpoint/scripts_library/{script_id}

Parameters:
  • script_id (str) – The ID of the script.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse containing the script metadata.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> script = await client.endpoint.get_script(script_id="script-id-1")
async create_script(*, name, platform, file_type, file, filename='script.sh', description=None, example=None, instructions=None, path_to_executable=None, requires_input=None, tags=None, space_id=None, validate_spaces=None)[source]

Create a script in the scripts library.

POST /api/endpoint/scripts_library

This is a multipart/form-data request: the script/archive bytes are sent in the file part; the platform and tags arrays and the requiresInput boolean are JSON-encoded form parts.

Parameters:
  • name (str) – Name of the script.

  • platform (list[str]) – Platforms supported by the script (any of linux, macos, windows).

  • file_type (str) – script for a single script file, or archive for a .zip (in which case path_to_executable is required).

  • file (bytes) – Raw bytes of the script/archive file.

  • filename (str) – Filename advertised for the uploaded file part.

  • description (str | None) – Description of the script.

  • example (str | None) – Example usage of the script.

  • instructions (str | None) – Usage instructions, including supported input args.

  • path_to_executable (str | None) – For archive uploads, the relative path to the executable within the archive.

  • requires_input (bool | None) – Whether the script requires input arguments.

  • tags (list[str] | None) – Categorization tags. Valid values include remediationAction, dataCollection, networkDiagnostics, networkAction, systemInventory, forensicCollection, threatHunting, discovery, systemManagement, userManagement, troubleshooting.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse whose body has data with the created script, including its id, fileId, fileHash and downloadUri.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> created = await client.endpoint.create_script(
...     name="collect-logs",
...     platform=["linux"],
...     file_type="script",
...     file=b"#!/bin/sh\necho hi\n",
...     filename="collect.sh",
... )
>>> print(created.body["data"]["id"])
async update_script(*, script_id, file=None, filename='script.sh', name=None, platform=None, file_type=None, description=None, example=None, instructions=None, path_to_executable=None, requires_input=None, tags=None, space_id=None, validate_spaces=None)[source]

Update a script in the scripts library.

PATCH /api/endpoint/scripts_library/{script_id}

This is a multipart/form-data request. All fields are optional; a new file part is only sent when file is provided.

Parameters:
  • script_id (str) – The ID of the script to update.

  • file (bytes | None) – Optional new script/archive bytes.

  • filename (str) – Filename advertised for the uploaded file part (only used when file is provided).

  • name (str | None) – New name.

  • platform (list[str] | None) – New supported platforms.

  • file_type (str | None) – New file type (script or archive).

  • description (str | None) – New description.

  • example (str | None) – New example usage.

  • instructions (str | None) – New usage instructions.

  • path_to_executable (str | None) – New relative path to executable (archives).

  • requires_input (bool | None) – Whether the script requires input arguments.

  • tags (list[str] | None) – New categorization tags.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse whose body has data with the updated script.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> await client.endpoint.update_script(
...     script_id="script-id-1",
...     description="Updated description",
... )
async delete_script(*, script_id, space_id=None, validate_spaces=None)[source]

Delete a script from the scripts library.

DELETE /api/endpoint/scripts_library/{script_id}

Parameters:
  • script_id (str) – The ID of the script to delete.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

ObjectApiResponse with an empty body on success.

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> await client.endpoint.delete_script(script_id="script-id-1")
async download_script(*, script_id, space_id=None, validate_spaces=None)[source]

Download the file backing a scripts-library entry.

GET /api/endpoint/scripts_library/{script_id}/download

The response body is the raw script/archive file content.

Parameters:
  • script_id (str) – The ID of the script to download.

  • space_id (str | None) – Optional space ID to scope the request to.

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

Returns:

Response whose body is the raw file content (the exact type depends on the uploaded file: text scripts come back as str, binary archives as bytes).

Raises:
Return type:

ObjectApiResponse[Any]

Example

>>> resp = await client.endpoint.download_script(script_id="script-id-1")
>>> open("script.sh", "wb").write(
...     resp.body if isinstance(resp.body, bytes)
...     else resp.body.encode()
... )
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]