---
title: Actualizar regla de análisis
description: Actualiza una regla de análisis.
breadcrumbs: Documentación > API > Actualizar regla de análisis
---

> For the complete documentation index, see [llms.txt](https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/llms.txt).

# Actualizar regla de análisis

## v2 (latest)

| Datadog site      | API endpoint                                                                             |
| ----------------- | ---------------------------------------------------------------------------------------- |
| app.datadoghq.com | PATCH https://api.datadoghq.com/api/v2/sensitive-data-scanner/config/rules/{rule_id}     |
| us3.datadoghq.com | PATCH https://api.us3.datadoghq.com/api/v2/sensitive-data-scanner/config/rules/{rule_id} |
| us5.datadoghq.com | PATCH https://api.us5.datadoghq.com/api/v2/sensitive-data-scanner/config/rules/{rule_id} |
| app.datadoghq.eu  | PATCH https://api.datadoghq.eu/api/v2/sensitive-data-scanner/config/rules/{rule_id}      |
| ap1.datadoghq.com | PATCH https://api.ap1.datadoghq.com/api/v2/sensitive-data-scanner/config/rules/{rule_id} |
| ap2.datadoghq.com | PATCH https://api.ap2.datadoghq.com/api/v2/sensitive-data-scanner/config/rules/{rule_id} |
| uk1.datadoghq.com | PATCH https://api.uk1.datadoghq.com/api/v2/sensitive-data-scanner/config/rules/{rule_id} |
| app.ddog-gov.com  | PATCH https://api.ddog-gov.com/api/v2/sensitive-data-scanner/config/rules/{rule_id}      |
| us2.ddog-gov.com  | PATCH https://api.us2.ddog-gov.com/api/v2/sensitive-data-scanner/config/rules/{rule_id}  |

### Overview

Actualiza una regla de análisis.
El cuerpo de la solicitud NO DEBE incluir una relación standard_pattern, ya que dicha relación
no se puede editar. Si se intenta editar el atributo de expresión regular de una regla con una relación standard_pattern
también provocará un error.

This endpoint requires the `data_scanner_write` permission.

### Arguments

#### Path Parameters

| Field                | Type   | Description         |
| -------------------- | ------ | ------------------- |
| rule_id [*required*] | string | The ID of the rule. |

### Request

#### Body Data (required)

