---
title: Create Custom Rule Revision
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Static Analysis
---

# Create Custom Rule Revision{% #create-custom-rule-revision %}

{% tab title="v2" %}
This endpoint is in Preview and may introduce breaking changes. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
| Datadog site      | API endpoint                                                                                                        |
| ----------------- | ------------------------------------------------------------------------------------------------------------------- |
| ap1.datadoghq.com | PUT https://api.ap1.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions |
| ap2.datadoghq.com | PUT https://api.ap2.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions |
| app.datadoghq.eu  | PUT https://api.datadoghq.eu/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions      |
| app.ddog-gov.com  | PUT https://api.ddog-gov.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions      |
| us2.ddog-gov.com  | PUT https://api.us2.ddog-gov.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions  |
| app.datadoghq.com | PUT https://api.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions     |
| us3.datadoghq.com | PUT https://api.us3.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions |
| us5.datadoghq.com | PUT https://api.us5.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}/revisions |

### Overview

Create a new revision for a custom rule

### Arguments

#### Path Parameters

| Name                           | Type   | Description      |
| ------------------------------ | ------ | ---------------- |
| ruleset_name [*required*] | string | The ruleset name |
| rule_name [*required*]    | string | The rule name    |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                               | Type     | Description                                                                                                  |
| ------------ | ----------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------ |
|              | data                                | object   | Data object for a custom rule revision create request.                                                       |
| data         | attributes                          | object   | Input attributes for creating or updating a custom rule revision.                                            |
| attributes   | arguments [*required*]         | [object] | Rule arguments                                                                                               |
| arguments    | description [*required*]       | string   | Base64-encoded argument description                                                                          |
| arguments    | name [*required*]              | string   | Base64-encoded argument name                                                                                 |
| attributes   | category [*required*]          | enum     | Rule category Allowed enum values: `SECURITY,BEST_PRACTICES,CODE_STYLE,ERROR_PRONE,PERFORMANCE`              |
| attributes   | code [*required*]              | string   | Rule code                                                                                                    |
| attributes   | creation_message [*required*]  | string   | Revision creation message                                                                                    |
| attributes   | cve [*required*]               | string   | Associated CVE                                                                                               |
| attributes   | cwe [*required*]               | string   | Associated CWE                                                                                               |
| attributes   | description [*required*]       | string   | Full description                                                                                             |
| attributes   | documentation_url [*required*] | string   | Documentation URL                                                                                            |
| attributes   | is_published [*required*]      | boolean  | Whether the revision is published                                                                            |
| attributes   | is_testing [*required*]        | boolean  | Whether this is a testing revision                                                                           |
| attributes   | language [*required*]          | enum     | Programming language Allowed enum values: `PYTHON,JAVASCRIPT,TYPESCRIPT,JAVA,GO,YAML,RUBY,CSHARP,PHP,KOTLIN` |
| attributes   | severity [*required*]          | enum     | Rule severity Allowed enum values: `ERROR,WARNING,NOTICE`                                                    |
| attributes   | short_description [*required*] | string   | Short description                                                                                            |
| attributes   | should_use_ai_fix [*required*] | boolean  | Whether to use AI for fixes                                                                                  |
| attributes   | tags [*required*]              | [string] | Rule tags                                                                                                    |
| attributes   | tests [*required*]             | [object] | Rule tests                                                                                                   |
| tests        | annotation_count [*required*]  | int64    | Expected violation count                                                                                     |
| tests        | code [*required*]              | string   | Test code                                                                                                    |
| tests        | filename [*required*]          | string   | Test filename                                                                                                |
| attributes   | tree_sitter_query [*required*] | string   | Tree-sitter query                                                                                            |
| data         | id                                  | string   | Revision identifier                                                                                          |
| data         | type                                | enum     | Resource type Allowed enum values: `custom_rule_revision`                                                    |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "YXJndW1lbnQgZGVzY3JpcHRpb24=",
          "name": "YXJndW1lbnRfbmFtZQ=="
        }
      ],
      "category": "SECURITY",
      "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "bG9uZyBkZXNjcmlwdGlvbg==",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "c2hvcnQgZGVzY3JpcHRpb24=",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="
    },
    "id": "string",
    "type": "custom_rule_revision"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
Successfully created
{% /tab %}

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

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| 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 title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="401" %}
Unauthorized - custom rules not enabled
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| 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 title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Rule not found
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| 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 title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

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

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

{% /tab %}

