---
title: List the revisions of an IaC custom rule
description: List the stored revisions of a custom IaC (Infrastructure as Code) rule, newest first.
breadcrumbs: Docs > API > List the revisions of an IaC custom rule
---

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

# List the revisions of an IaC custom rule

## 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/{rule_id}/revisions     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/security/code_security/iac_custom_rules/{rule_id}/revisions |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/security/code_security/iac_custom_rules/{rule_id}/revisions |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/security/code_security/iac_custom_rules/{rule_id}/revisions      |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/security/code_security/iac_custom_rules/{rule_id}/revisions |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/security/code_security/iac_custom_rules/{rule_id}/revisions |
| uk1.datadoghq.com | GET https://api.uk1.datadoghq.com/api/v2/security/code_security/iac_custom_rules/{rule_id}/revisions |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/security/code_security/iac_custom_rules/{rule_id}/revisions      |
| us2.ddog-gov.com  | GET https://api.us2.ddog-gov.com/api/v2/security/code_security/iac_custom_rules/{rule_id}/revisions  |

### Overview

List the stored revisions of a custom IaC (Infrastructure as Code) rule, newest first.
Each create, update, and publication change stores one revision.
Results are paginated with `page[size]` and `page[number]`.
`meta.page.total_filtered_count` is the number of revisions of the rule, across all pages.
Revisions show only the fields that the API exposes.
To restore the exposed fields of a revision, send them to
`PATCH /api/v2/security/code_security/iac_custom_rules/{rule_id}`:
the fields that the API doesn't expose (overrides, framework associations, aggregation, and test files)
keep their current values,
and a `sample_file` replaces all the test files of the rule.
There is no operation that restores a whole revision.

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

#### Path Parameters

| Field                | Type   | Description                                                                                     |
| -------------------- | ------ | ----------------------------------------------------------------------------------------------- |
| rule_id [*required*] | string | The ID of the IaC custom rule, for example `custom-terraform-aws-s3-bucket-without-encryption`. |

#### Query Strings

| Field        | Type    | Description                                                         |
| ------------ | ------- | ------------------------------------------------------------------- |
| page[size]   | integer | The number of revisions per page, between 1 and 100. Default: `10`. |
| page[number] | integer | The page to return, starting at `0`. Default: `0`.                  |

### Response

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

{% tabs %}
{% tab label="Model" %}
A page of revisions of an IaC custom rule.

| Parent field | Field                             | Type     | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ------------ | --------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]                 | [object] | A list of revisions of an IaC custom rule, newest first.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| data         | attributes [*required*]           | object   | The attributes of one revision of an IaC custom rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| 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 revision, in milliseconds since the Unix epoch, in UTC.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| attributes   | created_by_id [*required*]        | string   | The UUID (universally unique identifier) of the user who stored the revision.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| 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 revision has no CWE ID.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| attributes   | description [*required*]          | string   | What the rule detects and why it matters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| attributes   | is_published [*required*]         | boolean  | `true` when this revision published the rule, so that scans ran it. `false` when this revision kept the rule as a draft.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| attributes   | name [*required*]                 | string   | The display name of the rule.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| 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. `null` when the revision has no provider.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| attributes   | rego_query [*required*]           | string   | The Rego source of the rule, in plain text.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| attributes   | rule_id [*required*]              | string   | The ID of the rule that the revision belongs to.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| attributes   | sample_file [*required*]          | string   | An example IaC file, in plain text, that contains the misconfiguration that the rule detects. `null` when the revision 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 revision, starting at `1`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| data         | id [*required*]                   | string   | The ID of the revision.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| data         | type [*required*]                 | enum     | The type of the resource. The value is always `iac_custom_rule_revisions`. Allowed enum values: `iac_custom_rule_revisions`. Default: `iac_custom_rule_revisions`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
|              | meta [*required*]                 | object   | Information about the list of revisions.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| meta         | page [*required*]                 | object   | Pagination information.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| page         | total_filtered_count [*required*] | int64    | The number of revisions of the rule, 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,
        "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}",
        "rule_id": "custom-terraform-aws-s3-bucket-without-encryption",
        "sample_file": "resource \"aws_s3_bucket\" \"my_bucket\" {\n  bucket = \"my-bucket\"\n}",
        "severity": "high",
        "version": 1
      },
      "id": "1",
      "type": "iac_custom_rule_revisions"
    }
  ],
  "meta": {
    "page": {
      "total_filtered_count": 2
    }
  }
}
```
{% /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
# Path parameters
export rule_id="custom-terraform-aws-s3-bucket-without-encryption"

# 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/${rule_id}/revisions" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"
```
{% /tab %}
{% /tabs %}
