---
title: Créer un groupe d'analyse
description: Créer un groupe dʼanalyse.
breadcrumbs: Documentation > API > Créer un groupe d'analyse
---

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

# Créer un groupe d'analyse

## v2 (latest)

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

### Overview

Créer un groupe dʼanalyse.
La demande PEUT inclure une relation de configuration.
Une relation de règles peut être omise complètement, mais si elle est incluse, elle DOIT être
null ou un tableau vide (les règles ne peuvent pas être créées en même temps).
Le nouveau groupe sera classé en dernier dans la configuration.

This endpoint requires the `data_scanner_write` permission.

### Request

#### Body Data (required)

{% tabs %}
{% tab label="Model" %}
| Parent field  | Field                   | Type     | Description                                                                                                                                              |
| ------------- | ----------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|               | data                    | object   | Créez une requête de groupe.                                                                                                                             |
| data          | attributes [*required*] | object   | Attributes of the Sensitive Data Scanner group.                                                                                                          |
| attributes    | description             | string   | Description of the group.                                                                                                                                |
| attributes    | filter                  | object   | Filter for the Scanning Group.                                                                                                                           |
| filter        | query                   | string   | Query to filter the events.                                                                                                                              |
| attributes    | is_enabled              | boolean  | Whether or not the group is enabled.                                                                                                                     |
| attributes    | name                    | string   | Name of the group.                                                                                                                                       |
| attributes    | product_list            | [string] | List of products the scanning group applies.                                                                                                             |
| attributes    | samplings               | [object] | List of sampling rates per product type.                                                                                                                 |
| samplings     | product                 | enum     | Datadog product onto which Sensitive Data Scanner can be activated. Allowed enum values: `logs`, `rum`, `events`, `apm`. Default: `logs`.                |
| samplings     | rate                    | double   | Rate at which data in product type will be scanned, as a percentage.                                                                                     |
| data          | relationships           | object   | Relationships of the group.                                                                                                                              |
| relationships | configuration           | object   | A Sensitive Data Scanner configuration data.                                                                                                             |
| configuration | data                    | object   | A Sensitive Data Scanner configuration.                                                                                                                  |
| data          | id                      | string   | ID of the configuration.                                                                                                                                 |
| data          | type                    | enum     | Sensitive Data Scanner configuration type. Allowed enum values: `sensitive_data_scanner_configuration`. Default: `sensitive_data_scanner_configuration`. |
| relationships | rules                   | object   | Rules included in the group.                                                                                                                             |
| rules         | data                    | [object] | Rules included in the group. The order is important.                                                                                                     |
| data          | id                      | string   | ID of the rule.                                                                                                                                          |
| data          | type                    | enum     | Sensitive Data Scanner rule type. Allowed enum values: `sensitive_data_scanner_rule`. Default: `sensitive_data_scanner_rule`.                            |
| data          | type [*required*]       | enum     | Sensitive Data Scanner group type. Allowed enum values: `sensitive_data_scanner_group`. Default: `sensitive_data_scanner_group`.                         |
|               | meta                    | object   | Meta payload containing information about the API.                                                                                                       |
| meta          | version                 | int64    | Version of the API (optional).                                                                                                                           |
{% /tab %}

{% tab label="Example" %}
```json
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_group",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "is_enabled": false,
      "product_list": [
        "logs"
      ],
      "filter": {
        "query": "*"
      }
    },
    "relationships": {
      "configuration": {
        "data": {
          "type": "sensitive_data_scanner_configuration",
          "id": "string"
        }
      },
      "rules": {
        "data": []
      }
    }
  }
}
```
{% /tab %}
{% /tabs %}

### Response

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

{% tabs %}
{% tab label="Model" %}
Create group response.

