---
title: Bulk convert rules to Terraform
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Security Monitoring
---

# Bulk convert rules to Terraform{% #bulk-convert-rules-to-terraform %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                                                     |
| ----------------- | -------------------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/security_monitoring/rules/convert/bulk |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/security_monitoring/rules/convert/bulk |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/security_monitoring/rules/convert/bulk      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/security_monitoring/rules/convert/bulk      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/security_monitoring/rules/convert/bulk  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/security_monitoring/rules/convert/bulk     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/security_monitoring/rules/convert/bulk |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/security_monitoring/rules/convert/bulk |

### Overview



Convert a list of existing security monitoring rules to Terraform for the Datadog provider resource `datadog_security_monitoring_rule`. Returns a ZIP archive containing one Terraform file per rule. You can convert rules for the following types:

- App and API Protection
- Cloud SIEM (log detection and signal correlation)
- Workload Protection
This endpoint requires the `security_monitoring_rules_read` permission.
OAuth apps require the `security_monitoring_rules_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#security-monitoring) to access this endpoint.



### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                        | Type     | Description                                                                                                     |
| ------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]       | object   | Data for bulk converting security monitoring rules to Terraform.                                                |
| data         | attributes [*required*] | object   | Attributes for bulk converting security monitoring rules to Terraform.                                          |
| attributes   | ruleIds [*required*]    | [string] | List of rule IDs to convert. Each rule will be included in the resulting ZIP file as a separate Terraform file. |
| data         | id                           | string   | Request ID.                                                                                                     |
| data         | type [*required*]       | enum     | The type of the resource. Allowed enum values: `security_monitoring_rules_convert_bulk`                         |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "ruleIds": [
        "def-000-u7q",
        "def-000-7dd"
      ]
    },
    "id": "convert_bulk",
    "type": "security_monitoring_rules_convert_bulk"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}

| Field | Type | Description |
| ----- | ---- | ----------- |

{% /tab %}

{% tab title="Example" %}

```json
{}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Not Authorized
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/security_monitoring/rules/convert/bulk" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "ruleIds": [
        "def-000-u7q",
        "def-000-7dd"
      ]
    },
    "id": "convert_bulk",
    "type": "security_monitoring_rules_convert_bulk"
  }
}
EOF 
                
{% /tab %}