{% tabs %}
{% tab label="Model" %}
| Parent field                   | Field                          | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------------ | ------------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                                | data [*required*]              | object   | Actualiza una solicitud de regla.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| data                           | attributes                     | object   | Attributes of the Sensitive Data Scanner rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| attributes                     | description                    | string   | Description of the rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| attributes                     | excluded_namespaces            | [string] | Attributes excluded from the scan. If namespaces is provided, it has to be a sub-path of the namespaces array.                                                                                                                                                                                                                                                                                                                                                                                                      |
| attributes                     | included_keyword_configuration | object   | Object defining a set of keywords and a number of characters that help reduce noise. You can provide a list of keywords you would like to check within a defined proximity of the matching pattern. If any of the keywords are found within the proximity check, the match is kept. If none are found, the match is discarded.                                                                                                                                                                                      |
| included_keyword_configuration | character_count [*required*]   | int64    | The number of characters behind a match detected by Sensitive Data Scanner to look for the keywords defined. `character_count` should be greater than the maximum length of a keyword defined for a rule.                                                                                                                                                                                                                                                                                                           |
| included_keyword_configuration | keywords [*required*]          | [string] | Keyword list that will be checked during scanning in order to validate a match. The number of keywords in the list must be less than or equal to 30.                                                                                                                                                                                                                                                                                                                                                                |
| included_keyword_configuration | use_recommended_keywords       | boolean  | Should the rule use the underlying standard pattern keyword configuration. If set to `true`, the rule must be tied to a standard pattern. If set to `false`, the specified keywords and `character_count` are applied.                                                                                                                                                                                                                                                                                              |
| attributes                     | is_enabled                     | boolean  | Whether or not the rule is enabled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| attributes                     | name                           | string   | Name of the rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| attributes                     | namespaces                     | [string] | Attributes included in the scan. If namespaces is empty or missing, all attributes except excluded_namespaces are scanned. If both are missing the whole event is scanned.                                                                                                                                                                                                                                                                                                                                          |
| attributes                     | pattern                        | string   | Not included if there is a relationship to a standard pattern.                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| attributes                     | priority                       | int64    | Integer from 1 (high) to 5 (low) indicating rule issue severity.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| attributes                     | suppressions                   | object   | Object describing suppressions for a rule, or the recommended suppression lists published by a standard pattern. There are three types of suppressions, `starts_with`, `ends_with`, and `exact_match`. Rules based on the Datadog library can use recommended or custom suppressions. Custom rules can only use custom suppressions. Suppressed matches are not obfuscated, counted in metrics, or displayed in the Findings page.                                                                                  |
| suppressions                   | ends_with                      | [string] | List of strings to use for suppression of matches ending with these strings.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| suppressions                   | exact_match                    | [string] | List of strings to use for suppression of matches exactly matching these strings.                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| suppressions                   | starts_with                    | [string] | List of strings to use for suppression of matches starting with these strings.                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| suppressions                   | use_recommended_suppressions   | boolean  | Should the rule use the underlying standard pattern suppression configuration. If set to `true`, the rule must be tied to a standard pattern. If set to `false`, the specified suppressions are applied.                                                                                                                                                                                                                                                                                                            |
| attributes                     | tags                           | [string] | List of tags.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| attributes                     | text_replacement               | object   | Object describing how the scanned event will be replaced.                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| text_replacement               | number_of_chars                | int64    | Required if type == 'partial_replacement_from_beginning' or 'partial_replacement_from_end'. It must be > 0.                                                                                                                                                                                                                                                                                                                                                                                                         |
| text_replacement               | replacement_string             | string   | Required if type == 'replacement_string'.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| text_replacement               | should_save_match              | boolean  | Only valid when type == `replacement_string`. When enabled, matches can be unmasked in logs by users with ‘Data Scanner Unmask’ permission. As a security best practice, avoid masking for highly-sensitive, long-lived data.                                                                                                                                                                                                                                                                                       |
| text_replacement               | type                           | enum     | Type of the replacement text. None means no replacement. hash means the data will be stubbed. replacement_string means that one can chose a text to replace the data. partial_replacement_from_beginning allows a user to partially replace the data from the beginning, and partial_replacement_from_end on the other hand, allows to replace data from the end. Allowed enum values: `none`, `hash`, `replacement_string`, `partial_replacement_from_beginning`, `partial_replacement_from_end`. Default: `none`. |
| data                           | id                             | string   | ID of the rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| data                           | relationships                  | object   | Relationships of a scanning rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| relationships                  | group                          | object   | A scanning group data.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| group                          | data                           | object   | A scanning group.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| data                           | id                             | string   | ID of the group.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| data                           | type                           | enum     | Sensitive Data Scanner group type. Allowed enum values: `sensitive_data_scanner_group`. Default: `sensitive_data_scanner_group`.                                                                                                                                                                                                                                                                                                                                                                                    |
| relationships                  | standard_pattern               | object   | A standard pattern.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| standard_pattern               | data                           | object   | Data containing the standard pattern id.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| data                           | id                             | string   | ID of the standard pattern.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| data                           | type                           | enum     | Sensitive Data Scanner standard pattern type. Allowed enum values: `sensitive_data_scanner_standard_pattern`. Default: `sensitive_data_scanner_standard_pattern`.                                                                                                                                                                                                                                                                                                                                                   |
| data                           | type                           | enum     | Sensitive Data Scanner rule type. Allowed enum values: `sensitive_data_scanner_rule`. Default: `sensitive_data_scanner_rule`.                                                                                                                                                                                                                                                                                                                                                                                       |
|                                | meta [*required*]              | object   | Meta payload containing information about the API.                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| meta                           | version                        | int64    | Version of the API (optional).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
{% /tab %}

{% tab label="Example" %}
```json
{
  "meta": {},
  "data": {
    "id": "string",
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 5,
      "included_keyword_configuration": {
        "keywords": [
          "credit card",
          "cc"
        ],
        "character_count": 35
      }
    }
  }
}
```
{% /tab %}
{% /tabs %}

### Response

{% tabs %}
{% tab label="200" %}
OK

{% tabs %}
{% tab label="Model" %}
Update rule response.