| Parent field  | Field         | Type     | Description                                                                                                                                              |
| ------------- | ------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|               | data          | object   | Response data related to the creation of a group.                                                                                                        |
| data          | attributes    | object   | Attributes of the Sensitive Data Scanner group.                                                                                                          |
| attributes    | description   | string   | Description of the group.                                                                                                                                |
| attributes    | filter        | object   | Filter for the Scanning Group.                                                                                                                           |
| filter        | query         | string   | Query to filter the events.                                                                                                                              |
| attributes    | is_enabled    | boolean  | Whether or not the group is enabled.                                                                                                                     |
| attributes    | name          | string   | Name of the group.                                                                                                                                       |
| attributes    | product_list  | [string] | List of products the scanning group applies.                                                                                                             |
| attributes    | samplings     | [object] | List of sampling rates per product type.                                                                                                                 |
| samplings     | product       | enum     | Datadog product onto which Sensitive Data Scanner can be activated. Allowed enum values: `logs`, `rum`, `events`, `apm`. Default: `logs`.                |
| samplings     | rate          | double   | Rate at which data in product type will be scanned, as a percentage.                                                                                     |
| data          | id            | string   | ID of the group.                                                                                                                                         |
| data          | relationships | object   | Relationships of the group.                                                                                                                              |
| relationships | configuration | object   | A Sensitive Data Scanner configuration data.                                                                                                             |
| configuration | data          | object   | A Sensitive Data Scanner configuration.                                                                                                                  |
| data          | id            | string   | ID of the configuration.                                                                                                                                 |
| data          | type          | enum     | Sensitive Data Scanner configuration type. Allowed enum values: `sensitive_data_scanner_configuration`. Default: `sensitive_data_scanner_configuration`. |
| relationships | rules         | object   | Rules included in the group.                                                                                                                             |
| rules         | data          | [object] | Rules included in the group. The order is important.                                                                                                     |
| data          | id            | string   | ID of the rule.                                                                                                                                          |
| data          | type          | enum     | Sensitive Data Scanner rule type. Allowed enum values: `sensitive_data_scanner_rule`. Default: `sensitive_data_scanner_rule`.                            |
| data          | type          | enum     | Sensitive Data Scanner group type. Allowed enum values: `sensitive_data_scanner_group`. Default: `sensitive_data_scanner_group`.                         |
|               | meta          | object   | Meta payload containing information about the API.                                                                                                       |
| meta          | version       | int64    | Version of the API (optional).                                                                                                                           |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "description": "string",
      "filter": {
        "query": "string"
      },
      "is_enabled": false,
      "name": "string",
      "product_list": [],
      "samplings": [
        {
          "product": "string",
          "rate": 100
        }
      ]
    },
    "id": "string",
    "relationships": {
      "configuration": {
        "data": {
          "id": "string",
          "type": "sensitive_data_scanner_configuration"
        }
      },
      "rules": {
        "data": [
          {
            "id": "string",
            "type": "sensitive_data_scanner_rule"
          }
        ]
      }
    },
    "type": "sensitive_data_scanner_group"
  },
  "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="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
