---
title: List IaC custom rules
description: List the custom IaC (Infrastructure as Code) rules of your organization, with the current revision of each rule.
breadcrumbs: Docs > API > List IaC custom rules
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# List IaC custom rules

## v2 (latest)

{% alert level="warning" %}
**Note**: This endpoint is in Preview and is subject to change.
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help.md).
{% /alert %}

| Datadog site      | API endpoint                                                                     |
| ----------------- | -------------------------------------------------------------------------------- |
| app.datadoghq.com | GET https://api.datadoghq.com/api/v2/security/code_security/iac_custom_rules     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/security/code_security/iac_custom_rules |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/security/code_security/iac_custom_rules |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/security/code_security/iac_custom_rules      |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/security/code_security/iac_custom_rules |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/security/code_security/iac_custom_rules |
| uk1.datadoghq.com | GET https://api.uk1.datadoghq.com/api/v2/security/code_security/iac_custom_rules |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/security/code_security/iac_custom_rules      |
| us2.ddog-gov.com  | GET https://api.us2.ddog-gov.com/api/v2/security/code_security/iac_custom_rules  |

### Overview

List the custom IaC (Infrastructure as Code) rules of your organization, with the current revision of each rule.
The list doesn't include the Datadog default rules.
Use this operation to search rules, and `GET /api/v2/security/code_security/iac_custom_rules/{rule_id}` to get a rule by ID.
Results are sorted by rule ID and paginated with `page[size]` and `page[number]`.
`meta.page.total_filtered_count` is the number of rules that match the filters, across all pages.

This endpoint requires the `appsec_vm_read` permission.

