FleetPoliciesClient¶
Client for the Kibana Fleet agent and package policies API.
Agent policies define how Elastic Agents behave: which outputs they ship data to, their monitoring settings and which integrations they run. Package policies attach an integration package (with its inputs and variables) to one or more agent policies. Agentless policies deploy an integration without a self-managed Elastic Agent (Elastic Cloud / serverless only).
Fleet policies are space-aware resources: every method accepts an optional
space_id to target a specific space.
- class kibana._sync.client.fleet_policies.FleetPoliciesClient(client, default_space_id=None, validate_spaces=True)[source]¶
Bases:
NamespaceClientClient for the Kibana Fleet agent and package policies API.
Agent policies define how Elastic Agents behave: which outputs they ship data to, their monitoring settings and which integrations they run. Package policies attach an integration package (with its inputs and variables) to one or more agent policies. Agentless policies deploy an integration without a self-managed Elastic Agent (Elastic Cloud / serverless only).
Fleet policies are space-aware resources: every method accepts an optional
space_idto target a specific space (Nonetargets the default space or the space the client is scoped to).Example
>>> from kibana import Kibana >>> client = Kibana("http://localhost:5601", api_key="...") >>> >>> # Create an agent policy and attach a package policy to it >>> policy = client.fleet_policies.create_agent_policy( ... name="my-agent-policy", ... namespace="default", ... sys_monitoring=False, ... ) >>> policy_id = policy.body["item"]["id"] >>> >>> pkg = client.fleet_policies.create_package_policy( ... name="my-package-policy", ... package={"name": "log", "version": "2.4.4"}, ... policy_ids=[policy_id], ... inputs={"logs-logfile": {"enabled": True}}, ... ) >>> >>> # Clean up >>> client.fleet_policies.delete_package_policy( ... package_policy_id=pkg.body["item"]["id"] ... ) >>> client.fleet_policies.delete_agent_policy(agent_policy_id=policy_id)
Managing Agent Policies
from kibana import Kibana client = Kibana("http://localhost:5601", api_key="your_api_key") # Create an agent policy (without the system monitoring package) created = client.fleet_policies.create_agent_policy( name="my-agent-policy", namespace="default", description="Policy for web servers", monitoring_enabled=["logs", "metrics"], sys_monitoring=False, ) agent_policy_id = created.body["item"]["id"] # Get, update and list agent policies policy = client.fleet_policies.get_agent_policy( agent_policy_id=agent_policy_id ) client.fleet_policies.update_agent_policy( agent_policy_id=agent_policy_id, name="my-agent-policy", namespace="default", description="Updated description", ) policies = client.fleet_policies.get_agent_policies( kuery='ingest-agent-policies.name:"my-agent-policy"' ) # Copy, then delete the copy copy = client.fleet_policies.copy_agent_policy( agent_policy_id=agent_policy_id, name="my-agent-policy (copy)" ) client.fleet_policies.delete_agent_policy( agent_policy_id=copy.body["item"]["id"] )
Inspecting Compiled Policies
# Full compiled policy document (what an enrolled agent receives) full = client.fleet_policies.get_full_agent_policy( agent_policy_id=agent_policy_id ) # The same document as downloadable elastic-agent.yml (YAML string) yaml_doc = client.fleet_policies.download_agent_policy( agent_policy_id=agent_policy_id ) print(yaml_doc.body) # Outputs used by one or many policies outputs = client.fleet_policies.get_agent_policy_outputs( agent_policy_id=agent_policy_id ) bulk_outputs = client.fleet_policies.get_agent_policies_outputs( ids=[agent_policy_id] )
Managing Package Policies
# Attach the "udp" integration using the simplified inputs format pkg = client.fleet_policies.create_package_policy( name="my-udp-policy", package={"name": "udp", "version": "2.5.1"}, policy_ids=[agent_policy_id], inputs={ "udp-udp": { "enabled": True, "streams": { "udp.udp": { "enabled": True, "vars": { "listen_address": "localhost", "listen_port": 8964, "data_stream.dataset": "udp.custom", }, } }, } }, ) package_policy_id = pkg.body["item"]["id"] # Upgrade dry run, then upgrade to the latest installed version dry_run = client.fleet_policies.upgrade_package_policies_dry_run( package_policy_ids=[package_policy_id] ) client.fleet_policies.upgrade_package_policies( package_policy_ids=[package_policy_id] ) # Delete package policies (single or bulk) client.fleet_policies.delete_package_policy( package_policy_id=package_policy_id, force=True )
Agentless Policies
Agentless policies are only supported in Elastic Cloud and serverless environments; self-managed deployments reject these calls with a 400 error.
created = client.fleet_policies.create_agentless_policy( name="my-agentless-policy", package={"name": "cspm", "version": "1.0.0"}, ) client.fleet_policies.delete_agentless_policy( policy_id=created.body["item"]["id"] )
- __init__(client, default_space_id=None, validate_spaces=True)[source]¶
Initialize the FleetPoliciesClient.
- Parameters:
Example
>>> fleet_policies_client = FleetPoliciesClient(kibana_client)
- get_agent_policies(*, page=None, per_page=None, sort_field=None, sort_order=None, show_upgradeable=None, kuery=None, no_agent_count=None, with_agent_count=None, full=None, format=None, space_id=None, validate_spaces=None)[source]¶
Get agent policies.
GET /api/fleet/agent_policiesLists agent policies, optionally filtered with a KQL query and paginated.
- Parameters:
page (int | None) – Page number to return (1-based).
per_page (int | None) – Number of policies per page.
sort_field (str | None) – Field to sort the results by.
sort_order (str | None) – Sort direction, either
"asc"or"desc".show_upgradeable (bool | None) – Only return policies with agents that can be upgraded.
kuery (str | None) – KQL filter, e.g.
'ingest-agent-policies.name:"my-policy"'.no_agent_count (bool | None) – Do not compute the agent count per policy (deprecated in favor of
with_agent_count).with_agent_count (bool | None) – Include the number of enrolled agents for each policy.
full (bool | None) – Return the full policy representation (including package policies).
format (str | None) – Representation of package policies within each agent policy:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
items(list of agent policies),total,pageandperPage.- Raises:
BadRequestError – If a query parameter is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policies = client.fleet_policies.get_agent_policies( ... kuery='ingest-agent-policies.name:"my-policy"', per_page=5 ... ) >>> print(policies.body["total"])
- create_agent_policy(*, name, namespace, advanced_settings=None, agent_features=None, agentless=None, bump_revision=None, data_output_id=None, description=None, download_source_id=None, fleet_server_host_id=None, force=None, global_data_tags=None, has_agent_version_conditions=None, has_fleet_server=None, id=None, inactivity_timeout=None, is_default=None, is_default_fleet_server=None, is_managed=None, is_protected=None, is_verifier=None, keep_monitoring_alive=None, min_agent_version=None, monitoring_diagnostics=None, monitoring_enabled=None, monitoring_http=None, monitoring_output_id=None, monitoring_pprof_enabled=None, overrides=None, package_agent_version_conditions=None, required_versions=None, space_ids=None, supports_agentless=None, unenroll_timeout=None, sys_monitoring=None, space_id=None, validate_spaces=None)[source]¶
Create an agent policy.
POST /api/fleet/agent_policies- Parameters:
name (str) – Name of the agent policy (must be unique).
namespace (str) – Default data stream namespace for the policy’s integrations (e.g.
"default").advanced_settings (dict[str, Any] | None) – Advanced agent settings (e.g. log level).
agent_features (list[dict[str, Any]] | None) – Agent feature flags, list of
{"name": ..., "enabled": ...}objects.agentless (dict[str, Any] | None) – Agentless deployment configuration.
bump_revision (bool | None) – Bump the policy revision on creation.
data_output_id (str | None) – ID of the output used for integration data.
description (str | None) – Human-readable description of the policy.
download_source_id (str | None) – ID of the agent binary download source.
fleet_server_host_id (str | None) – ID of the Fleet Server host to use.
force (bool | None) – Force creation even if some preconditions fail.
global_data_tags (list[dict[str, Any]] | None) – Tags added to every document produced by the policy, list of
{"name": ..., "value": ...}objects.has_agent_version_conditions (bool | None) – Whether the policy has agent version conditions.
has_fleet_server (bool | None) – Whether the policy hosts a Fleet Server.
id (str | None) – Explicit ID for the new policy (auto-generated when omitted).
inactivity_timeout (int | None) – Seconds of inactivity before an agent is marked inactive (minimum 0, default 1209600).
is_default (bool | None) – Mark as the default agent policy.
is_default_fleet_server (bool | None) – Mark as the default Fleet Server policy.
is_managed (bool | None) – Mark the policy as hosted/managed (cannot be edited in the UI).
is_protected (bool | None) – Enable agent tamper protection.
is_verifier (bool | None) – Whether the policy is a verifier policy.
keep_monitoring_alive (bool | None) – Keep the monitoring server alive even when monitoring is disabled.
min_agent_version (str | None) – Minimum agent version allowed to enroll.
monitoring_diagnostics (dict[str, Any] | None) – Monitoring diagnostics rate limit / uploader settings.
monitoring_enabled (list[str] | None) – What to monitor on the agents; any of
"logs","metrics","traces".monitoring_http (dict[str, Any] | None) – Monitoring HTTP endpoint settings.
monitoring_output_id (str | None) – ID of the output used for agent monitoring data.
monitoring_pprof_enabled (bool | None) – Enable pprof profiling endpoints on the agents.
overrides (dict[str, Any] | None) – Overrides applied on top of the compiled full agent policy.
package_agent_version_conditions (list[dict[str, Any]] | None) – Per-package agent version conditions, list of
{"packageName": ..., "versionCondition": ...}objects.required_versions (list[dict[str, Any]] | None) – Target agent versions for automatic upgrades, list of
{"version": ..., "percentage": ...}objects.space_ids (list[str] | None) – IDs of the spaces the policy is shared with.
supports_agentless (bool | None) – Whether the policy supports agentless integrations (Elastic Cloud / serverless only).
unenroll_timeout (int | None) – Seconds after which inactive agents are automatically unenrolled.
sys_monitoring (bool | None) – Query flag; when True, also create a
systemmonitoring package policy on the new agent policy.space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the created agent policy (id,name,namespace,revision, …).- Raises:
BadRequestError – If the request body is invalid (e.g. duplicate name).
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> created = client.fleet_policies.create_agent_policy( ... name="my-agent-policy", ... namespace="default", ... description="Policy for web servers", ... monitoring_enabled=["logs", "metrics"], ... sys_monitoring=False, ... ) >>> print(created.body["item"]["id"])
- bulk_get_agent_policies(*, ids, full=None, ignore_missing=None, format=None, space_id=None, validate_spaces=None)[source]¶
Bulk get agent policies.
POST /api/fleet/agent_policies/_bulk_get- Parameters:
full (bool | None) – Return the full policy representation (including package policies).
ignore_missing (bool | None) – When True, missing IDs are silently skipped instead of producing a 404.
format (str | None) – Representation of package policies within each agent policy:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemscontaining the requested agent policies.- Raises:
BadRequestError – If the request body is invalid.
NotFoundError – If an ID is missing and
ignore_missingis not set.AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policies = client.fleet_policies.bulk_get_agent_policies( ... ids=["policy-1", "policy-2"], ignore_missing=True ... ) >>> print(len(policies.body["items"]))
- get_agent_policy(*, agent_policy_id, format=None, space_id=None, validate_spaces=None)[source]¶
Get an agent policy.
GET /api/fleet/agent_policies/{agentPolicyId}- Parameters:
agent_policy_id (str) – ID of the agent policy.
format (str | None) – Representation of package policies within the agent policy:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the agent policy.- Raises:
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policy = client.fleet_policies.get_agent_policy( ... agent_policy_id="policy-1" ... ) >>> print(policy.body["item"]["name"])
- update_agent_policy(*, agent_policy_id, name, namespace, advanced_settings=None, agent_features=None, agentless=None, bump_revision=None, data_output_id=None, description=None, download_source_id=None, fleet_server_host_id=None, force=None, global_data_tags=None, has_agent_version_conditions=None, has_fleet_server=None, id=None, inactivity_timeout=None, is_default=None, is_default_fleet_server=None, is_managed=None, is_protected=None, is_verifier=None, keep_monitoring_alive=None, min_agent_version=None, monitoring_diagnostics=None, monitoring_enabled=None, monitoring_http=None, monitoring_output_id=None, monitoring_pprof_enabled=None, overrides=None, package_agent_version_conditions=None, required_versions=None, space_ids=None, supports_agentless=None, unenroll_timeout=None, format=None, space_id=None, validate_spaces=None)[source]¶
Update an agent policy.
PUT /api/fleet/agent_policies/{agentPolicyId}This is a full update:
nameandnamespaceare required and omitted optional fields fall back to their defaults.- Parameters:
agent_policy_id (str) – ID of the agent policy to update.
name (str) – Name of the agent policy.
namespace (str) – Default data stream namespace for the policy’s integrations.
advanced_settings (dict[str, Any] | None) – Advanced agent settings (e.g. log level).
agent_features (list[dict[str, Any]] | None) – Agent feature flags, list of
{"name": ..., "enabled": ...}objects.agentless (dict[str, Any] | None) – Agentless deployment configuration.
bump_revision (bool | None) – Bump the policy revision even without changes.
data_output_id (str | None) – ID of the output used for integration data.
description (str | None) – Human-readable description of the policy.
download_source_id (str | None) – ID of the agent binary download source.
fleet_server_host_id (str | None) – ID of the Fleet Server host to use.
force (bool | None) – Force the update even if some preconditions fail (e.g. the policy is managed).
global_data_tags (list[dict[str, Any]] | None) – Tags added to every document produced by the policy, list of
{"name": ..., "value": ...}objects.has_agent_version_conditions (bool | None) – Whether the policy has agent version conditions.
has_fleet_server (bool | None) – Whether the policy hosts a Fleet Server.
id (str | None) – Policy ID field carried in the body.
inactivity_timeout (int | None) – Seconds of inactivity before an agent is marked inactive.
is_default (bool | None) – Mark as the default agent policy.
is_default_fleet_server (bool | None) – Mark as the default Fleet Server policy.
is_managed (bool | None) – Mark the policy as hosted/managed.
is_protected (bool | None) – Enable agent tamper protection.
is_verifier (bool | None) – Whether the policy is a verifier policy.
keep_monitoring_alive (bool | None) – Keep the monitoring server alive even when monitoring is disabled.
min_agent_version (str | None) – Minimum agent version allowed to enroll.
monitoring_diagnostics (dict[str, Any] | None) – Monitoring diagnostics rate limit / uploader settings.
monitoring_enabled (list[str] | None) – What to monitor on the agents; any of
"logs","metrics","traces".monitoring_http (dict[str, Any] | None) – Monitoring HTTP endpoint settings.
monitoring_output_id (str | None) – ID of the output used for agent monitoring data.
monitoring_pprof_enabled (bool | None) – Enable pprof profiling endpoints on the agents.
overrides (dict[str, Any] | None) – Overrides applied on top of the compiled full agent policy.
package_agent_version_conditions (list[dict[str, Any]] | None) – Per-package agent version conditions.
required_versions (list[dict[str, Any]] | None) – Target agent versions for automatic upgrades.
space_ids (list[str] | None) – IDs of the spaces the policy is shared with.
supports_agentless (bool | None) – Whether the policy supports agentless integrations (Elastic Cloud / serverless only).
unenroll_timeout (int | None) – Seconds after which inactive agents are automatically unenrolled.
format (str | None) – Representation of package policies in the response:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the updated agent policy (with a bumpedrevision).- Raises:
BadRequestError – If the request body is invalid.
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> updated = client.fleet_policies.update_agent_policy( ... agent_policy_id="policy-1", ... name="my-agent-policy", ... namespace="default", ... description="Updated description", ... ) >>> print(updated.body["item"]["revision"])
- get_auto_upgrade_agents_status(*, agent_policy_id, space_id=None, validate_spaces=None)[source]¶
Get the auto-upgrade agents status for an agent policy.
GET /api/fleet/agent_policies/{agentPolicyId}/auto_upgrade_agents_statusReports how many agents run each target version configured in the policy’s
required_versions(automatic upgrades).- Parameters:
- Returns:
ObjectApiResponse with
currentVersions(per-version agent counts and failed upgrades) andtotalAgents.- Raises:
BadRequestError – If the request is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> status = client.fleet_policies.get_auto_upgrade_agents_status( ... agent_policy_id="policy-1" ... ) >>> print(status.body["totalAgents"])
- copy_agent_policy(*, agent_policy_id, name, description=None, format=None, space_id=None, validate_spaces=None)[source]¶
Copy an agent policy.
POST /api/fleet/agent_policies/{agentPolicyId}/copyDuplicates the agent policy (including its package policies) under a new name.
- Parameters:
agent_policy_id (str) – ID of the agent policy to copy.
name (str) – Name for the new (copied) agent policy; must be unique.
description (str | None) – Description for the new agent policy.
format (str | None) – Representation of package policies in the response:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the newly created copy of the agent policy.- Raises:
BadRequestError – If the name is already in use.
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> copy = client.fleet_policies.copy_agent_policy( ... agent_policy_id="policy-1", name="policy-1 (copy)" ... ) >>> print(copy.body["item"]["id"])
- download_agent_policy(*, agent_policy_id, download=None, standalone=None, kubernetes=None, revision=None, space_id=None, validate_spaces=None)[source]¶
Download an agent policy as YAML.
GET /api/fleet/agent_policies/{agentPolicyId}/downloadReturns the compiled policy document served as a downloadable
elastic-agent.ymlfile. The live server responds withtext/x-yaml, so the response body is the raw YAML string (the returned object is aTextApiResponseat runtime).- Parameters:
agent_policy_id (str) – ID of the agent policy.
download (bool | None) – Serve the document as a file download.
standalone (bool | None) – Render the standalone (non-Fleet-managed) variant of the policy.
kubernetes (bool | None) – Render the Kubernetes manifest variant of the policy.
revision (int | None) – Specific policy revision to download (defaults to the latest).
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse whose body is the YAML policy document as a string.
- Raises:
BadRequestError – If the request is invalid.
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> yaml_doc = client.fleet_policies.download_agent_policy( ... agent_policy_id="policy-1" ... ) >>> print(yaml_doc.body[:20])
- get_full_agent_policy(*, agent_policy_id, download=None, standalone=None, kubernetes=None, revision=None, space_id=None, validate_spaces=None)[source]¶
Get a full (compiled) agent policy.
GET /api/fleet/agent_policies/{agentPolicyId}/fullReturns the complete policy document as JSON — the same content an enrolled Elastic Agent receives, including outputs and compiled inputs.
- Parameters:
agent_policy_id (str) – ID of the agent policy.
download (bool | None) – Serve the document as a file download.
standalone (bool | None) – Render the standalone (non-Fleet-managed) variant of the policy.
kubernetes (bool | None) – Render the Kubernetes manifest variant of the policy.
revision (int | None) – Specific policy revision to fetch (defaults to the latest).
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the full agent policy document (or the Kubernetes manifest string whenkubernetes=True).- Raises:
BadRequestError – If the request is invalid.
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> full = client.fleet_policies.get_full_agent_policy( ... agent_policy_id="policy-1" ... ) >>> print(full.body["item"]["outputs"].keys())
- get_agent_policy_outputs(*, agent_policy_id, space_id=None, validate_spaces=None)[source]¶
Get outputs for an agent policy.
GET /api/fleet/agent_policies/{agentPolicyId}/outputs- Parameters:
- Returns:
ObjectApiResponse with
itemdescribing thedataandmonitoringoutputs used by the policy (and per-integration output overrides).- Raises:
BadRequestError – If the request is invalid.
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> outputs = client.fleet_policies.get_agent_policy_outputs( ... agent_policy_id="policy-1" ... ) >>> print(outputs.body["item"]["data"]["output"]["id"])
- delete_agent_policy(*, agent_policy_id, force=None, space_id=None, validate_spaces=None)[source]¶
Delete an agent policy.
POST /api/fleet/agent_policies/deleteDeletes the agent policy and its package policies. Policies with enrolled agents cannot be deleted.
- Parameters:
- Returns:
ObjectApiResponse with the
idandnameof the deleted agent policy.- Raises:
BadRequestError – If the policy cannot be deleted (e.g. agents are still enrolled or the policy does not exist).
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> deleted = client.fleet_policies.delete_agent_policy( ... agent_policy_id="policy-1" ... ) >>> print(deleted.body["id"])
- get_agent_policies_outputs(*, ids, space_id=None, validate_spaces=None)[source]¶
Get outputs for multiple agent policies.
POST /api/fleet/agent_policies/outputs- Parameters:
- Returns:
one entry per agent policy describing its
dataandmonitoringoutputs.- Return type:
ObjectApiResponse with
items- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
Example
>>> outputs = client.fleet_policies.get_agent_policies_outputs( ... ids=["policy-1", "policy-2"] ... ) >>> print(len(outputs.body["items"]))
- create_agentless_policy(*, name, package, additional_datastreams_permissions=None, cloud_connector=None, condition=None, description=None, force=None, global_data_tags=None, id=None, inputs=None, namespace=None, policy_template=None, var_group_selections=None, vars=None, format=None, space_id=None, validate_spaces=None)[source]¶
Create an agentless policy.
POST /api/fleet/agentless_policiesDeploys an integration without a self-managed Elastic Agent. The agentless feature is only available in Elastic Cloud and serverless environments; on self-managed deployments the server rejects the request with a 400 error.
- Parameters:
name (str) – Name for the agentless integration policy.
package (dict[str, Any]) – The integration package, e.g.
{"name": "cspm", "version": "1.0.0"}.additional_datastreams_permissions (list[str] | None) – Additional data stream permission patterns granted to the policy.
cloud_connector (dict[str, Any] | None) – Cloud connector settings, e.g.
{"enabled": True, "target_csp": "aws"}.condition (str | None) – Condition under which the inputs are active.
description (str | None) – Human-readable description of the policy.
force (bool | None) – Force creation even if some preconditions fail.
global_data_tags (list[dict[str, Any]] | None) – Tags added to every document produced by the policy, list of
{"name": ..., "value": ...}objects.id (str | None) – Explicit ID for the new policy (auto-generated when omitted).
inputs (dict[str, Any] | None) – Package policy inputs in the simplified (object) format, keyed by
<policy_template>-<input_type>.namespace (str | None) – Data stream namespace for the policy’s data.
policy_template (str | None) – Name of the package policy template to use.
var_group_selections (dict[str, Any] | None) – Selected variable groups, keyed by group name.
vars (dict[str, Any] | None) – Package-level variables in the simplified format.
format (str | None) – Response format:
"simplified"(default) or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the created package policy backing the agentless deployment.- Raises:
BadRequestError – If the request is invalid or the deployment does not support the agentless feature.
ConflictError – If an agentless policy with the same name exists.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> created = client.fleet_policies.create_agentless_policy( ... name="my-agentless-policy", ... package={"name": "cspm", "version": "1.0.0"}, ... ) >>> print(created.body["item"]["id"])
- delete_agentless_policy(*, policy_id, force=None, space_id=None, validate_spaces=None)[source]¶
Delete an agentless policy.
DELETE /api/fleet/agentless_policies/{policyId}Tears down the agentless deployment and deletes the backing package policy. On the live 9.4.3 server this endpoint responds 200 with
{"id": ...}even for unknown policy IDs (idempotent delete).- Parameters:
- Returns:
ObjectApiResponse with the
idof the deleted policy.- Raises:
BadRequestError – If the request is invalid.
ConflictError – If the policy cannot be deleted right now.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> deleted = client.fleet_policies.delete_agentless_policy( ... policy_id="agentless-policy-1" ... ) >>> print(deleted.body["id"])
- get_package_policies(*, page=None, per_page=None, sort_field=None, sort_order=None, show_upgradeable=None, kuery=None, format=None, with_agent_count=None, space_id=None, validate_spaces=None)[source]¶
Get package policies.
GET /api/fleet/package_policiesLists package policies (integration policies), optionally filtered with a KQL query and paginated.
- Parameters:
page (int | None) – Page number to return (1-based).
per_page (int | None) – Number of policies per page.
sort_field (str | None) – Field to sort the results by.
sort_order (str | None) – Sort direction, either
"asc"or"desc".show_upgradeable (bool | None) – Only return policies that can be upgraded to a newer package version.
kuery (str | None) – KQL filter, e.g.
'ingest-package-policies.package.name:"nginx"'.format (str | None) – Response format:
"simplified"or"legacy".with_agent_count (bool | None) – Include the number of agents using each policy.
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
items(list of package policies),total,pageandperPage.- Raises:
BadRequestError – If a query parameter is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policies = client.fleet_policies.get_package_policies( ... kuery='ingest-package-policies.package.name:"log"' ... ) >>> print(policies.body["total"])
- create_package_policy(*, name, package, additional_datastreams_permissions=None, cloud_connector=None, cloud_connector_id=None, cloud_connector_name=None, condition=None, description=None, enabled=None, force=None, global_data_tags=None, id=None, inputs=None, is_managed=None, namespace=None, output_id=None, overrides=None, package_agent_version_condition=None, policy_id=None, policy_ids=None, policy_template=None, space_ids=None, supports_agentless=None, supports_cloud_connector=None, var_group_selections=None, vars=None, format=None, space_id=None, validate_spaces=None)[source]¶
Create a package policy.
POST /api/fleet/package_policiesAttaches an integration package to one or more agent policies. The API accepts two body formats: the classic (legacy) format with
inputsas a list of input objects, and the simplified format withinputsas an object keyed by<policy_template>-<input_type>. Pass a list or a dict forinputsaccordingly. If the package is not installed yet, Kibana installs it from the registry as part of this call.- Parameters:
name (str) – Name for the package policy (must be unique).
package (dict[str, Any]) – The integration package, e.g.
{"name": "log", "version": "2.4.4"}.additional_datastreams_permissions (list[str] | None) – Additional data stream permission patterns granted to the policy.
cloud_connector (dict[str, Any] | None) – Cloud connector settings (simplified format).
cloud_connector_id (str | None) – ID of an existing cloud connector (classic format).
cloud_connector_name (str | None) – Name of the cloud connector (classic format).
condition (str | None) – Condition under which the inputs are active (simplified format).
description (str | None) – Human-readable description of the policy.
enabled (bool | None) – Whether the package policy is enabled (classic format).
force (bool | None) – Force creation even if some preconditions fail (e.g. package below the minimum required version).
global_data_tags (list[dict[str, Any]] | None) – Tags added to every document produced by the policy, list of
{"name": ..., "value": ...}objects.id (str | None) – Explicit ID for the new policy (auto-generated when omitted).
inputs (list[dict[str, Any]] | dict[str, Any] | None) – Package policy inputs: a list of input objects (classic format) or an object keyed by
<policy_template>-<input_type>(simplified format).is_managed (bool | None) – Mark the policy as managed (classic format).
namespace (str | None) – Data stream namespace for the policy’s data; falls back to the agent policy’s namespace when omitted.
output_id (str | None) – ID of the output to send this integration’s data to (classic format).
overrides (dict[str, Any] | None) – Overrides for the compiled package policy (classic format); use only in automation.
package_agent_version_condition (str | None) – Agent version condition for the package (classic format).
policy_id (str | None) – ID of the agent policy to add this policy to (deprecated, use
policy_ids).policy_ids (list[str] | None) – IDs of the agent policies to add this policy to.
policy_template (str | None) – Name of the package policy template to use (simplified format).
space_ids (list[str] | None) – IDs of the spaces the policy is available in (classic format, sent as
spaceIds).supports_agentless (bool | None) – Whether the policy supports agentless deployments (classic format).
supports_cloud_connector (bool | None) – Whether the policy supports cloud connectors (classic format).
var_group_selections (dict[str, Any] | None) – Selected variable groups, keyed by group name.
vars (dict[str, Any] | None) – Package-level variables (simplified format, or classic input-level structure).
format (str | None) – Response format:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the created package policy.- Raises:
BadRequestError – If the request body is invalid (e.g. unknown input or stream).
ConflictError – If a package policy with the same name exists.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> created = client.fleet_policies.create_package_policy( ... name="my-log-policy", ... package={"name": "log", "version": "2.4.4"}, ... policy_ids=["policy-1"], ... inputs={ ... "logs-logfile": { ... "enabled": True, ... "streams": { ... "log.logs": { ... "enabled": True, ... "vars": {"paths": ["/var/log/app.log"]}, ... } ... }, ... } ... }, ... ) >>> print(created.body["item"]["id"])
- bulk_get_package_policies(*, ids, ignore_missing=None, format=None, space_id=None, validate_spaces=None)[source]¶
Bulk get package policies.
POST /api/fleet/package_policies/_bulk_get- Parameters:
ignore_missing (bool | None) – When True, missing IDs are silently skipped instead of producing a 404.
format (str | None) – Response format:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemscontaining the requested package policies.- Raises:
BadRequestError – If the request body is invalid.
NotFoundError – If an ID is missing and
ignore_missingis not set.AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policies = client.fleet_policies.bulk_get_package_policies( ... ids=["pkg-policy-1"], ignore_missing=True ... ) >>> print(len(policies.body["items"]))
- get_package_policy(*, package_policy_id, format=None, space_id=None, validate_spaces=None)[source]¶
Get a package policy.
GET /api/fleet/package_policies/{packagePolicyId}- Parameters:
- Returns:
ObjectApiResponse with
itemcontaining the package policy.- Raises:
NotFoundError – If the package policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policy = client.fleet_policies.get_package_policy( ... package_policy_id="pkg-policy-1" ... ) >>> print(policy.body["item"]["name"])
- update_package_policy(*, package_policy_id, package, name=None, additional_datastreams_permissions=None, cloud_connector=None, cloud_connector_id=None, cloud_connector_name=None, condition=None, description=None, enabled=None, force=None, global_data_tags=None, id=None, inputs=None, is_managed=None, namespace=None, output_id=None, overrides=None, package_agent_version_condition=None, policy_id=None, policy_ids=None, policy_template=None, space_ids=None, supports_agentless=None, supports_cloud_connector=None, var_group_selections=None, vars=None, version=None, format=None, space_id=None, validate_spaces=None)[source]¶
Update a package policy.
PUT /api/fleet/package_policies/{packagePolicyId}Accepts the same two body formats as
create_package_policy()(classic withinputsas a list, simplified withinputsas an object).nameis required by the simplified format.- Parameters:
package_policy_id (str) – ID of the package policy to update.
package (dict[str, Any]) – The integration package, e.g.
{"name": "log", "version": "2.4.4"}.name (str | None) – Name for the package policy.
additional_datastreams_permissions (list[str] | None) – Additional data stream permission patterns granted to the policy.
cloud_connector (dict[str, Any] | None) – Cloud connector settings (simplified format).
cloud_connector_id (str | None) – ID of an existing cloud connector (classic format).
cloud_connector_name (str | None) – Name of the cloud connector (classic format).
condition (str | None) – Condition under which the inputs are active (simplified format).
description (str | None) – Human-readable description of the policy.
enabled (bool | None) – Whether the package policy is enabled (classic format).
force (bool | None) – Force the update even if some preconditions fail.
global_data_tags (list[dict[str, Any]] | None) – Tags added to every document produced by the policy.
id (str | None) – Policy ID field carried in the body (simplified format).
inputs (list[dict[str, Any]] | dict[str, Any] | None) – Package policy inputs: a list of input objects (classic format) or an object keyed by
<policy_template>-<input_type>(simplified format).is_managed (bool | None) – Mark the policy as managed (classic format).
namespace (str | None) – Data stream namespace for the policy’s data.
output_id (str | None) – ID of the output to send this integration’s data to (classic format).
overrides (dict[str, Any] | None) – Overrides for the compiled package policy (classic format).
package_agent_version_condition (str | None) – Agent version condition for the package (classic format).
policy_id (str | None) – ID of the agent policy the policy belongs to (deprecated, use
policy_ids).policy_ids (list[str] | None) – IDs of the agent policies the policy belongs to.
policy_template (str | None) – Name of the package policy template to use (simplified format).
space_ids (list[str] | None) – IDs of the spaces the policy is available in (classic format, sent as
spaceIds).supports_agentless (bool | None) – Whether the policy supports agentless deployments (classic format).
supports_cloud_connector (bool | None) – Whether the policy supports cloud connectors (classic format).
var_group_selections (dict[str, Any] | None) – Selected variable groups, keyed by group name.
vars (dict[str, Any] | None) – Package-level variables (simplified format, or classic input-level structure).
version (str | None) – Saved-object version of the policy (classic format, optimistic concurrency).
format (str | None) – Response format:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the updated package policy (with a bumpedrevision).- Raises:
BadRequestError – If the request body is invalid.
AuthorizationException – If insufficient privileges.
NotFoundError – If the package policy does not exist.
AuthenticationException – If authentication fails.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> updated = client.fleet_policies.update_package_policy( ... package_policy_id="pkg-policy-1", ... package={"name": "log", "version": "2.4.4"}, ... description="Updated description", ... ) >>> print(updated.body["item"]["revision"])
- delete_package_policy(*, package_policy_id, force=None, space_id=None, validate_spaces=None)[source]¶
Delete a package policy.
DELETE /api/fleet/package_policies/{packagePolicyId}- Parameters:
package_policy_id (str) – ID of the package policy to delete.
force (bool | None) – Force deletion even if the policy is used by agents or marked as managed.
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the
idof the deleted package policy.- Raises:
BadRequestError – If the policy cannot be deleted or does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> deleted = client.fleet_policies.delete_package_policy( ... package_policy_id="pkg-policy-1" ... ) >>> print(deleted.body["id"])
- bulk_delete_package_policies(*, package_policy_ids, force=None, space_id=None, validate_spaces=None)[source]¶
Bulk delete package policies.
POST /api/fleet/package_policies/delete- Parameters:
package_policy_ids (list[str]) – IDs of the package policies to delete.
force (bool | None) – Force deletion even if the policies are used by agents or marked as managed.
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse whose body is a list with one result entry per policy (
id,name,success, …).- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> results = client.fleet_policies.bulk_delete_package_policies( ... package_policy_ids=["pkg-policy-1"], force=True ... ) >>> print(results.body[0]["success"])
- upgrade_package_policies(*, package_policy_ids, space_id=None, validate_spaces=None)[source]¶
Upgrade package policies to the latest installed package version.
POST /api/fleet/package_policies/upgrade- Parameters:
- Returns:
ObjectApiResponse whose body is a list with one result entry per policy (
id,name,successand optionalstatusCode/bodyon failure).- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> results = client.fleet_policies.upgrade_package_policies( ... package_policy_ids=["pkg-policy-1"] ... ) >>> print(results.body[0]["success"])
- upgrade_package_policies_dry_run(*, package_policy_ids, package_version=None, space_id=None, validate_spaces=None)[source]¶
Dry run a package policy upgrade.
POST /api/fleet/package_policies/upgrade/dryrunComputes the diff an upgrade would produce without persisting any change.
- Parameters:
package_policy_ids (list[str]) – IDs of the package policies to check.
package_version (str | None) – Target package version to simulate the upgrade against (defaults to the latest installed version).
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse whose body is a list with one result entry per policy, each containing
name,diff(current vs proposed policy) andhasErrors.- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> results = client.fleet_policies.upgrade_package_policies_dry_run( ... package_policy_ids=["pkg-policy-1"] ... ) >>> print(results.body[0]["hasErrors"])
AsyncFleetPoliciesClient¶
Asynchronous version of the FleetPoliciesClient for use with async/await syntax.
- class kibana._async.client.fleet_policies.AsyncFleetPoliciesClient(client, default_space_id=None, validate_spaces=True)[source]¶
Bases:
AsyncNamespaceClientAsync client for the Kibana Fleet agent and package policies API.
Agent policies define how Elastic Agents behave: which outputs they ship data to, their monitoring settings and which integrations they run. Package policies attach an integration package (with its inputs and variables) to one or more agent policies. Agentless policies deploy an integration without a self-managed Elastic Agent (Elastic Cloud / serverless only).
Fleet policies are space-aware resources: every method accepts an optional
space_idto target a specific space (Nonetargets the default space or the space the client is scoped to).Example
>>> from kibana import AsyncKibana >>> client = AsyncKibana("http://localhost:5601", api_key="...") >>> >>> # Create an agent policy and attach a package policy to it >>> policy = await client.fleet_policies.create_agent_policy( ... name="my-agent-policy", ... namespace="default", ... sys_monitoring=False, ... ) >>> policy_id = policy.body["item"]["id"] >>> >>> pkg = await client.fleet_policies.create_package_policy( ... name="my-package-policy", ... package={"name": "log", "version": "2.4.4"}, ... policy_ids=[policy_id], ... inputs={"logs-logfile": {"enabled": True}}, ... ) >>> >>> # Clean up >>> await client.fleet_policies.delete_package_policy( ... package_policy_id=pkg.body["item"]["id"] ... ) >>> await client.fleet_policies.delete_agent_policy(agent_policy_id=policy_id)
Usage
The AsyncFleetPoliciesClient provides the same methods as FleetPoliciesClient 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: created = await client.fleet_policies.create_agent_policy( name="async-agent-policy", namespace="default", sys_monitoring=False, ) agent_policy_id = created.body["item"]["id"] yaml_doc = await client.fleet_policies.download_agent_policy( agent_policy_id=agent_policy_id ) await client.fleet_policies.delete_agent_policy( agent_policy_id=agent_policy_id ) asyncio.run(main())
- __init__(client, default_space_id=None, validate_spaces=True)[source]¶
Initialize the AsyncFleetPoliciesClient.
- 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
>>> fleet_policies_client = AsyncFleetPoliciesClient(kibana_client)
- async get_agent_policies(*, page=None, per_page=None, sort_field=None, sort_order=None, show_upgradeable=None, kuery=None, no_agent_count=None, with_agent_count=None, full=None, format=None, space_id=None, validate_spaces=None)[source]¶
Get agent policies.
GET /api/fleet/agent_policiesLists agent policies, optionally filtered with a KQL query and paginated.
- Parameters:
page (int | None) – Page number to return (1-based).
per_page (int | None) – Number of policies per page.
sort_field (str | None) – Field to sort the results by.
sort_order (str | None) – Sort direction, either
"asc"or"desc".show_upgradeable (bool | None) – Only return policies with agents that can be upgraded.
kuery (str | None) – KQL filter, e.g.
'ingest-agent-policies.name:"my-policy"'.no_agent_count (bool | None) – Do not compute the agent count per policy (deprecated in favor of
with_agent_count).with_agent_count (bool | None) – Include the number of enrolled agents for each policy.
full (bool | None) – Return the full policy representation (including package policies).
format (str | None) – Representation of package policies within each agent policy:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
items(list of agent policies),total,pageandperPage.- Raises:
BadRequestError – If a query parameter is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policies = await client.fleet_policies.get_agent_policies( ... kuery='ingest-agent-policies.name:"my-policy"', per_page=5 ... ) >>> print(policies.body["total"])
- async create_agent_policy(*, name, namespace, advanced_settings=None, agent_features=None, agentless=None, bump_revision=None, data_output_id=None, description=None, download_source_id=None, fleet_server_host_id=None, force=None, global_data_tags=None, has_agent_version_conditions=None, has_fleet_server=None, id=None, inactivity_timeout=None, is_default=None, is_default_fleet_server=None, is_managed=None, is_protected=None, is_verifier=None, keep_monitoring_alive=None, min_agent_version=None, monitoring_diagnostics=None, monitoring_enabled=None, monitoring_http=None, monitoring_output_id=None, monitoring_pprof_enabled=None, overrides=None, package_agent_version_conditions=None, required_versions=None, space_ids=None, supports_agentless=None, unenroll_timeout=None, sys_monitoring=None, space_id=None, validate_spaces=None)[source]¶
Create an agent policy.
POST /api/fleet/agent_policies- Parameters:
name (str) – Name of the agent policy (must be unique).
namespace (str) – Default data stream namespace for the policy’s integrations (e.g.
"default").advanced_settings (dict[str, Any] | None) – Advanced agent settings (e.g. log level).
agent_features (list[dict[str, Any]] | None) – Agent feature flags, list of
{"name": ..., "enabled": ...}objects.agentless (dict[str, Any] | None) – Agentless deployment configuration.
bump_revision (bool | None) – Bump the policy revision on creation.
data_output_id (str | None) – ID of the output used for integration data.
description (str | None) – Human-readable description of the policy.
download_source_id (str | None) – ID of the agent binary download source.
fleet_server_host_id (str | None) – ID of the Fleet Server host to use.
force (bool | None) – Force creation even if some preconditions fail.
global_data_tags (list[dict[str, Any]] | None) – Tags added to every document produced by the policy, list of
{"name": ..., "value": ...}objects.has_agent_version_conditions (bool | None) – Whether the policy has agent version conditions.
has_fleet_server (bool | None) – Whether the policy hosts a Fleet Server.
id (str | None) – Explicit ID for the new policy (auto-generated when omitted).
inactivity_timeout (int | None) – Seconds of inactivity before an agent is marked inactive (minimum 0, default 1209600).
is_default (bool | None) – Mark as the default agent policy.
is_default_fleet_server (bool | None) – Mark as the default Fleet Server policy.
is_managed (bool | None) – Mark the policy as hosted/managed (cannot be edited in the UI).
is_protected (bool | None) – Enable agent tamper protection.
is_verifier (bool | None) – Whether the policy is a verifier policy.
keep_monitoring_alive (bool | None) – Keep the monitoring server alive even when monitoring is disabled.
min_agent_version (str | None) – Minimum agent version allowed to enroll.
monitoring_diagnostics (dict[str, Any] | None) – Monitoring diagnostics rate limit / uploader settings.
monitoring_enabled (list[str] | None) – What to monitor on the agents; any of
"logs","metrics","traces".monitoring_http (dict[str, Any] | None) – Monitoring HTTP endpoint settings.
monitoring_output_id (str | None) – ID of the output used for agent monitoring data.
monitoring_pprof_enabled (bool | None) – Enable pprof profiling endpoints on the agents.
overrides (dict[str, Any] | None) – Overrides applied on top of the compiled full agent policy.
package_agent_version_conditions (list[dict[str, Any]] | None) – Per-package agent version conditions, list of
{"packageName": ..., "versionCondition": ...}objects.required_versions (list[dict[str, Any]] | None) – Target agent versions for automatic upgrades, list of
{"version": ..., "percentage": ...}objects.space_ids (list[str] | None) – IDs of the spaces the policy is shared with.
supports_agentless (bool | None) – Whether the policy supports agentless integrations (Elastic Cloud / serverless only).
unenroll_timeout (int | None) – Seconds after which inactive agents are automatically unenrolled.
sys_monitoring (bool | None) – Query flag; when True, also create a
systemmonitoring package policy on the new agent policy.space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the created agent policy (id,name,namespace,revision, …).- Raises:
BadRequestError – If the request body is invalid (e.g. duplicate name).
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> created = await client.fleet_policies.create_agent_policy( ... name="my-agent-policy", ... namespace="default", ... description="Policy for web servers", ... monitoring_enabled=["logs", "metrics"], ... sys_monitoring=False, ... ) >>> print(created.body["item"]["id"])
- async bulk_get_agent_policies(*, ids, full=None, ignore_missing=None, format=None, space_id=None, validate_spaces=None)[source]¶
Bulk get agent policies.
POST /api/fleet/agent_policies/_bulk_get- Parameters:
full (bool | None) – Return the full policy representation (including package policies).
ignore_missing (bool | None) – When True, missing IDs are silently skipped instead of producing a 404.
format (str | None) – Representation of package policies within each agent policy:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemscontaining the requested agent policies.- Raises:
BadRequestError – If the request body is invalid.
NotFoundError – If an ID is missing and
ignore_missingis not set.AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policies = await client.fleet_policies.bulk_get_agent_policies( ... ids=["policy-1", "policy-2"], ignore_missing=True ... ) >>> print(len(policies.body["items"]))
- async get_agent_policy(*, agent_policy_id, format=None, space_id=None, validate_spaces=None)[source]¶
Get an agent policy.
GET /api/fleet/agent_policies/{agentPolicyId}- Parameters:
agent_policy_id (str) – ID of the agent policy.
format (str | None) – Representation of package policies within the agent policy:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the agent policy.- Raises:
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policy = await client.fleet_policies.get_agent_policy( ... agent_policy_id="policy-1" ... ) >>> print(policy.body["item"]["name"])
- async update_agent_policy(*, agent_policy_id, name, namespace, advanced_settings=None, agent_features=None, agentless=None, bump_revision=None, data_output_id=None, description=None, download_source_id=None, fleet_server_host_id=None, force=None, global_data_tags=None, has_agent_version_conditions=None, has_fleet_server=None, id=None, inactivity_timeout=None, is_default=None, is_default_fleet_server=None, is_managed=None, is_protected=None, is_verifier=None, keep_monitoring_alive=None, min_agent_version=None, monitoring_diagnostics=None, monitoring_enabled=None, monitoring_http=None, monitoring_output_id=None, monitoring_pprof_enabled=None, overrides=None, package_agent_version_conditions=None, required_versions=None, space_ids=None, supports_agentless=None, unenroll_timeout=None, format=None, space_id=None, validate_spaces=None)[source]¶
Update an agent policy.
PUT /api/fleet/agent_policies/{agentPolicyId}This is a full update:
nameandnamespaceare required and omitted optional fields fall back to their defaults.- Parameters:
agent_policy_id (str) – ID of the agent policy to update.
name (str) – Name of the agent policy.
namespace (str) – Default data stream namespace for the policy’s integrations.
advanced_settings (dict[str, Any] | None) – Advanced agent settings (e.g. log level).
agent_features (list[dict[str, Any]] | None) – Agent feature flags, list of
{"name": ..., "enabled": ...}objects.agentless (dict[str, Any] | None) – Agentless deployment configuration.
bump_revision (bool | None) – Bump the policy revision even without changes.
data_output_id (str | None) – ID of the output used for integration data.
description (str | None) – Human-readable description of the policy.
download_source_id (str | None) – ID of the agent binary download source.
fleet_server_host_id (str | None) – ID of the Fleet Server host to use.
force (bool | None) – Force the update even if some preconditions fail (e.g. the policy is managed).
global_data_tags (list[dict[str, Any]] | None) – Tags added to every document produced by the policy, list of
{"name": ..., "value": ...}objects.has_agent_version_conditions (bool | None) – Whether the policy has agent version conditions.
has_fleet_server (bool | None) – Whether the policy hosts a Fleet Server.
id (str | None) – Policy ID field carried in the body.
inactivity_timeout (int | None) – Seconds of inactivity before an agent is marked inactive.
is_default (bool | None) – Mark as the default agent policy.
is_default_fleet_server (bool | None) – Mark as the default Fleet Server policy.
is_managed (bool | None) – Mark the policy as hosted/managed.
is_protected (bool | None) – Enable agent tamper protection.
is_verifier (bool | None) – Whether the policy is a verifier policy.
keep_monitoring_alive (bool | None) – Keep the monitoring server alive even when monitoring is disabled.
min_agent_version (str | None) – Minimum agent version allowed to enroll.
monitoring_diagnostics (dict[str, Any] | None) – Monitoring diagnostics rate limit / uploader settings.
monitoring_enabled (list[str] | None) – What to monitor on the agents; any of
"logs","metrics","traces".monitoring_http (dict[str, Any] | None) – Monitoring HTTP endpoint settings.
monitoring_output_id (str | None) – ID of the output used for agent monitoring data.
monitoring_pprof_enabled (bool | None) – Enable pprof profiling endpoints on the agents.
overrides (dict[str, Any] | None) – Overrides applied on top of the compiled full agent policy.
package_agent_version_conditions (list[dict[str, Any]] | None) – Per-package agent version conditions.
required_versions (list[dict[str, Any]] | None) – Target agent versions for automatic upgrades.
space_ids (list[str] | None) – IDs of the spaces the policy is shared with.
supports_agentless (bool | None) – Whether the policy supports agentless integrations (Elastic Cloud / serverless only).
unenroll_timeout (int | None) – Seconds after which inactive agents are automatically unenrolled.
format (str | None) – Representation of package policies in the response:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the updated agent policy (with a bumpedrevision).- Raises:
BadRequestError – If the request body is invalid.
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> updated = await client.fleet_policies.update_agent_policy( ... agent_policy_id="policy-1", ... name="my-agent-policy", ... namespace="default", ... description="Updated description", ... ) >>> print(updated.body["item"]["revision"])
- async get_auto_upgrade_agents_status(*, agent_policy_id, space_id=None, validate_spaces=None)[source]¶
Get the auto-upgrade agents status for an agent policy.
GET /api/fleet/agent_policies/{agentPolicyId}/auto_upgrade_agents_statusReports how many agents run each target version configured in the policy’s
required_versions(automatic upgrades).- Parameters:
- Returns:
ObjectApiResponse with
currentVersions(per-version agent counts and failed upgrades) andtotalAgents.- Raises:
BadRequestError – If the request is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> status = await client.fleet_policies.get_auto_upgrade_agents_status( ... agent_policy_id="policy-1" ... ) >>> print(status.body["totalAgents"])
- async copy_agent_policy(*, agent_policy_id, name, description=None, format=None, space_id=None, validate_spaces=None)[source]¶
Copy an agent policy.
POST /api/fleet/agent_policies/{agentPolicyId}/copyDuplicates the agent policy (including its package policies) under a new name.
- Parameters:
agent_policy_id (str) – ID of the agent policy to copy.
name (str) – Name for the new (copied) agent policy; must be unique.
description (str | None) – Description for the new agent policy.
format (str | None) – Representation of package policies in the response:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the newly created copy of the agent policy.- Raises:
BadRequestError – If the name is already in use.
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> copy = await client.fleet_policies.copy_agent_policy( ... agent_policy_id="policy-1", name="policy-1 (copy)" ... ) >>> print(copy.body["item"]["id"])
- async download_agent_policy(*, agent_policy_id, download=None, standalone=None, kubernetes=None, revision=None, space_id=None, validate_spaces=None)[source]¶
Download an agent policy as YAML.
GET /api/fleet/agent_policies/{agentPolicyId}/downloadReturns the compiled policy document served as a downloadable
elastic-agent.ymlfile. The live server responds withtext/x-yaml, so the response body is the raw YAML string (the returned object is aTextApiResponseat runtime).- Parameters:
agent_policy_id (str) – ID of the agent policy.
download (bool | None) – Serve the document as a file download.
standalone (bool | None) – Render the standalone (non-Fleet-managed) variant of the policy.
kubernetes (bool | None) – Render the Kubernetes manifest variant of the policy.
revision (int | None) – Specific policy revision to download (defaults to the latest).
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse whose body is the YAML policy document as a string.
- Raises:
BadRequestError – If the request is invalid.
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> yaml_doc = await client.fleet_policies.download_agent_policy( ... agent_policy_id="policy-1" ... ) >>> print(yaml_doc.body[:20])
- async get_full_agent_policy(*, agent_policy_id, download=None, standalone=None, kubernetes=None, revision=None, space_id=None, validate_spaces=None)[source]¶
Get a full (compiled) agent policy.
GET /api/fleet/agent_policies/{agentPolicyId}/fullReturns the complete policy document as JSON — the same content an enrolled Elastic Agent receives, including outputs and compiled inputs.
- Parameters:
agent_policy_id (str) – ID of the agent policy.
download (bool | None) – Serve the document as a file download.
standalone (bool | None) – Render the standalone (non-Fleet-managed) variant of the policy.
kubernetes (bool | None) – Render the Kubernetes manifest variant of the policy.
revision (int | None) – Specific policy revision to fetch (defaults to the latest).
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the full agent policy document (or the Kubernetes manifest string whenkubernetes=True).- Raises:
BadRequestError – If the request is invalid.
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> full = await client.fleet_policies.get_full_agent_policy( ... agent_policy_id="policy-1" ... ) >>> print(full.body["item"]["outputs"].keys())
- async get_agent_policy_outputs(*, agent_policy_id, space_id=None, validate_spaces=None)[source]¶
Get outputs for an agent policy.
GET /api/fleet/agent_policies/{agentPolicyId}/outputs- Parameters:
- Returns:
ObjectApiResponse with
itemdescribing thedataandmonitoringoutputs used by the policy (and per-integration output overrides).- Raises:
BadRequestError – If the request is invalid.
NotFoundError – If the agent policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> outputs = await client.fleet_policies.get_agent_policy_outputs( ... agent_policy_id="policy-1" ... ) >>> print(outputs.body["item"]["data"]["output"]["id"])
- async delete_agent_policy(*, agent_policy_id, force=None, space_id=None, validate_spaces=None)[source]¶
Delete an agent policy.
POST /api/fleet/agent_policies/deleteDeletes the agent policy and its package policies. Policies with enrolled agents cannot be deleted.
- Parameters:
- Returns:
ObjectApiResponse with the
idandnameof the deleted agent policy.- Raises:
BadRequestError – If the policy cannot be deleted (e.g. agents are still enrolled or the policy does not exist).
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> deleted = await client.fleet_policies.delete_agent_policy( ... agent_policy_id="policy-1" ... ) >>> print(deleted.body["id"])
- async get_agent_policies_outputs(*, ids, space_id=None, validate_spaces=None)[source]¶
Get outputs for multiple agent policies.
POST /api/fleet/agent_policies/outputs- Parameters:
- Returns:
one entry per agent policy describing its
dataandmonitoringoutputs.- Return type:
ObjectApiResponse with
items- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
Example
>>> outputs = await client.fleet_policies.get_agent_policies_outputs( ... ids=["policy-1", "policy-2"] ... ) >>> print(len(outputs.body["items"]))
- async create_agentless_policy(*, name, package, additional_datastreams_permissions=None, cloud_connector=None, condition=None, description=None, force=None, global_data_tags=None, id=None, inputs=None, namespace=None, policy_template=None, var_group_selections=None, vars=None, format=None, space_id=None, validate_spaces=None)[source]¶
Create an agentless policy.
POST /api/fleet/agentless_policiesDeploys an integration without a self-managed Elastic Agent. The agentless feature is only available in Elastic Cloud and serverless environments; on self-managed deployments the server rejects the request with a 400 error.
- Parameters:
name (str) – Name for the agentless integration policy.
package (dict[str, Any]) – The integration package, e.g.
{"name": "cspm", "version": "1.0.0"}.additional_datastreams_permissions (list[str] | None) – Additional data stream permission patterns granted to the policy.
cloud_connector (dict[str, Any] | None) – Cloud connector settings, e.g.
{"enabled": True, "target_csp": "aws"}.condition (str | None) – Condition under which the inputs are active.
description (str | None) – Human-readable description of the policy.
force (bool | None) – Force creation even if some preconditions fail.
global_data_tags (list[dict[str, Any]] | None) – Tags added to every document produced by the policy, list of
{"name": ..., "value": ...}objects.id (str | None) – Explicit ID for the new policy (auto-generated when omitted).
inputs (dict[str, Any] | None) – Package policy inputs in the simplified (object) format, keyed by
<policy_template>-<input_type>.namespace (str | None) – Data stream namespace for the policy’s data.
policy_template (str | None) – Name of the package policy template to use.
var_group_selections (dict[str, Any] | None) – Selected variable groups, keyed by group name.
vars (dict[str, Any] | None) – Package-level variables in the simplified format.
format (str | None) – Response format:
"simplified"(default) or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the created package policy backing the agentless deployment.- Raises:
BadRequestError – If the request is invalid or the deployment does not support the agentless feature.
ConflictError – If an agentless policy with the same name exists.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> created = await client.fleet_policies.create_agentless_policy( ... name="my-agentless-policy", ... package={"name": "cspm", "version": "1.0.0"}, ... ) >>> print(created.body["item"]["id"])
- async delete_agentless_policy(*, policy_id, force=None, space_id=None, validate_spaces=None)[source]¶
Delete an agentless policy.
DELETE /api/fleet/agentless_policies/{policyId}Tears down the agentless deployment and deletes the backing package policy. On the live 9.4.3 server this endpoint responds 200 with
{"id": ...}even for unknown policy IDs (idempotent delete).- Parameters:
- Returns:
ObjectApiResponse with the
idof the deleted policy.- Raises:
BadRequestError – If the request is invalid.
ConflictError – If the policy cannot be deleted right now.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> deleted = await client.fleet_policies.delete_agentless_policy( ... policy_id="agentless-policy-1" ... ) >>> print(deleted.body["id"])
- async get_package_policies(*, page=None, per_page=None, sort_field=None, sort_order=None, show_upgradeable=None, kuery=None, format=None, with_agent_count=None, space_id=None, validate_spaces=None)[source]¶
Get package policies.
GET /api/fleet/package_policiesLists package policies (integration policies), optionally filtered with a KQL query and paginated.
- Parameters:
page (int | None) – Page number to return (1-based).
per_page (int | None) – Number of policies per page.
sort_field (str | None) – Field to sort the results by.
sort_order (str | None) – Sort direction, either
"asc"or"desc".show_upgradeable (bool | None) – Only return policies that can be upgraded to a newer package version.
kuery (str | None) – KQL filter, e.g.
'ingest-package-policies.package.name:"nginx"'.format (str | None) – Response format:
"simplified"or"legacy".with_agent_count (bool | None) – Include the number of agents using each policy.
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
items(list of package policies),total,pageandperPage.- Raises:
BadRequestError – If a query parameter is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policies = await client.fleet_policies.get_package_policies( ... kuery='ingest-package-policies.package.name:"log"' ... ) >>> print(policies.body["total"])
- async create_package_policy(*, name, package, additional_datastreams_permissions=None, cloud_connector=None, cloud_connector_id=None, cloud_connector_name=None, condition=None, description=None, enabled=None, force=None, global_data_tags=None, id=None, inputs=None, is_managed=None, namespace=None, output_id=None, overrides=None, package_agent_version_condition=None, policy_id=None, policy_ids=None, policy_template=None, space_ids=None, supports_agentless=None, supports_cloud_connector=None, var_group_selections=None, vars=None, format=None, space_id=None, validate_spaces=None)[source]¶
Create a package policy.
POST /api/fleet/package_policiesAttaches an integration package to one or more agent policies. The API accepts two body formats: the classic (legacy) format with
inputsas a list of input objects, and the simplified format withinputsas an object keyed by<policy_template>-<input_type>. Pass a list or a dict forinputsaccordingly. If the package is not installed yet, Kibana installs it from the registry as part of this call.- Parameters:
name (str) – Name for the package policy (must be unique).
package (dict[str, Any]) – The integration package, e.g.
{"name": "log", "version": "2.4.4"}.additional_datastreams_permissions (list[str] | None) – Additional data stream permission patterns granted to the policy.
cloud_connector (dict[str, Any] | None) – Cloud connector settings (simplified format).
cloud_connector_id (str | None) – ID of an existing cloud connector (classic format).
cloud_connector_name (str | None) – Name of the cloud connector (classic format).
condition (str | None) – Condition under which the inputs are active (simplified format).
description (str | None) – Human-readable description of the policy.
enabled (bool | None) – Whether the package policy is enabled (classic format).
force (bool | None) – Force creation even if some preconditions fail (e.g. package below the minimum required version).
global_data_tags (list[dict[str, Any]] | None) – Tags added to every document produced by the policy, list of
{"name": ..., "value": ...}objects.id (str | None) – Explicit ID for the new policy (auto-generated when omitted).
inputs (list[dict[str, Any]] | dict[str, Any] | None) – Package policy inputs: a list of input objects (classic format) or an object keyed by
<policy_template>-<input_type>(simplified format).is_managed (bool | None) – Mark the policy as managed (classic format).
namespace (str | None) – Data stream namespace for the policy’s data; falls back to the agent policy’s namespace when omitted.
output_id (str | None) – ID of the output to send this integration’s data to (classic format).
overrides (dict[str, Any] | None) – Overrides for the compiled package policy (classic format); use only in automation.
package_agent_version_condition (str | None) – Agent version condition for the package (classic format).
policy_id (str | None) – ID of the agent policy to add this policy to (deprecated, use
policy_ids).policy_ids (list[str] | None) – IDs of the agent policies to add this policy to.
policy_template (str | None) – Name of the package policy template to use (simplified format).
space_ids (list[str] | None) – IDs of the spaces the policy is available in (classic format, sent as
spaceIds).supports_agentless (bool | None) – Whether the policy supports agentless deployments (classic format).
supports_cloud_connector (bool | None) – Whether the policy supports cloud connectors (classic format).
var_group_selections (dict[str, Any] | None) – Selected variable groups, keyed by group name.
vars (dict[str, Any] | None) – Package-level variables (simplified format, or classic input-level structure).
format (str | None) – Response format:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the created package policy.- Raises:
BadRequestError – If the request body is invalid (e.g. unknown input or stream).
ConflictError – If a package policy with the same name exists.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> created = await client.fleet_policies.create_package_policy( ... name="my-log-policy", ... package={"name": "log", "version": "2.4.4"}, ... policy_ids=["policy-1"], ... inputs={ ... "logs-logfile": { ... "enabled": True, ... "streams": { ... "log.logs": { ... "enabled": True, ... "vars": {"paths": ["/var/log/app.log"]}, ... } ... }, ... } ... }, ... ) >>> print(created.body["item"]["id"])
- async bulk_get_package_policies(*, ids, ignore_missing=None, format=None, space_id=None, validate_spaces=None)[source]¶
Bulk get package policies.
POST /api/fleet/package_policies/_bulk_get- Parameters:
ignore_missing (bool | None) – When True, missing IDs are silently skipped instead of producing a 404.
format (str | None) – Response format:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemscontaining the requested package policies.- Raises:
BadRequestError – If the request body is invalid.
NotFoundError – If an ID is missing and
ignore_missingis not set.AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policies = await client.fleet_policies.bulk_get_package_policies( ... ids=["pkg-policy-1"], ignore_missing=True ... ) >>> print(len(policies.body["items"]))
- async get_package_policy(*, package_policy_id, format=None, space_id=None, validate_spaces=None)[source]¶
Get a package policy.
GET /api/fleet/package_policies/{packagePolicyId}- Parameters:
- Returns:
ObjectApiResponse with
itemcontaining the package policy.- Raises:
NotFoundError – If the package policy does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> policy = await client.fleet_policies.get_package_policy( ... package_policy_id="pkg-policy-1" ... ) >>> print(policy.body["item"]["name"])
- async update_package_policy(*, package_policy_id, package, name=None, additional_datastreams_permissions=None, cloud_connector=None, cloud_connector_id=None, cloud_connector_name=None, condition=None, description=None, enabled=None, force=None, global_data_tags=None, id=None, inputs=None, is_managed=None, namespace=None, output_id=None, overrides=None, package_agent_version_condition=None, policy_id=None, policy_ids=None, policy_template=None, space_ids=None, supports_agentless=None, supports_cloud_connector=None, var_group_selections=None, vars=None, version=None, format=None, space_id=None, validate_spaces=None)[source]¶
Update a package policy.
PUT /api/fleet/package_policies/{packagePolicyId}Accepts the same two body formats as
create_package_policy()(classic withinputsas a list, simplified withinputsas an object).nameis required by the simplified format.- Parameters:
package_policy_id (str) – ID of the package policy to update.
package (dict[str, Any]) – The integration package, e.g.
{"name": "log", "version": "2.4.4"}.name (str | None) – Name for the package policy.
additional_datastreams_permissions (list[str] | None) – Additional data stream permission patterns granted to the policy.
cloud_connector (dict[str, Any] | None) – Cloud connector settings (simplified format).
cloud_connector_id (str | None) – ID of an existing cloud connector (classic format).
cloud_connector_name (str | None) – Name of the cloud connector (classic format).
condition (str | None) – Condition under which the inputs are active (simplified format).
description (str | None) – Human-readable description of the policy.
enabled (bool | None) – Whether the package policy is enabled (classic format).
force (bool | None) – Force the update even if some preconditions fail.
global_data_tags (list[dict[str, Any]] | None) – Tags added to every document produced by the policy.
id (str | None) – Policy ID field carried in the body (simplified format).
inputs (list[dict[str, Any]] | dict[str, Any] | None) – Package policy inputs: a list of input objects (classic format) or an object keyed by
<policy_template>-<input_type>(simplified format).is_managed (bool | None) – Mark the policy as managed (classic format).
namespace (str | None) – Data stream namespace for the policy’s data.
output_id (str | None) – ID of the output to send this integration’s data to (classic format).
overrides (dict[str, Any] | None) – Overrides for the compiled package policy (classic format).
package_agent_version_condition (str | None) – Agent version condition for the package (classic format).
policy_id (str | None) – ID of the agent policy the policy belongs to (deprecated, use
policy_ids).policy_ids (list[str] | None) – IDs of the agent policies the policy belongs to.
policy_template (str | None) – Name of the package policy template to use (simplified format).
space_ids (list[str] | None) – IDs of the spaces the policy is available in (classic format, sent as
spaceIds).supports_agentless (bool | None) – Whether the policy supports agentless deployments (classic format).
supports_cloud_connector (bool | None) – Whether the policy supports cloud connectors (classic format).
var_group_selections (dict[str, Any] | None) – Selected variable groups, keyed by group name.
vars (dict[str, Any] | None) – Package-level variables (simplified format, or classic input-level structure).
version (str | None) – Saved-object version of the policy (classic format, optimistic concurrency).
format (str | None) – Response format:
"simplified"or"legacy".space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with
itemcontaining the updated package policy (with a bumpedrevision).- Raises:
BadRequestError – If the request body is invalid.
AuthorizationException – If insufficient privileges.
NotFoundError – If the package policy does not exist.
AuthenticationException – If authentication fails.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> updated = await client.fleet_policies.update_package_policy( ... package_policy_id="pkg-policy-1", ... package={"name": "log", "version": "2.4.4"}, ... description="Updated description", ... ) >>> print(updated.body["item"]["revision"])
- async delete_package_policy(*, package_policy_id, force=None, space_id=None, validate_spaces=None)[source]¶
Delete a package policy.
DELETE /api/fleet/package_policies/{packagePolicyId}- Parameters:
package_policy_id (str) – ID of the package policy to delete.
force (bool | None) – Force deletion even if the policy is used by agents or marked as managed.
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse with the
idof the deleted package policy.- Raises:
BadRequestError – If the policy cannot be deleted or does not exist.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> deleted = await client.fleet_policies.delete_package_policy( ... package_policy_id="pkg-policy-1" ... ) >>> print(deleted.body["id"])
- async bulk_delete_package_policies(*, package_policy_ids, force=None, space_id=None, validate_spaces=None)[source]¶
Bulk delete package policies.
POST /api/fleet/package_policies/delete- Parameters:
package_policy_ids (list[str]) – IDs of the package policies to delete.
force (bool | None) – Force deletion even if the policies are used by agents or marked as managed.
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse whose body is a list with one result entry per policy (
id,name,success, …).- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> results = await client.fleet_policies.bulk_delete_package_policies( ... package_policy_ids=["pkg-policy-1"], force=True ... ) >>> print(results.body[0]["success"])
- async upgrade_package_policies(*, package_policy_ids, space_id=None, validate_spaces=None)[source]¶
Upgrade package policies to the latest installed package version.
POST /api/fleet/package_policies/upgrade- Parameters:
- Returns:
ObjectApiResponse whose body is a list with one result entry per policy (
id,name,successand optionalstatusCode/bodyon failure).- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> results = await client.fleet_policies.upgrade_package_policies( ... package_policy_ids=["pkg-policy-1"] ... ) >>> print(results.body[0]["success"])
- async upgrade_package_policies_dry_run(*, package_policy_ids, package_version=None, space_id=None, validate_spaces=None)[source]¶
Dry run a package policy upgrade.
POST /api/fleet/package_policies/upgrade/dryrunComputes the diff an upgrade would produce without persisting any change.
- Parameters:
package_policy_ids (list[str]) – IDs of the package policies to check.
package_version (str | None) – Target package version to simulate the upgrade against (defaults to the latest installed version).
space_id (str | None) – Optional space ID to scope the operation to.
validate_spaces (bool | None) – Override space validation setting for this operation.
- Returns:
ObjectApiResponse whose body is a list with one result entry per policy, each containing
name,diff(current vs proposed policy) andhasErrors.- Raises:
BadRequestError – If the request body is invalid.
AuthenticationException – If authentication fails.
AuthorizationException – If insufficient privileges.
SpaceNotFoundError – If the space doesn’t exist and validation is enabled.
- Return type:
Example
>>> results = await client.fleet_policies.upgrade_package_policies_dry_run( ... package_policy_ids=["pkg-policy-1"] ... ) >>> print(results.body[0]["hasErrors"])