# 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 POST "https://api.${DD_SITE}/api/v2/sensitive-data-scanner/config/groups" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "meta": {},
  "data": {
    "type": "sensitive_data_scanner_group",
    "attributes": {
      "name": "Example-Sensitive-Data-Scanner",
      "is_enabled": false,
      "product_list": [
        "logs"
      ],
      "filter": {
        "query": "*"
      }
    },
    "relationships": {
      "configuration": {
        "data": {
          "type": "sensitive_data_scanner_configuration",
          "id": "string"
        }
      },
      "rules": {
        "data": []
      }
    }
  }
}
EOF
```
{% /tab %}

{% tab label="Go" %}
```go
// Create Scanning Group 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() {
	// a valid "configuration" in the system
	ConfigurationDataID := os.Getenv("CONFIGURATION_DATA_ID")

	body := datadogV2.SensitiveDataScannerGroupCreateRequest{
		Meta: &datadogV2.SensitiveDataScannerMetaVersionOnly{},
		Data: &datadogV2.SensitiveDataScannerGroupCreate{
			Type: datadogV2.SENSITIVEDATASCANNERGROUPTYPE_SENSITIVE_DATA_SCANNER_GROUP,
			Attributes: datadogV2.SensitiveDataScannerGroupAttributes{
				Name:      datadog.PtrString("Example-Sensitive-Data-Scanner"),
				IsEnabled: datadog.PtrBool(false),
				ProductList: []datadogV2.SensitiveDataScannerProduct{
					datadogV2.SENSITIVEDATASCANNERPRODUCT_LOGS,
				},
				Filter: &datadogV2.SensitiveDataScannerFilter{
					Query: datadog.PtrString("*"),
				},
			},
			Relationships: &datadogV2.SensitiveDataScannerGroupRelationships{
				Configuration: &datadogV2.SensitiveDataScannerConfigurationData{
					Data: &datadogV2.SensitiveDataScannerConfiguration{
						Type: datadogV2.SENSITIVEDATASCANNERCONFIGURATIONTYPE_SENSITIVE_DATA_SCANNER_CONFIGURATIONS.Ptr(),
						Id:   datadog.PtrString(ConfigurationDataID),
					},
				},
				Rules: &datadogV2.SensitiveDataScannerRuleData{
					Data: []datadogV2.SensitiveDataScannerRule{},
				},
			},
		},
	}
	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.CreateScanningGroup(ctx, body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `SensitiveDataScannerApi.CreateScanningGroup`:\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
// Create Scanning Group 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.SensitiveDataScannerConfiguration;
import com.datadog.api.client.v2.model.SensitiveDataScannerConfigurationData;
import com.datadog.api.client.v2.model.SensitiveDataScannerConfigurationType;
import com.datadog.api.client.v2.model.SensitiveDataScannerCreateGroupResponse;
import com.datadog.api.client.v2.model.SensitiveDataScannerFilter;
import com.datadog.api.client.v2.model.SensitiveDataScannerGroupAttributes;
import com.datadog.api.client.v2.model.SensitiveDataScannerGroupCreate;
import com.datadog.api.client.v2.model.SensitiveDataScannerGroupCreateRequest;
import com.datadog.api.client.v2.model.SensitiveDataScannerGroupRelationships;
import com.datadog.api.client.v2.model.SensitiveDataScannerGroupType;
import com.datadog.api.client.v2.model.SensitiveDataScannerMetaVersionOnly;
import com.datadog.api.client.v2.model.SensitiveDataScannerProduct;
import com.datadog.api.client.v2.model.SensitiveDataScannerRuleData;
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);

    // a valid "configuration" in the system
    String CONFIGURATION_DATA_ID = System.getenv("CONFIGURATION_DATA_ID");

    SensitiveDataScannerGroupCreateRequest body =
        new SensitiveDataScannerGroupCreateRequest()
            .meta(new SensitiveDataScannerMetaVersionOnly())
            .data(
                new SensitiveDataScannerGroupCreate()
                    .type(SensitiveDataScannerGroupType.SENSITIVE_DATA_SCANNER_GROUP)
                    .attributes(
                        new SensitiveDataScannerGroupAttributes()
                            .name("Example-Sensitive-Data-Scanner")
                            .isEnabled(false)
                            .productList(
                                Collections.singletonList(SensitiveDataScannerProduct.LOGS))
                            .filter(new SensitiveDataScannerFilter().query("*")))
                    .relationships(
                        new SensitiveDataScannerGroupRelationships()
                            .configuration(
                                new SensitiveDataScannerConfigurationData()
                                    .data(
                                        new SensitiveDataScannerConfiguration()
                                            .type(
                                                SensitiveDataScannerConfigurationType
                                                    .SENSITIVE_DATA_SCANNER_CONFIGURATIONS)
                                            .id(CONFIGURATION_DATA_ID)))
                            .rules(new SensitiveDataScannerRuleData())));

    try {
      SensitiveDataScannerCreateGroupResponse result = apiInstance.createScanningGroup(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling SensitiveDataScannerApi#createScanningGroup");
      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
"""
Create Scanning Group 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_configuration import SensitiveDataScannerConfiguration
from datadog_api_client.v2.model.sensitive_data_scanner_configuration_data import SensitiveDataScannerConfigurationData
from datadog_api_client.v2.model.sensitive_data_scanner_configuration_type import SensitiveDataScannerConfigurationType
from datadog_api_client.v2.model.sensitive_data_scanner_filter import SensitiveDataScannerFilter
from datadog_api_client.v2.model.sensitive_data_scanner_group_attributes import SensitiveDataScannerGroupAttributes
from datadog_api_client.v2.model.sensitive_data_scanner_group_create import SensitiveDataScannerGroupCreate
from datadog_api_client.v2.model.sensitive_data_scanner_group_create_request import (
    SensitiveDataScannerGroupCreateRequest,
)
from datadog_api_client.v2.model.sensitive_data_scanner_group_relationships import (
    SensitiveDataScannerGroupRelationships,
)
from datadog_api_client.v2.model.sensitive_data_scanner_group_type import SensitiveDataScannerGroupType
from datadog_api_client.v2.model.sensitive_data_scanner_meta_version_only import SensitiveDataScannerMetaVersionOnly
from datadog_api_client.v2.model.sensitive_data_scanner_product import SensitiveDataScannerProduct
from datadog_api_client.v2.model.sensitive_data_scanner_rule_data import SensitiveDataScannerRuleData

# a valid "configuration" in the system
CONFIGURATION_DATA_ID = environ["CONFIGURATION_DATA_ID"]

body = SensitiveDataScannerGroupCreateRequest(
    meta=SensitiveDataScannerMetaVersionOnly(),
    data=SensitiveDataScannerGroupCreate(
        type=SensitiveDataScannerGroupType.SENSITIVE_DATA_SCANNER_GROUP,
        attributes=SensitiveDataScannerGroupAttributes(
            name="Example-Sensitive-Data-Scanner",
            is_enabled=False,
            product_list=[
                SensitiveDataScannerProduct.LOGS,
            ],
            filter=SensitiveDataScannerFilter(
                query="*",
            ),
        ),
        relationships=SensitiveDataScannerGroupRelationships(
            configuration=SensitiveDataScannerConfigurationData(
                data=SensitiveDataScannerConfiguration(
                    type=SensitiveDataScannerConfigurationType.SENSITIVE_DATA_SCANNER_CONFIGURATIONS,
                    id=CONFIGURATION_DATA_ID,
                ),
            ),
            rules=SensitiveDataScannerRuleData(
                data=[],
            ),
        ),
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
    api_instance = SensitiveDataScannerApi(api_client)
    response = api_instance.create_scanning_group(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
# Create Scanning Group 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

# a valid "configuration" in the system
CONFIGURATION_DATA_ID = ENV["CONFIGURATION_DATA_ID"]

body = DatadogAPIClient::V2::SensitiveDataScannerGroupCreateRequest.new({
  meta: DatadogAPIClient::V2::SensitiveDataScannerMetaVersionOnly.new({}),
  data: DatadogAPIClient::V2::SensitiveDataScannerGroupCreate.new({
    type: DatadogAPIClient::V2::SensitiveDataScannerGroupType::SENSITIVE_DATA_SCANNER_GROUP,
    attributes: DatadogAPIClient::V2::SensitiveDataScannerGroupAttributes.new({
      name: "Example-Sensitive-Data-Scanner",
      is_enabled: false,
      product_list: [
        DatadogAPIClient::V2::SensitiveDataScannerProduct::LOGS,
      ],
      filter: DatadogAPIClient::V2::SensitiveDataScannerFilter.new({
        query: "*",
      }),
    }),
    relationships: DatadogAPIClient::V2::SensitiveDataScannerGroupRelationships.new({
      configuration: DatadogAPIClient::V2::SensitiveDataScannerConfigurationData.new({
        data: DatadogAPIClient::V2::SensitiveDataScannerConfiguration.new({
          type: DatadogAPIClient::V2::SensitiveDataScannerConfigurationType::SENSITIVE_DATA_SCANNER_CONFIGURATIONS,
          id: CONFIGURATION_DATA_ID,
        }),
      }),
      rules: DatadogAPIClient::V2::SensitiveDataScannerRuleData.new({
        data: [],
      }),
    }),
  }),
})
p api_instance.create_scanning_group(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
// Create Scanning Group returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_sensitive_data_scanner::SensitiveDataScannerAPI;
use datadog_api_client::datadogV2::model::SensitiveDataScannerConfiguration;
use datadog_api_client::datadogV2::model::SensitiveDataScannerConfigurationData;
use datadog_api_client::datadogV2::model::SensitiveDataScannerConfigurationType;
use datadog_api_client::datadogV2::model::SensitiveDataScannerFilter;
use datadog_api_client::datadogV2::model::SensitiveDataScannerGroupAttributes;
use datadog_api_client::datadogV2::model::SensitiveDataScannerGroupCreate;
use datadog_api_client::datadogV2::model::SensitiveDataScannerGroupCreateRequest;
use datadog_api_client::datadogV2::model::SensitiveDataScannerGroupRelationships;
use datadog_api_client::datadogV2::model::SensitiveDataScannerGroupType;
use datadog_api_client::datadogV2::model::SensitiveDataScannerMetaVersionOnly;
use datadog_api_client::datadogV2::model::SensitiveDataScannerProduct;
use datadog_api_client::datadogV2::model::SensitiveDataScannerRuleData;

#[tokio::main]
async fn main() {
    // a valid "configuration" in the system
    let configuration_data_id = std::env::var("CONFIGURATION_DATA_ID").unwrap();
    let body =
        SensitiveDataScannerGroupCreateRequest::new()
            .data(
                SensitiveDataScannerGroupCreate::new(
                    SensitiveDataScannerGroupAttributes::new()
                        .filter(SensitiveDataScannerFilter::new().query("*".to_string()))
                        .is_enabled(false)
                        .name("Example-Sensitive-Data-Scanner".to_string())
                        .product_list(vec![SensitiveDataScannerProduct::LOGS]),
                    SensitiveDataScannerGroupType::SENSITIVE_DATA_SCANNER_GROUP,
                ).relationships(
                    SensitiveDataScannerGroupRelationships::new()
                        .configuration(
                            SensitiveDataScannerConfigurationData
                            ::new().data(
                                SensitiveDataScannerConfiguration::new()
                                    .id(configuration_data_id.clone())
                                    .type_(
                                        SensitiveDataScannerConfigurationType::SENSITIVE_DATA_SCANNER_CONFIGURATIONS,
                                    ),
                            ),
                        )
                        .rules(SensitiveDataScannerRuleData::new().data(vec![])),
                ),
            )
            .meta(SensitiveDataScannerMetaVersionOnly::new());
    let configuration = datadog::Configuration::new();
    let api = SensitiveDataScannerAPI::with_config(configuration);
    let resp = api.create_scanning_group(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
/**
 * Create Scanning Group 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);

// a valid "configuration" in the system
const CONFIGURATION_DATA_ID = process.env.CONFIGURATION_DATA_ID as string;

const params: v2.SensitiveDataScannerApiCreateScanningGroupRequest = {
  body: {
    meta: {},
    data: {
      type: "sensitive_data_scanner_group",
      attributes: {
        name: "Example-Sensitive-Data-Scanner",
        isEnabled: false,
        productList: ["logs"],
        filter: {
          query: "*",
        },
      },
      relationships: {
        configuration: {
          data: {
            type: "sensitive_data_scanner_configuration",
            id: CONFIGURATION_DATA_ID,
          },
        },
        rules: {
          data: [],
        },
      },
    },
  },
};

apiInstance
  .createScanningGroup(params)
  .then((data: v2.SensitiveDataScannerCreateGroupResponse) => {
    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 %}