| Parent field | Field   | Type   | Description                                        |
| ------------ | ------- | ------ | -------------------------------------------------- |
|              | meta    | object | Meta payload containing information about the API. |
| meta         | version | int64  | Version of the API (optional).                     |
{% /tab %}

{% tab label="Example" %}
```json
{
  "meta": {
    "version": 0
  }
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="400" %}
Bad Request

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="403" %}
Authentication Error

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="404" %}
Not Found

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="429" %}
Too many requests

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}
{% /tabs %}

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
# Path parameters
export rule_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, 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 PATCH "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/rules/${rule_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "id": "string",
    "type": "sensitive_data_scanner_rule",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "pattern": "pattern",
      "text_replacement": {
        "type": "none"
      },
      "tags": [
        "sensitive_data:true"
      ],
      "is_enabled": true,
      "priority": 5,
      "included_keyword_configuration": {
        "keywords": [
          "credit card",
          "cc"
        ],
        "character_count": 35
      }
    }
  }
}
EOF
```
{% /tab %}

{% tab label="Go" %}
```go
// Update Scanning Rule returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	// the "scanning_group" has a "scanning_rule"
	RuleDataID := os.Getenv("RULE_DATA_ID")

	body := datadogV2.SensitiveDataScannerRuleUpdateRequest{
		Meta: datadogV2.SensitiveDataScannerMetaVersionOnly{},
		Data: datadogV2.SensitiveDataScannerRuleUpdate{
			Id:   datadog.PtrString(RuleDataID),
			Type: datadogV2.SENSITIVEDATASCANNERRULETYPE_SENSITIVE_DATA_SCANNER_RULE.Ptr(),
			Attributes: &datadogV2.SensitiveDataScannerRuleAttributes{
				Name:    datadog.PtrString("Example-Sensitive-Data-Scanner"),
				Pattern: datadog.PtrString("pattern"),
				TextReplacement: &datadogV2.SensitiveDataScannerTextReplacement{
					Type: datadogV2.SENSITIVEDATASCANNERTEXTREPLACEMENTTYPE_NONE.Ptr(),
				},
				Tags: []string{
					"sensitive_data:true",
				},
				IsEnabled: datadog.PtrBool(true),
				Priority:  datadog.PtrInt64(5),
				IncludedKeywordConfiguration: &datadogV2.SensitiveDataScannerIncludedKeywordConfiguration{
					Keywords: []string{
						"credit card",
						"cc",
					},
					CharacterCount: 35,
				},
			},
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewSensitiveDataScannerApi(apiClient)
	resp, r, err := api.UpdateScanningRule(ctx, RuleDataID, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `SensitiveDataScannerApi.UpdateScanningRule`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `SensitiveDataScannerApi.UpdateScanningRule`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
```
{% /tab %}

{% tab label="Java" %}
```java
// Update Scanning Rule returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.SensitiveDataScannerApi;
import com.datadog.api.client.v2.model.SensitiveDataScannerIncludedKeywordConfiguration;
import com.datadog.api.client.v2.model.SensitiveDataScannerMetaVersionOnly;
import com.datadog.api.client.v2.model.SensitiveDataScannerRuleAttributes;
import com.datadog.api.client.v2.model.SensitiveDataScannerRuleType;
import com.datadog.api.client.v2.model.SensitiveDataScannerRuleUpdate;
import com.datadog.api.client.v2.model.SensitiveDataScannerRuleUpdateRequest;
import com.datadog.api.client.v2.model.SensitiveDataScannerRuleUpdateResponse;
import com.datadog.api.client.v2.model.SensitiveDataScannerTextReplacement;
import com.datadog.api.client.v2.model.SensitiveDataScannerTextReplacementType;
import java.util.Arrays;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    SensitiveDataScannerApi apiInstance = new SensitiveDataScannerApi(defaultClient);

    // the "scanning_group" has a "scanning_rule"
    String RULE_DATA_ID = System.getenv("RULE_DATA_ID");

    SensitiveDataScannerRuleUpdateRequest body =
        new SensitiveDataScannerRuleUpdateRequest()
            .meta(new SensitiveDataScannerMetaVersionOnly())
            .data(
                new SensitiveDataScannerRuleUpdate()
                    .id(RULE_DATA_ID)
                    .type(SensitiveDataScannerRuleType.SENSITIVE_DATA_SCANNER_RULE)
                    .attributes(
                        new SensitiveDataScannerRuleAttributes()
                            .name("Example-Sensitive-Data-Scanner")
                            .pattern("pattern")
                            .textReplacement(
                                new SensitiveDataScannerTextReplacement()
                                    .type(SensitiveDataScannerTextReplacementType.NONE))
                            .tags(Collections.singletonList("sensitive_data:true"))
                            .isEnabled(true)
                            .priority(5L)
                            .includedKeywordConfiguration(
                                new SensitiveDataScannerIncludedKeywordConfiguration()
                                    .keywords(Arrays.asList("credit card", "cc"))
                                    .characterCount(35L))));

    try {
      SensitiveDataScannerRuleUpdateResponse result =
          apiInstance.updateScanningRule(RULE_DATA_ID, body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling SensitiveDataScannerApi#updateScanningRule");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
```
{% /tab %}

