For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/api/latest/security-monitoring/update-an-existing-rule.md. A documentation index is available at /llms.txt.
Language
Datadog site

Update an existing rule

PUThttps://api.datadoghq.com/api/v2/security_monitoring/rules/{rule_id}https://api.us3.datadoghq.com/api/v2/security_monitoring/rules/{rule_id}https://api.us5.datadoghq.com/api/v2/security_monitoring/rules/{rule_id}https://api.datadoghq.eu/api/v2/security_monitoring/rules/{rule_id}https://api.ap1.datadoghq.com/api/v2/security_monitoring/rules/{rule_id}https://api.ap2.datadoghq.com/api/v2/security_monitoring/rules/{rule_id}https://api.uk1.datadoghq.com/api/v2/security_monitoring/rules/{rule_id}https://api.ddog-gov.com/api/v2/security_monitoring/rules/{rule_id}https://api.us2.ddog-gov.com/api/v2/security_monitoring/rules/{rule_id}

Overview

Update an existing rule. When updating cases, queries or options, the whole field must be included. For example, when modifying a query all queries must be included. Default rules can only be updated to be enabled, to change notifications, or to update the tags (default tags cannot be removed).

This endpoint requires the security_monitoring_rules_write permission.

OAuth apps require the security_monitoring_rules_write authorization scope to access this endpoint.

Arguments

Path Parameters

Name
Type
Description
rule_id [required]
string

The ID of the rule.

Request

Body Data (required)

Field
Type
Description
calculatedFields
[object]

Calculated fields. Only allowed for scheduled rules - in other words, when schedulingOptions is also defined.

cases
[object]

Cases for generating signals.

complianceSignalOptions
object

How to generate compliance signals. Useful for cloud_configuration rules only.

customMessage
string

Custom/Overridden Message for generated signals (used in case of Default rule update).

customName
string

Custom/Overridden name (used in case of Default rule update).

filters
[object]

Additional queries to filter matched events before they are processed. This field is deprecated for log detection, signal correlation, and workload security rules.

groupSignalsBy
[string]

Additional grouping to perform on top of the existing groups in the query section. Must be a subset of the existing groups.

hasExtendedTitle
boolean

Whether the notifications include the triggering group-by values in their title.

isEnabled
boolean

Whether the rule is enabled.

message
string

Message for generated signals.

name
string

Name of the rule.

options
object

Options.

queries
[<oneOf>]

Queries for selecting logs which are part of the rule.

referenceTables
[object]

Reference tables for the rule.

schedulingOptions
object

Options for scheduled rules. When this field is present, the rule runs based on the schedule. When absent, it runs real-time on ingested logs.

tags
[string]

Tags for generated signals.

thirdPartyCases
[object]

Cases for generating signals from third-party rules. Only available for third-party rules.

version
int32

The version of the rule being updated.

Response

OK

Create a new rule.

Field
Type
Description
Option 1
object

Rule.

Option 2
object

Rule.

Code Example

