Import detection rules
https://{kibana_url}
- POST /api/detection_engine/rules/_import
- POST /s/{space_id}/api/detection_engine/rules/_import
Refer to Spaces for more information.
Import detection rules from an .ndjson file, including actions and exception lists. The request must include:
- The
Content-Type: multipart/form-dataHTTP header. - A link to the
.ndjsonfile containing the rules.
warn When used with API key authentication, the user's key gets assigned to the affected rules. If the user's key gets deleted or the user becomes inactive, the rules will stop running.
If the API key that is used for authorization has different privileges than the key that created or most recently updated the rule, the rule behavior might change. info To import rules with actions, you need at least Read privileges for the Action and Connectors feature. To overwrite or add new connectors, you need All privileges for the Actions and Connectors feature. To import rules without actions, you don’t need Actions and Connectors privileges. Refer to Enable and access detections for more information.
info Rule actions and connectors are included in the exported file, but sensitive information about the connector (such as authentication credentials) is not included. You must re-add missing connector details after importing detection rules.
You can use Kibana’s Saved Objects UI (Stack Management → Kibana → Saved Objects) or the Saved Objects APIs (experimental) to export and import any necessary connectors before importing detection rules.
Similarly, any value lists used for rule exceptions are not included in rule exports or imports. Use the Manage value lists UI (Rules → Detection rules (SIEM) → Manage value lists) to export and import value lists separately.
Query Parameters
-
overwriteboolean · default: false Determines whether existing rules with the same
rule_idare overwritten.-
overwrite_exceptionsboolean · default: false Determines whether existing exception lists with the same
list_idare overwritten. Both the exception list container and its items are overwritten.-
overwrite_action_connectorsboolean · default: false Determines whether existing actions with the same
kibana.alert.rule.actions.idare overwritten.-
as_new_listboolean · default: false Generates a new list ID for each imported exception list.
Response
Indicates a successful call.
-
action_connectors_errorsobjectrequired -
errorobjectrequired -
messagestringrequired -
status_codeinteger · min: 400required -
idstring -
item_idstring · min: 1 -
list_idstring · min: 1 -
rule_idstring -
A stable unique identifier for the rule object. It can be assigned during rule creation. It can be any string, but often is a UUID. It should be unique not only within a given Kibana space, but also across spaces and Elastic environments. The same prebuilt Elastic rule, when installed in two different Kibana spaces or two different Elastic environments, will have the same
rule_ids. -
action_connectors_successbooleanrequired -
action_connectors_success_countinteger · min: 0required -
action_connectors_warningsobjectrequired -
actionPathstringrequired -
messagestringrequired -
typestringrequired -
errorsobjectrequired -
errorobjectrequired -
messagestringrequired -
status_codeinteger · min: 400required -
idstring -
item_idstring · min: 1 -
list_idstring · min: 1 -
rule_idstring -
A stable unique identifier for the rule object. It can be assigned during rule creation. It can be any string, but often is a UUID. It should be unique not only within a given Kibana space, but also across spaces and Elastic environments. The same prebuilt Elastic rule, when installed in two different Kibana spaces or two different Elastic environments, will have the same
rule_ids. -
exceptions_errorsobjectrequired -
errorobjectrequired -
messagestringrequired -
status_codeinteger · min: 400required -
idstring -
item_idstring · min: 1 -
list_idstring · min: 1 -
rule_idstring -
A stable unique identifier for the rule object. It can be assigned during rule creation. It can be any string, but often is a UUID. It should be unique not only within a given Kibana space, but also across spaces and Elastic environments. The same prebuilt Elastic rule, when installed in two different Kibana spaces or two different Elastic environments, will have the same
rule_ids. -
exceptions_successbooleanrequired -
exceptions_success_countinteger · min: 0required -
rules_countinteger · min: 0required -
successbooleanrequired -
success_countinteger · min: 0required