{% tab label="Python" %}
```python
"""
Update Scanning Rule returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.sensitive_data_scanner_api import SensitiveDataScannerApi
from datadog_api_client.v2.model.sensitive_data_scanner_included_keyword_configuration import (
    SensitiveDataScannerIncludedKeywordConfiguration,
)
from datadog_api_client.v2.model.sensitive_data_scanner_meta_version_only import SensitiveDataScannerMetaVersionOnly
from datadog_api_client.v2.model.sensitive_data_scanner_rule_attributes import SensitiveDataScannerRuleAttributes
from datadog_api_client.v2.model.sensitive_data_scanner_rule_type import SensitiveDataScannerRuleType
from datadog_api_client.v2.model.sensitive_data_scanner_rule_update import SensitiveDataScannerRuleUpdate
from datadog_api_client.v2.model.sensitive_data_scanner_rule_update_request import SensitiveDataScannerRuleUpdateRequest
from datadog_api_client.v2.model.sensitive_data_scanner_text_replacement import SensitiveDataScannerTextReplacement
from datadog_api_client.v2.model.sensitive_data_scanner_text_replacement_type import (
    SensitiveDataScannerTextReplacementType,
)

# the "scanning_group" has a "scanning_rule"
RULE_DATA_ID = environ["RULE_DATA_ID"]

body = SensitiveDataScannerRuleUpdateRequest(
    meta=SensitiveDataScannerMetaVersionOnly(),
    data=SensitiveDataScannerRuleUpdate(
        id=RULE_DATA_ID,
        type=SensitiveDataScannerRuleType.SENSITIVE_DATA_SCANNER_RULE,
        attributes=SensitiveDataScannerRuleAttributes(
            name="Example-Sensitive-Data-Scanner",
            pattern="pattern",
            text_replacement=SensitiveDataScannerTextReplacement(
                type=SensitiveDataScannerTextReplacementType.NONE,
            ),
            tags=[
                "sensitive_data:true",
            ],
            is_enabled=True,
            priority=5,
            included_keyword_configuration=SensitiveDataScannerIncludedKeywordConfiguration(
                keywords=[
                    "credit card",
                    "cc",
                ],
                character_count=35,
            ),
        ),
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
    api_instance = SensitiveDataScannerApi(api_client)
    response = api_instance.update_scanning_rule(rule_id=RULE_DATA_ID, body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
```
{% /tab %}

{% tab label="Ruby" %}
```ruby
# Update Scanning Rule returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::SensitiveDataScannerAPI.new

# the "scanning_group" has a "scanning_rule"
RULE_DATA_ID = ENV["RULE_DATA_ID"]

body = DatadogAPIClient::V2::SensitiveDataScannerRuleUpdateRequest.new({
  meta: DatadogAPIClient::V2::SensitiveDataScannerMetaVersionOnly.new({}),
  data: DatadogAPIClient::V2::SensitiveDataScannerRuleUpdate.new({
    id: RULE_DATA_ID,
    type: DatadogAPIClient::V2::SensitiveDataScannerRuleType::SENSITIVE_DATA_SCANNER_RULE,
    attributes: DatadogAPIClient::V2::SensitiveDataScannerRuleAttributes.new({
      name: "Example-Sensitive-Data-Scanner",
      pattern: "pattern",
      text_replacement: DatadogAPIClient::V2::SensitiveDataScannerTextReplacement.new({
        type: DatadogAPIClient::V2::SensitiveDataScannerTextReplacementType::NONE,
      }),
      tags: [
        "sensitive_data:true",
      ],
      is_enabled: true,
      priority: 5,
      included_keyword_configuration: DatadogAPIClient::V2::SensitiveDataScannerIncludedKeywordConfiguration.new({
        keywords: [
          "credit card",
          "cc",
        ],
        character_count: 35,
      }),
    }),
  }),
})
p api_instance.update_scanning_rule(RULE_DATA_ID, body)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
```
{% /tab %}