OAuth apps require the `appsec_vm_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#code-security) to access this endpoint.

### Arguments

#### Query Strings

| Field                | Type    | Description                                                                                                                                                  |
| -------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| page[size]           | integer | The number of rules per page, between 1 and 1000. Default: `100`.                                                                                            |
| page[number]         | integer | The page to return, starting at `0`. Default: `0`.                                                                                                           |
| filter[platform]     | enum    | Return only the rules of this platform. Allowed enum values: `ansible`, `cicd`, `cloudformation`, `docker_compose`, `dockerfile`, `kubernetes`, `terraform`. |
| filter[provider]     | string  | Return only the rules of this provider, for example `aws`. The match ignores case.                                                                           |
| filter[is_published] | boolean | Set to `true` to return only published rules, or `false` to return only drafts.                                                                              |
| filter[query]        | string  | Return only the rules whose ID, name, description, or provider contains this text. The match ignores case.                                                   |

### Response

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

{% tabs %}
{% tab label="Model" %}
A page of IaC custom rules.

| Parent field | Field                             | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------ | --------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]                 | [object] | A list of IaC custom rules.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| data         | attributes [*required*]           | object   | The attributes of an IaC custom rule, from its current revision.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| attributes   | category [*required*]             | enum     | The category of the misconfiguration that the rule detects. - `access_control`: Access to resources. - `availability`: Resilience and uptime of resources. - `backup`: Backups, snapshots, and versioning. - `best_practices`: General configuration practices. - `bill_of_materials`: Inventory of the components that the configuration declares. - `build_process`: Build and image instructions. - `encryption`: Encryption of data at rest and in transit. - `insecure_configurations`: Settings that weaken security. - `insecure_defaults`: Default values that weaken security. - `least_privilege`: Permissions broader than the resource needs. - `networking_and_firewall`: Network exposure and firewall rules. - `observability`: Logging, monitoring, and auditing. - `resource_management`: Resource limits and quotas. - `secret_management`: Secrets and credentials in the configuration. - `structure_and_semantics`: Syntax and structure of the configuration. - `supply_chain`: Origin and integrity of dependencies and images. Allowed enum values: `access_control`, `availability`, `backup`, `best_practices`, `bill_of_materials`, `build_process`, `encryption`, `insecure_configurations`, `insecure_defaults`, `least_privilege`, `networking_and_firewall`, `observability`, `resource_management`, `secret_management`, `structure_and_semantics`, `supply_chain`.                                                                                                                                                                                                                       |
| attributes   | created_at [*required*]           | int64    | The creation time of the rule, in milliseconds since the Unix epoch, in UTC.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| attributes   | created_by_id [*required*]        | string   | The UUID (universally unique identifier) of the user who created the rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| attributes   | cwe_id [*required*]               | string   | The CWE (Common Weakness Enumeration) ID of the weakness that the rule detects, in the `CWE-<number>` format. `null` when the rule has no CWE ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| attributes   | description [*required*]          | string   | What the rule detects and why it matters, at most 10,000 bytes in UTF-8. Search it with `filter[query]`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| attributes   | is_published [*required*]         | boolean  | `true` when scans run the rule. `false` when the rule is a draft, which scans skip. Filter with `filter[is_published]=true`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| attributes   | modified_at [*required*]          | int64    | The creation time of the current revision, in milliseconds since the Unix epoch, in UTC.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| attributes   | modified_by_id [*required*]       | string   | The UUID of the user who stored the current revision.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| attributes   | name [*required*]                 | string   | The display name of the rule, between 1 and 60 bytes in UTF-8. Search it with `filter[query]`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| attributes   | platform [*required*]             | enum     | The IaC (Infrastructure as Code) platform of the files that the rule scans, as stored. Rules created outside this API can have a platform that custom rules don't support. Scans don't run these rules, and create, update, and validate requests don't accept that platform. - `ansible`: Ansible playbooks. - `azure_resource_manager`: Azure Resource Manager templates. Custom rules don't support it. - `buildah`: Buildah files. Custom rules don't support it. - `cicd`: GitHub Actions workflows. - `cloudformation`: AWS CloudFormation templates. - `common`: Rules that aren't specific to one platform. Custom rules don't support it. - `crossplane`: Crossplane manifests. Custom rules don't support it. - `docker_compose`: Docker Compose files. - `dockerfile`: Dockerfiles. - `google_deployment_manager`: Google Cloud Deployment Manager templates. Custom rules don't support it. - `grpc`: gRPC Protocol Buffers definitions. Custom rules don't support it. - `knative`: Knative manifests. Custom rules don't support it. - `kubernetes`: Kubernetes manifests. - `openapi`: OpenAPI definitions. Custom rules don't support it. - `pulumi`: Pulumi programs. Custom rules don't support it. - `serverless_fw`: Serverless Framework files. Custom rules don't support it. - `terraform`: Terraform configuration files. Allowed enum values: `ansible`, `azure_resource_manager`, `buildah`, `cicd`, `cloudformation`, `common`, `crossplane`, `docker_compose`, `dockerfile`, `google_deployment_manager`, `grpc`, `knative`, `kubernetes`, `openapi`, `pulumi`, `serverless_fw`, `terraform`. |
| attributes   | provider [*required*]             | string   | The cloud or service provider that the rule targets, in lowercase, for example `aws`. `null` when the rule has no provider. Filter with `filter[provider]=aws`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| attributes   | rego_query [*required*]           | string   | The Rego source of the rule, in plain text.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| attributes   | sample_file [*required*]          | string   | An example IaC file, in plain text, that contains the misconfiguration that the rule detects. `null` when the rule has no sample file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| attributes   | severity [*required*]             | enum     | The severity of the findings that the rule reports. - `critical`: The highest severity. - `high`: The second highest severity. - `medium`: The middle severity. - `low`: The second lowest severity. - `info`: The lowest severity, for informational findings. Allowed enum values: `critical`, `high`, `medium`, `low`, `info`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| attributes   | version [*required*]              | int64    | The number of the current revision, starting at `1`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| data         | id [*required*]                   | string   | The ID of the rule, for example `custom-terraform-aws-s3-bucket-without-encryption`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| data         | type [*required*]                 | enum     | The type of the resource. The value is always `iac_custom_rules`. Allowed enum values: `iac_custom_rules`. Default: `iac_custom_rules`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
|              | meta [*required*]                 | object   | Information about the list of rules.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| meta         | page [*required*]                 | object   | Pagination information.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| page         | total_filtered_count [*required*] | int64    | The number of rules that match the filters, across all pages.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": [
    {
      "attributes": {
        "category": "encryption",
        "created_at": 1793271987422,
        "created_by_id": "00000000-0000-0000-0000-000000001234",
        "cwe_id": "CWE-311",
        "description": "S3 buckets must encrypt data at rest.",
        "is_published": false,
        "modified_at": 1793271987422,
        "modified_by_id": "00000000-0000-0000-0000-000000001234",
        "name": "S3 bucket without encryption",
        "platform": "terraform",
        "provider": "aws",
        "rego_query": "package datadog\n\nDatadogPolicy contains result if {\n\tsome i, doc in input.document\n\tsome type, resources in doc.resource\n\tsome name, resource in resources\n\ttype == \"aws_s3_bucket\"\n\tnot resource.server_side_encryption_configuration\n\tresult := {\n\t\t\"documentId\": doc.id,\n\t\t\"resourceType\": type,\n\t\t\"resourceName\": name,\n\t\t\"searchKey\": sprintf(\"resource.%s.%s\", [type, name]),\n\t}\n}",
        "sample_file": "resource \"aws_s3_bucket\" \"my_bucket\" {\n  bucket = \"my-bucket\"\n}",
        "severity": "high",
        "version": 1
      },
      "id": "custom-terraform-aws-s3-bucket-without-encryption",
      "type": "iac_custom_rules"
    }
  ],
  "meta": {
    "page": {
      "total_filtered_count": 1
    }
  }
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

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

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

| Parent field | Field               | Type     | Description                                                                     |
| ------------ | ------------------- | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | code                | string   | An application-specific error code.                                             |
| errors       | detail              | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                | object   | Non-standard meta-information about the error                                   |
| errors       | source              | object   | References to the source of the error.                                          |
| source       | header              | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter           | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer             | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status              | string   | Status code of the response.                                                    |
| errors       | title               | string   | Short human-readable summary of the error.                                      |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    {
      "code": "invalid_request",
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="403" %}
Forbidden

{% 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.

| Parent field | Field               | Type     | Description                                                                     |
| ------------ | ------------------- | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | code                | string   | An application-specific error code.                                             |
| errors       | detail              | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                | object   | Non-standard meta-information about the error                                   |
| errors       | source              | object   | References to the source of the error.                                          |
| source       | header              | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter           | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer             | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status              | string   | Status code of the response.                                                    |
| errors       | title               | string   | Short human-readable summary of the error.                                      |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    {
      "code": "invalid_request",
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "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 GET "https://api.${DD_SITE}/api/v2/security/code_security/iac_custom_rules" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"
```
{% /tab %}
{% /tabs %}
