For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/api/latest/sensitive-data-scanner/create-scanning-rule.md. A documentation index is available at /llms.txt.
Language
Datadog site

Create Scanning Rule

POSThttps://api.datadoghq.com/api/v2/sensitive-data-scanner/config/ruleshttps://api.us3.datadoghq.com/api/v2/sensitive-data-scanner/config/ruleshttps://api.us5.datadoghq.com/api/v2/sensitive-data-scanner/config/ruleshttps://api.datadoghq.eu/api/v2/sensitive-data-scanner/config/ruleshttps://api.ap1.datadoghq.com/api/v2/sensitive-data-scanner/config/ruleshttps://api.ap2.datadoghq.com/api/v2/sensitive-data-scanner/config/ruleshttps://api.uk1.datadoghq.com/api/v2/sensitive-data-scanner/config/ruleshttps://api.ddog-gov.com/api/v2/sensitive-data-scanner/config/ruleshttps://api.us2.ddog-gov.com/api/v2/sensitive-data-scanner/config/rules

Overview

Create a scanning rule in a sensitive data scanner group, ordered last. The posted rule MUST include a group relationship. It MUST include either a standard_pattern relationship or a regex attribute, but not both. If included_attributes is empty or missing, we will scan all attributes except excluded_attributes. If both are missing, we will scan the whole event.

This endpoint requires the data_scanner_write permission.

Request

Body Data (required)

Field
Type
Description
data [required]
object

Data related to the creation of a rule.

meta [required]
object

Meta payload containing information about the API.

Response

OK

Create rule response.

Field
Type
Description
data
object

Response data related to the creation of a rule.

meta
object

Meta payload containing information about the API.

Code Example

Create Scanning Rule returns "OK" response
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "namespaces": [
        "admin"
      ],
      "excluded_namespaces": [
        "admin.name"
      ],
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1,
      "included_keyword_configuration": {
        "keywords": [
          "credit card"
        ],
        "character_count": 35
      }
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "namespaces": [
        "admin"
      ],
      "excluded_namespaces": [
        "admin.name"
      ],
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1,
      "included_keyword_configuration": {
        "keywords": [
          "credit card"
        ],
        "character_count": 35
      }
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "namespaces": [
        "admin"
      ],
      "excluded_namespaces": [
        "admin.name"
      ],
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1,
      "included_keyword_configuration": {
        "keywords": [
          "credit card"
        ],
        "character_count": 35
      }
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "namespaces": [
        "admin"
      ],
      "excluded_namespaces": [
        "admin.name"
      ],
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1,
      "included_keyword_configuration": {
        "keywords": [
          "credit card"
        ],
        "character_count": 35
      }
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "namespaces": [
        "admin"
      ],
      "excluded_namespaces": [
        "admin.name"
      ],
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1,
      "included_keyword_configuration": {
        "keywords": [
          "credit card"
        ],
        "character_count": 35
      }
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "namespaces": [
        "admin"
      ],
      "excluded_namespaces": [
        "admin.name"
      ],
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1,
      "included_keyword_configuration": {
        "keywords": [
          "credit card"
        ],
        "character_count": 35
      }
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "namespaces": [
        "admin"
      ],
      "excluded_namespaces": [
        "admin.name"
      ],
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1,
      "included_keyword_configuration": {
        "keywords": [
          "credit card"
        ],
        "character_count": 35
      }
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "namespaces": [
        "admin"
      ],
      "excluded_namespaces": [
        "admin.name"
      ],
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1,
      "included_keyword_configuration": {
        "keywords": [
          "credit card"
        ],
        "character_count": 35
      }
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "namespaces": [
        "admin"
      ],
      "excluded_namespaces": [
        "admin.name"
      ],
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1,
      "included_keyword_configuration": {
        "keywords": [
          "credit card"
        ],
        "character_count": 35
      }
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
Create Scanning Rule with should_save_match returns "OK" response
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "replacement_string",
        "replacement_string": "REDACTED",
        "should_save_match": true
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "replacement_string",
        "replacement_string": "REDACTED",
        "should_save_match": true
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "replacement_string",
        "replacement_string": "REDACTED",
        "should_save_match": true
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "replacement_string",
        "replacement_string": "REDACTED",
        "should_save_match": true
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "replacement_string",
        "replacement_string": "REDACTED",
        "should_save_match": true
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "replacement_string",
        "replacement_string": "REDACTED",
        "should_save_match": true
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "replacement_string",
        "replacement_string": "REDACTED",
        "should_save_match": true
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "replacement_string",
        "replacement_string": "REDACTED",
        "should_save_match": true
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "replacement_string",
        "replacement_string": "REDACTED",
        "should_save_match": true
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 1
    },
    "relationships": {
      "group": {
        "data": {
          "type": "sensitive_data_scanner_group",
          "id": "string"
        }
      }
    }
  }
}
EOF