{% tab title="Example" %}

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

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Path parameters export ruleset_name="CHANGE_ME" export rule_name="CHANGE_ME" \# Curl command curl -X PUT "https://api.datadoghq.com/api/v2/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}/revisions" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        {
          "description": "Maximum call depth to analyze",
          "name": "max_depth"
        }
      ],
      "category": "SECURITY",
      "code": "def rule(node): return node.type == 'call'",
      "creation_message": "Initial revision",
      "cve": "CVE-2024-1234",
      "cwe": "CWE-79",
      "description": "Detects insecure coding patterns that may lead to vulnerabilities",
      "documentation_url": "https://docs.example.com/rules/my-rule",
      "is_published": false,
      "is_testing": false,
      "language": "PYTHON",
      "severity": "ERROR",
      "short_description": "Rule to detect insecure patterns",
      "should_use_ai_fix": false,
      "tags": [
        "security",
        "custom"
      ],
      "tests": [
        {
          "annotation_count": 1,
          "code": "result = insecure_function()",
          "filename": "test.yaml"
        }
      ],
      "tree_sitter_query": "(call_expression) @call"
    },
    "type": "custom_rule_revision"
  }
}
EOF 
                
##### 

```python
"""
Create Custom Rule Revision returns "Successfully created" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.static_analysis_api import StaticAnalysisApi
from datadog_api_client.v2.model.argument import Argument
from datadog_api_client.v2.model.custom_rule_revision_attributes_category import CustomRuleRevisionAttributesCategory
from datadog_api_client.v2.model.custom_rule_revision_attributes_severity import CustomRuleRevisionAttributesSeverity
from datadog_api_client.v2.model.custom_rule_revision_data_type import CustomRuleRevisionDataType
from datadog_api_client.v2.model.custom_rule_revision_input_attributes import CustomRuleRevisionInputAttributes
from datadog_api_client.v2.model.custom_rule_revision_request import CustomRuleRevisionRequest
from datadog_api_client.v2.model.custom_rule_revision_request_data import CustomRuleRevisionRequestData
from datadog_api_client.v2.model.custom_rule_revision_test import CustomRuleRevisionTest
from datadog_api_client.v2.model.language import Language

body = CustomRuleRevisionRequest(
    data=CustomRuleRevisionRequestData(
        attributes=CustomRuleRevisionInputAttributes(
            arguments=[
                Argument(
                    description="YXJndW1lbnQgZGVzY3JpcHRpb24=",
                    name="YXJndW1lbnRfbmFtZQ==",
                ),
            ],
            category=CustomRuleRevisionAttributesCategory.SECURITY,
            code="Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
            creation_message="Initial revision",
            cve="CVE-2024-1234",
            cwe="CWE-79",
            description="bG9uZyBkZXNjcmlwdGlvbg==",
            documentation_url="https://docs.example.com/rules/my-rule",
            is_published=False,
            is_testing=False,
            language=Language.PYTHON,
            severity=CustomRuleRevisionAttributesSeverity.ERROR,
            short_description="c2hvcnQgZGVzY3JpcHRpb24=",
            should_use_ai_fix=False,
            tags=[
                "security",
                "custom",
            ],
            tests=[
                CustomRuleRevisionTest(
                    annotation_count=1,
                    code="Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                    filename="test.yaml",
                ),
            ],
            tree_sitter_query="Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
        ),
        type=CustomRuleRevisionDataType.CUSTOM_RULE_REVISION,
    ),
)

configuration = Configuration()
configuration.unstable_operations["create_custom_rule_revision"] = True
with ApiClient(configuration) as api_client:
    api_instance = StaticAnalysisApi(api_client)
    api_instance.create_custom_rule_revision(ruleset_name="ruleset_name", rule_name="rule_name", body=body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Create Custom Rule Revision returns "Successfully created" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.create_custom_rule_revision".to_sym] = true
end
api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new

body = DatadogAPIClient::V2::CustomRuleRevisionRequest.new({
  data: DatadogAPIClient::V2::CustomRuleRevisionRequestData.new({
    attributes: DatadogAPIClient::V2::CustomRuleRevisionInputAttributes.new({
      arguments: [
        DatadogAPIClient::V2::Argument.new({
          description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
          name: "YXJndW1lbnRfbmFtZQ==",
        }),
      ],
      category: DatadogAPIClient::V2::CustomRuleRevisionAttributesCategory::SECURITY,
      code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
      creation_message: "Initial revision",
      cve: "CVE-2024-1234",
      cwe: "CWE-79",
      description: "bG9uZyBkZXNjcmlwdGlvbg==",
      documentation_url: "https://docs.example.com/rules/my-rule",
      is_published: false,
      is_testing: false,
      language: DatadogAPIClient::V2::Language::PYTHON,
      severity: DatadogAPIClient::V2::CustomRuleRevisionAttributesSeverity::ERROR,
      short_description: "c2hvcnQgZGVzY3JpcHRpb24=",
      should_use_ai_fix: false,
      tags: [
        "security",
        "custom",
      ],
      tests: [
        DatadogAPIClient::V2::CustomRuleRevisionTest.new({
          annotation_count: 1,
          code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
          filename: "test.yaml",
        }),
      ],
      tree_sitter_query: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
    }),
    type: DatadogAPIClient::V2::CustomRuleRevisionDataType::CUSTOM_RULE_REVISION,
  }),
})
p api_instance.create_custom_rule_revision("ruleset_name", "rule_name", body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// Create Custom Rule Revision returns "Successfully created" response

package main

import (
	"context"
	"fmt"
	"os"

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

func main() {
	body := datadogV2.CustomRuleRevisionRequest{
		Data: &datadogV2.CustomRuleRevisionRequestData{
			Attributes: &datadogV2.CustomRuleRevisionInputAttributes{
				Arguments: []datadogV2.Argument{
					{
						Description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
						Name:        "YXJndW1lbnRfbmFtZQ==",
					},
				},
				Category:         datadogV2.CUSTOMRULEREVISIONATTRIBUTESCATEGORY_SECURITY,
				Code:             "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
				CreationMessage:  "Initial revision",
				Cve:              *datadog.NewNullableString(datadog.PtrString("CVE-2024-1234")),
				Cwe:              *datadog.NewNullableString(datadog.PtrString("CWE-79")),
				Description:      "bG9uZyBkZXNjcmlwdGlvbg==",
				DocumentationUrl: *datadog.NewNullableString(datadog.PtrString("https://docs.example.com/rules/my-rule")),
				IsPublished:      false,
				IsTesting:        false,
				Language:         datadogV2.LANGUAGE_PYTHON,
				Severity:         datadogV2.CUSTOMRULEREVISIONATTRIBUTESSEVERITY_ERROR,
				ShortDescription: "c2hvcnQgZGVzY3JpcHRpb24=",
				ShouldUseAiFix:   false,
				Tags: []string{
					"security",
					"custom",
				},
				Tests: []datadogV2.CustomRuleRevisionTest{
					{
						AnnotationCount: 1,
						Code:            "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
						Filename:        "test.yaml",
					},
				},
				TreeSitterQuery: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
			},
			Type: datadogV2.CUSTOMRULEREVISIONDATATYPE_CUSTOM_RULE_REVISION.Ptr(),
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.CreateCustomRuleRevision", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewStaticAnalysisApi(apiClient)
	r, err := api.CreateCustomRuleRevision(ctx, "ruleset_name", "rule_name", body)

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Create Custom Rule Revision returns "Successfully created" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.StaticAnalysisApi;
import com.datadog.api.client.v2.model.Argument;
import com.datadog.api.client.v2.model.CustomRuleRevisionAttributesCategory;
import com.datadog.api.client.v2.model.CustomRuleRevisionAttributesSeverity;
import com.datadog.api.client.v2.model.CustomRuleRevisionDataType;
import com.datadog.api.client.v2.model.CustomRuleRevisionInputAttributes;
import com.datadog.api.client.v2.model.CustomRuleRevisionRequest;
import com.datadog.api.client.v2.model.CustomRuleRevisionRequestData;
import com.datadog.api.client.v2.model.CustomRuleRevisionTest;
import com.datadog.api.client.v2.model.Language;
import java.util.Arrays;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.createCustomRuleRevision", true);
    StaticAnalysisApi apiInstance = new StaticAnalysisApi(defaultClient);

    CustomRuleRevisionRequest body =
        new CustomRuleRevisionRequest()
            .data(
                new CustomRuleRevisionRequestData()
                    .attributes(
                        new CustomRuleRevisionInputAttributes()
                            .arguments(
                                Collections.singletonList(
                                    new Argument()
                                        .description("YXJndW1lbnQgZGVzY3JpcHRpb24=")
                                        .name("YXJndW1lbnRfbmFtZQ==")))
                            .category(CustomRuleRevisionAttributesCategory.SECURITY)
                            .code("Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==")
                            .creationMessage("Initial revision")
                            .cve("CVE-2024-1234")
                            .cwe("CWE-79")
                            .description("bG9uZyBkZXNjcmlwdGlvbg==")
                            .documentationUrl("https://docs.example.com/rules/my-rule")
                            .isPublished(false)
                            .isTesting(false)
                            .language(Language.PYTHON)
                            .severity(CustomRuleRevisionAttributesSeverity.ERROR)
                            .shortDescription("c2hvcnQgZGVzY3JpcHRpb24=")
                            .shouldUseAiFix(false)
                            .tags(Arrays.asList("security", "custom"))
                            .tests(
                                Collections.singletonList(
                                    new CustomRuleRevisionTest()
                                        .annotationCount(1L)
                                        .code("Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==")
                                        .filename("test.yaml")))
                            .treeSitterQuery("Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ=="))
                    .type(CustomRuleRevisionDataType.CUSTOM_RULE_REVISION));

    try {
      apiInstance.createCustomRuleRevision("ruleset_name", "rule_name", body);
    } catch (ApiException e) {
      System.err.println("Exception when calling StaticAnalysisApi#createCustomRuleRevision");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// Create Custom Rule Revision returns "Successfully created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_static_analysis::StaticAnalysisAPI;
use datadog_api_client::datadogV2::model::Argument;
use datadog_api_client::datadogV2::model::CustomRuleRevisionAttributesCategory;
use datadog_api_client::datadogV2::model::CustomRuleRevisionAttributesSeverity;
use datadog_api_client::datadogV2::model::CustomRuleRevisionDataType;
use datadog_api_client::datadogV2::model::CustomRuleRevisionInputAttributes;
use datadog_api_client::datadogV2::model::CustomRuleRevisionRequest;
use datadog_api_client::datadogV2::model::CustomRuleRevisionRequestData;
use datadog_api_client::datadogV2::model::CustomRuleRevisionTest;
use datadog_api_client::datadogV2::model::Language;

#[tokio::main]
async fn main() {
    let body = CustomRuleRevisionRequest::new().data(
        CustomRuleRevisionRequestData::new()
            .attributes(CustomRuleRevisionInputAttributes::new(
                vec![Argument::new(
                    "YXJndW1lbnQgZGVzY3JpcHRpb24=".to_string(),
                    "YXJndW1lbnRfbmFtZQ==".to_string(),
                )],
                CustomRuleRevisionAttributesCategory::SECURITY,
                "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==".to_string(),
                "Initial revision".to_string(),
                Some("CVE-2024-1234".to_string()),
                Some("CWE-79".to_string()),
                "bG9uZyBkZXNjcmlwdGlvbg==".to_string(),
                Some("https://docs.example.com/rules/my-rule".to_string()),
                false,
                false,
                Language::PYTHON,
                CustomRuleRevisionAttributesSeverity::ERROR,
                "c2hvcnQgZGVzY3JpcHRpb24=".to_string(),
                false,
                vec!["security".to_string(), "custom".to_string()],
                vec![CustomRuleRevisionTest::new(
                    1,
                    "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==".to_string(),
                    "test.yaml".to_string(),
                )],
                "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==".to_string(),
            ))
            .type_(CustomRuleRevisionDataType::CUSTOM_RULE_REVISION),
    );
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.CreateCustomRuleRevision", true);
    let api = StaticAnalysisAPI::with_config(configuration);
    let resp = api
        .create_custom_rule_revision("ruleset_name".to_string(), "rule_name".to_string(), body)
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Create Custom Rule Revision returns "Successfully created" response
 */

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

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.createCustomRuleRevision"] = true;
const apiInstance = new v2.StaticAnalysisApi(configuration);

const params: v2.StaticAnalysisApiCreateCustomRuleRevisionRequest = {
  body: {
    data: {
      attributes: {
        arguments: [
          {
            description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
            name: "YXJndW1lbnRfbmFtZQ==",
          },
        ],
        category: "SECURITY",
        code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
        creationMessage: "Initial revision",
        cve: "CVE-2024-1234",
        cwe: "CWE-79",
        description: "bG9uZyBkZXNjcmlwdGlvbg==",
        documentationUrl: "https://docs.example.com/rules/my-rule",
        isPublished: false,
        isTesting: false,
        language: "PYTHON",
        severity: "ERROR",
        shortDescription: "c2hvcnQgZGVzY3JpcHRpb24=",
        shouldUseAiFix: false,
        tags: ["security", "custom"],
        tests: [
          {
            annotationCount: 1,
            code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
            filename: "test.yaml",
          },
        ],
        treeSitterQuery: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
      },
      type: "custom_rule_revision",
    },
  },
  rulesetName: "ruleset_name",
  ruleName: "rule_name",
};

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}