# Path parameters
export rule_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/security_monitoring/rules/${rule_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "cases": [
    {
      "condition": "a > 0",
      "name": "",
      "notifications": [],
      "status": "info"
    }
  ],
  "filters": [],
  "isEnabled": true,
  "message": "Test rule",
  "name": "My security monitoring rule.",
  "options": {
    "evaluationWindow": 900,
    "keepAlive": 3600,
    "maxSignalDuration": 86400
  },
  "queries": [
    {
      "aggregation": "count",
      "distinctFields": [],
      "groupByFields": [],
      "metrics": [],
      "query": "@test:true"
    }
  ],
  "tags": []
}
EOF
# Path parameters
export rule_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/security_monitoring/rules/${rule_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "cases": [
    {
      "condition": "a > 0",
      "name": "",
      "notifications": [],
      "status": "info"
    }
  ],
  "filters": [],
  "isEnabled": true,
  "message": "Test rule",
  "name": "My security monitoring rule.",
  "options": {
    "evaluationWindow": 900,
    "keepAlive": 3600,
    "maxSignalDuration": 86400
  },
  "queries": [
    {
      "aggregation": "count",
      "distinctFields": [],
      "groupByFields": [],
      "metrics": [],
      "query": "@test:true"
    }
  ],
  "tags": []
}
EOF
# Path parameters
export rule_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/security_monitoring/rules/${rule_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "cases": [
    {
      "condition": "a > 0",
      "name": "",
      "notifications": [],
      "status": "info"
    }
  ],
  "filters": [],
  "isEnabled": true,
  "message": "Test rule",
  "name": "My security monitoring rule.",
  "options": {
    "evaluationWindow": 900,
    "keepAlive": 3600,
    "maxSignalDuration": 86400
  },
  "queries": [
    {
      "aggregation": "count",
      "distinctFields": [],
      "groupByFields": [],
      "metrics": [],
      "query": "@test:true"
    }
  ],
  "tags": []
}
EOF
# Path parameters
export rule_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/security_monitoring/rules/${rule_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "cases": [
    {
      "condition": "a > 0",
      "name": "",
      "notifications": [],
      "status": "info"
    }
  ],
  "filters": [],
  "isEnabled": true,
  "message": "Test rule",
  "name": "My security monitoring rule.",
  "options": {
    "evaluationWindow": 900,
    "keepAlive": 3600,
    "maxSignalDuration": 86400
  },
  "queries": [
    {
      "aggregation": "count",
      "distinctFields": [],
      "groupByFields": [],
      "metrics": [],
      "query": "@test:true"
    }
  ],
  "tags": []
}
EOF
# Path parameters
export rule_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/security_monitoring/rules/${rule_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "cases": [
    {
      "condition": "a > 0",
      "name": "",
      "notifications": [],
      "status": "info"
    }
  ],
  "filters": [],
  "isEnabled": true,
  "message": "Test rule",
  "name": "My security monitoring rule.",
  "options": {
    "evaluationWindow": 900,
    "keepAlive": 3600,
    "maxSignalDuration": 86400
  },
  "queries": [
    {
      "aggregation": "count",
      "distinctFields": [],
      "groupByFields": [],
      "metrics": [],
      "query": "@test:true"
    }
  ],
  "tags": []
}
EOF
# Path parameters
export rule_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/security_monitoring/rules/${rule_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "cases": [
    {
      "condition": "a > 0",
      "name": "",
      "notifications": [],
      "status": "info"
    }
  ],
  "filters": [],
  "isEnabled": true,
  "message": "Test rule",
  "name": "My security monitoring rule.",
  "options": {
    "evaluationWindow": 900,
    "keepAlive": 3600,
    "maxSignalDuration": 86400
  },
  "queries": [
    {
      "aggregation": "count",
      "distinctFields": [],
      "groupByFields": [],
      "metrics": [],
      "query": "@test:true"
    }
  ],
  "tags": []
}
EOF
# Path parameters
export rule_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/security_monitoring/rules/${rule_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "cases": [
    {
      "condition": "a > 0",
      "name": "",
      "notifications": [],
      "status": "info"
    }
  ],
  "filters": [],
  "isEnabled": true,
  "message": "Test rule",
  "name": "My security monitoring rule.",
  "options": {
    "evaluationWindow": 900,
    "keepAlive": 3600,
    "maxSignalDuration": 86400
  },
  "queries": [
    {
      "aggregation": "count",
      "distinctFields": [],
      "groupByFields": [],
      "metrics": [],
      "query": "@test:true"
    }
  ],
  "tags": []
}
EOF
# Path parameters
export rule_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/security_monitoring/rules/${rule_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "cases": [
    {
      "condition": "a > 0",
      "name": "",
      "notifications": [],
      "status": "info"
    }
  ],
  "filters": [],
  "isEnabled": true,
  "message": "Test rule",
  "name": "My security monitoring rule.",
  "options": {
    "evaluationWindow": 900,
    "keepAlive": 3600,
    "maxSignalDuration": 86400
  },
  "queries": [
    {
      "aggregation": "count",
      "distinctFields": [],
      "groupByFields": [],
      "metrics": [],
      "query": "@test:true"
    }
  ],
  "tags": []
}
EOF
# Path parameters
export rule_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PUT "https://api.${DD_SITE}/api/v2/security_monitoring/rules/${rule_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "cases": [
    {
      "condition": "a > 0",
      "name": "",
      "notifications": [],
      "status": "info"
    }
  ],
  "filters": [],
  "isEnabled": true,
  "message": "Test rule",
  "name": "My security monitoring rule.",
  "options": {
    "evaluationWindow": 900,
    "keepAlive": 3600,
    "maxSignalDuration": 86400
  },
  "queries": [
    {
      "aggregation": "count",
      "distinctFields": [],
      "groupByFields": [],
      "metrics": [],
      "query": "@test:true"
    }
  ],
  "tags": []
}
EOF