{% tab label="Rust" %}
```rust
// Update Scanning Rule returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_sensitive_data_scanner::SensitiveDataScannerAPI;
use datadog_api_client::datadogV2::model::SensitiveDataScannerIncludedKeywordConfiguration;
use datadog_api_client::datadogV2::model::SensitiveDataScannerMetaVersionOnly;
use datadog_api_client::datadogV2::model::SensitiveDataScannerRuleAttributes;
use datadog_api_client::datadogV2::model::SensitiveDataScannerRuleType;
use datadog_api_client::datadogV2::model::SensitiveDataScannerRuleUpdate;
use datadog_api_client::datadogV2::model::SensitiveDataScannerRuleUpdateRequest;
use datadog_api_client::datadogV2::model::SensitiveDataScannerTextReplacement;
use datadog_api_client::datadogV2::model::SensitiveDataScannerTextReplacementType;

#[tokio::main]
async fn main() {
    // the "scanning_group" has a "scanning_rule"
    let rule_data_id = std::env::var("RULE_DATA_ID").unwrap();
    let body = SensitiveDataScannerRuleUpdateRequest::new(
        SensitiveDataScannerRuleUpdate::new()
            .attributes(
                SensitiveDataScannerRuleAttributes::new()
                    .included_keyword_configuration(
                        SensitiveDataScannerIncludedKeywordConfiguration::new(
                            35,
                            vec!["credit card".to_string(), "cc".to_string()],
                        ),
                    )
                    .is_enabled(true)
                    .name("Example-Sensitive-Data-Scanner".to_string())
                    .pattern("pattern".to_string())
                    .priority(5)
                    .tags(vec!["sensitive_data:true".to_string()])
                    .text_replacement(
                        SensitiveDataScannerTextReplacement::new()
                            .type_(SensitiveDataScannerTextReplacementType::NONE),
                    ),
            )
            .id(rule_data_id.clone())
            .type_(SensitiveDataScannerRuleType::SENSITIVE_DATA_SCANNER_RULE),
        SensitiveDataScannerMetaVersionOnly::new(),
    );
    let configuration = datadog::Configuration::new();
    let api = SensitiveDataScannerAPI::with_config(configuration);
    let resp = api.update_scanning_rule(rule_data_id.clone(), body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
```
{% /tab %}

{% tab label="TypeScript" %}
```typescript
/**
 * Update Scanning Rule returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration({
  authMethods: {
    AuthZ: {
      accessToken: process.env.DD_BEARER_TOKEN as string,
    },
  },
});
const apiInstance = new v2.SensitiveDataScannerApi(configuration);

// the "scanning_group" has a "scanning_rule"
const RULE_DATA_ID = process.env.RULE_DATA_ID as string;

const params: v2.SensitiveDataScannerApiUpdateScanningRuleRequest = {
  body: {
    meta: {},
    data: {
      id: RULE_DATA_ID,
      type: "sensitive_data_scanner_rule",
      attributes: {
        name: "Example-Sensitive-Data-Scanner",
        pattern: "pattern",
        textReplacement: {
          type: "none",
        },
        tags: ["sensitive_data:true"],
        isEnabled: true,
        priority: 5,
        includedKeywordConfiguration: {
          keywords: ["credit card", "cc"],
          characterCount: 35,
        },
      },
    },
  },
  ruleId: RULE_DATA_ID,
};

apiInstance
  .updateScanningRule(params)
  .then((data: v2.SensitiveDataScannerRuleUpdateResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"
```
{% /tab %}
{% /tabs %}
