Update Custom Ruleset

This endpoint is in Preview and may introduce breaking changes. If you have any feedback, contact Datadog support.

PATCH https://api.ap1.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}https://api.ap2.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}https://api.datadoghq.eu/api/v2/static-analysis/custom/rulesets/{ruleset_name}https://api.ddog-gov.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}https://api.us2.ddog-gov.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}https://api.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}https://api.us3.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}https://api.us5.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}

Overview

Update an existing custom ruleset

Arguments

Path Parameters

Name

Type

Description

ruleset_name [required]

string

The ruleset name

Request

Body Data (required)

Expand All

Field

Type

Description

data

object

Data object for a custom ruleset create or update request.

attributes

object

Attributes for creating or updating a custom ruleset.

description

string

Base64-encoded full description

name

string

Ruleset name

rules

[object]

Rules in the ruleset

created_at [required]

date-time

Creation timestamp

created_by [required]

string

Creator identifier

last_revision [required]

object

Most recent revision

attributes [required]

object

Attributes of a custom rule revision, including code, metadata, and test cases.

arguments [required]

[object]

Rule arguments

description [required]

string

Base64-encoded argument description

name [required]

string

Base64-encoded argument name

category [required]

enum

Rule category Allowed enum values: SECURITY,BEST_PRACTICES,CODE_STYLE,ERROR_PRONE,PERFORMANCE

checksum [required]

string

Code checksum

code [required]

string

Rule code

created_at [required]

date-time

Creation timestamp

created_by [required]

string

Creator identifier

creation_message [required]

string

Revision creation message

cve [required]

string

Associated CVE

cwe [required]

string

Associated CWE

description [required]

string

Full description

documentation_url [required]

string

Documentation URL

is_published [required]

boolean

Whether the revision is published

is_testing [required]

boolean

Whether this is a testing revision

language [required]

enum

Programming language Allowed enum values: PYTHON,JAVASCRIPT,TYPESCRIPT,JAVA,GO,YAML,RUBY,CSHARP,PHP,KOTLIN

Show 1 more,SWIFT

severity [required]

enum

Rule severity Allowed enum values: ERROR,WARNING,NOTICE

short_description [required]

string

Short description

should_use_ai_fix [required]

boolean

Whether to use AI for fixes

tags [required]

[string]

Rule tags

tests [required]

[object]

Rule tests

annotation_count [required]

int64

Expected violation count

code [required]

string

Test code

filename [required]

string

Test filename

tree_sitter_query [required]

string

Tree-sitter query

id [required]

string

Revision identifier

type [required]

enum

Resource type Allowed enum values: custom_rule_revision

name [required]

string

Rule name

short_description

string

Base64-encoded short description

id

string

Ruleset identifier

type

enum

Resource type Allowed enum values: custom_ruleset

{
  "data": {
    "attributes": {
      "description": "string",
      "name": "string",
      "rules": [
        {
          "created_at": "2026-01-09T13:00:57.473141Z",
          "created_by": "foobarbaz",
          "last_revision": {
            "attributes": {
              "arguments": [
                {
                  "description": "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                  "name": "YXJndW1lbnRfbmFtZQ=="
                }
              ],
              "category": "SECURITY",
              "checksum": "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99",
              "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
              "created_at": "2026-01-09T13:00:57.473141Z",
              "created_by": "foobarbaz",
              "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": "revision-123",
            "type": "custom_rule_revision"
          },
          "name": "my-rule"
        }
      ],
      "short_description": "string"
    },
    "id": "string",
    "type": "custom_ruleset"
  }
}

Response

Successfully updated

Response containing a single custom ruleset.

Expand All

Field

Type

Description

data [required]

object

A custom static analysis ruleset containing a set of user-defined rules.

attributes [required]

object

Attributes of a custom ruleset, including its name, description, and rules.

created_at [required]

date-time

Creation timestamp

created_by [required]

string

Creator identifier

description [required]

string

Base64-encoded full description

name [required]

string

Ruleset name

rules [required]

[object]

Rules in the ruleset

created_at [required]

date-time

Creation timestamp

created_by [required]

string

Creator identifier

last_revision [required]

object

Most recent revision

attributes [required]

object

Attributes of a custom rule revision, including code, metadata, and test cases.

arguments [required]

[object]

Rule arguments

description [required]

string

Base64-encoded argument description

name [required]

string

Base64-encoded argument name

category [required]

enum

Rule category Allowed enum values: SECURITY,BEST_PRACTICES,CODE_STYLE,ERROR_PRONE,PERFORMANCE

checksum [required]

string

Code checksum

code [required]

string

Rule code

created_at [required]

date-time

Creation timestamp

created_by [required]

string

Creator identifier

creation_message [required]

string

Revision creation message

cve [required]

string

Associated CVE

cwe [required]

string

Associated CWE

description [required]

string

Full description

documentation_url [required]

string

Documentation URL

is_published [required]

boolean

Whether the revision is published

is_testing [required]

boolean

Whether this is a testing revision

language [required]

enum

Programming language Allowed enum values: PYTHON,JAVASCRIPT,TYPESCRIPT,JAVA,GO,YAML,RUBY,CSHARP,PHP,KOTLIN

Show 1 more,SWIFT

severity [required]

enum

Rule severity Allowed enum values: ERROR,WARNING,NOTICE

short_description [required]

string

Short description

should_use_ai_fix [required]

boolean

Whether to use AI for fixes

tags [required]

[string]

Rule tags

tests [required]

[object]

Rule tests

annotation_count [required]

int64

Expected violation count

code [required]

string

Test code

filename [required]

string

Test filename

tree_sitter_query [required]

string

Tree-sitter query

id [required]

string

Revision identifier

type [required]

enum

Resource type Allowed enum values: custom_rule_revision

name [required]

string

Rule name

short_description [required]

string

Base64-encoded short description

id [required]

string

Ruleset identifier

type [required]

enum

Resource type Allowed enum values: custom_ruleset

{
  "data": {
    "attributes": {
      "created_at": "2026-01-09T13:00:57.473141Z",
      "created_by": "foobarbaz",
      "description": "bG9uZyBkZXNjcmlwdGlvbg==",
      "name": "my-ruleset",
      "rules": [
        {
          "created_at": "2026-01-09T13:00:57.473141Z",
          "created_by": "foobarbaz",
          "last_revision": {
            "attributes": {
              "arguments": [
                {
                  "description": "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                  "name": "YXJndW1lbnRfbmFtZQ=="
                }
              ],
              "category": "SECURITY",
              "checksum": "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99",
              "code": "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
              "created_at": "2026-01-09T13:00:57.473141Z",
              "created_by": "foobarbaz",
              "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": "revision-123",
            "type": "custom_rule_revision"
          },
          "name": "my-rule"
        }
      ],
      "short_description": "c2hvcnQgZGVzY3JpcHRpb24="
    },
    "id": "my-ruleset",
    "type": "custom_ruleset"
  }
}

Bad request

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

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

Unauthorized - custom rules not enabled

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

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

Precondition failed - validation error or ruleset not found

API error response.

Expand All

Field

Type

Description

errors [required]

[object]

A list of errors.

detail

string

A human-readable explanation specific to this occurrence of the error.

meta

object

Non-standard meta-information about the error

source

object

References to the source of the error.

header

string

A string indicating the name of a single request header which caused the error.

parameter

string

A string indicating which URI query parameter caused the error.

pointer

string

A JSON pointer to the value in the request document that caused the error.

status

string

Status code of the response.

title

string

Short human-readable summary of the error.

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

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example

                  ## default
# 

# Path parameters
export ruleset_name="CHANGE_ME"
# Curl command
curl -X PATCH "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/static-analysis/custom/rulesets/${ruleset_name}" \ -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": { "rules": [ { "created_at": "2026-01-09T13:00:57.473141Z", "created_by": "foobarbaz", "last_revision": { "id": "revision-123" }, "name": "my-rule" } ] }, "type": "custom_ruleset" } } EOF
"""
Update Custom Ruleset returns "Successfully updated" 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 import CustomRule
from datadog_api_client.v2.model.custom_rule_revision import CustomRuleRevision
from datadog_api_client.v2.model.custom_rule_revision_attributes import CustomRuleRevisionAttributes
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_test import CustomRuleRevisionTest
from datadog_api_client.v2.model.custom_ruleset_data_type import CustomRulesetDataType
from datadog_api_client.v2.model.custom_ruleset_request import CustomRulesetRequest
from datadog_api_client.v2.model.custom_ruleset_request_data import CustomRulesetRequestData
from datadog_api_client.v2.model.custom_ruleset_request_data_attributes import CustomRulesetRequestDataAttributes
from datadog_api_client.v2.model.language import Language
from datetime import datetime
from dateutil.tz import tzutc

body = CustomRulesetRequest(
    data=CustomRulesetRequestData(
        attributes=CustomRulesetRequestDataAttributes(
            rules=[
                CustomRule(
                    created_at=datetime(2026, 1, 9, 13, 0, 57, 473141, tzinfo=tzutc()),
                    created_by="foobarbaz",
                    last_revision=CustomRuleRevision(
                        attributes=CustomRuleRevisionAttributes(
                            arguments=[
                                Argument(
                                    description="YXJndW1lbnQgZGVzY3JpcHRpb24=",
                                    name="YXJndW1lbnRfbmFtZQ==",
                                ),
                            ],
                            category=CustomRuleRevisionAttributesCategory.SECURITY,
                            checksum="8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99",
                            code="Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                            created_at=datetime(2026, 1, 9, 13, 0, 57, 473141, tzinfo=tzutc()),
                            created_by="foobarbaz",
                            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==",
                        ),
                        id="revision-123",
                        type=CustomRuleRevisionDataType.CUSTOM_RULE_REVISION,
                    ),
                    name="my-rule",
                ),
            ],
        ),
        type=CustomRulesetDataType.CUSTOM_RULESET,
    ),
)

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

    print(response)

Instructions

First install the library and its dependencies and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Update Custom Ruleset returns "Successfully updated" response

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

body = DatadogAPIClient::V2::CustomRulesetRequest.new({
  data: DatadogAPIClient::V2::CustomRulesetRequestData.new({
    attributes: DatadogAPIClient::V2::CustomRulesetRequestDataAttributes.new({
      rules: [
        DatadogAPIClient::V2::CustomRule.new({
          created_at: "2026-01-09T13:00:57.473141Z",
          created_by: "foobarbaz",
          last_revision: DatadogAPIClient::V2::CustomRuleRevision.new({
            attributes: DatadogAPIClient::V2::CustomRuleRevisionAttributes.new({
              arguments: [
                DatadogAPIClient::V2::Argument.new({
                  description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                  name: "YXJndW1lbnRfbmFtZQ==",
                }),
              ],
              category: DatadogAPIClient::V2::CustomRuleRevisionAttributesCategory::SECURITY,
              checksum: "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99",
              code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
              created_at: "2026-01-09T13:00:57.473141Z",
              created_by: "foobarbaz",
              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==",
            }),
            id: "revision-123",
            type: DatadogAPIClient::V2::CustomRuleRevisionDataType::CUSTOM_RULE_REVISION,
          }),
          name: "my-rule",
        }),
      ],
    }),
    type: DatadogAPIClient::V2::CustomRulesetDataType::CUSTOM_RULESET,
  }),
})
p api_instance.update_custom_ruleset("ruleset_name", body)

Instructions

First install the library and its dependencies and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
// Update Custom Ruleset returns "Successfully updated" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

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

func main() {
	body := datadogV2.CustomRulesetRequest{
		Data: &datadogV2.CustomRulesetRequestData{
			Attributes: &datadogV2.CustomRulesetRequestDataAttributes{
				Rules: []datadogV2.CustomRule{
					{
						CreatedAt: time.Date(2026, 1, 9, 13, 0, 57, 473141, time.UTC),
						CreatedBy: "foobarbaz",
						LastRevision: datadogV2.CustomRuleRevision{
							Attributes: datadogV2.CustomRuleRevisionAttributes{
								Arguments: []datadogV2.Argument{
									{
										Description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
										Name:        "YXJndW1lbnRfbmFtZQ==",
									},
								},
								Category:         datadogV2.CUSTOMRULEREVISIONATTRIBUTESCATEGORY_SECURITY,
								Checksum:         "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99",
								Code:             "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
								CreatedAt:        time.Date(2026, 1, 9, 13, 0, 57, 473141, time.UTC),
								CreatedBy:        "foobarbaz",
								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==",
							},
							Id:   "revision-123",
							Type: datadogV2.CUSTOMRULEREVISIONDATATYPE_CUSTOM_RULE_REVISION,
						},
						Name: "my-rule",
					},
				},
			},
			Type: datadogV2.CUSTOMRULESETDATATYPE_CUSTOM_RULESET.Ptr(),
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.UpdateCustomRuleset", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewStaticAnalysisApi(apiClient)
	resp, r, err := api.UpdateCustomRuleset(ctx, "ruleset_name", body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `StaticAnalysisApi.UpdateCustomRuleset`:\n%s\n", responseContent)
}

Instructions

First install the library and its dependencies and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Update Custom Ruleset returns "Successfully updated" 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.CustomRule;
import com.datadog.api.client.v2.model.CustomRuleRevision;
import com.datadog.api.client.v2.model.CustomRuleRevisionAttributes;
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.CustomRuleRevisionTest;
import com.datadog.api.client.v2.model.CustomRulesetDataType;
import com.datadog.api.client.v2.model.CustomRulesetRequest;
import com.datadog.api.client.v2.model.CustomRulesetRequestData;
import com.datadog.api.client.v2.model.CustomRulesetRequestDataAttributes;
import com.datadog.api.client.v2.model.CustomRulesetResponse;
import com.datadog.api.client.v2.model.Language;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.Collections;

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

    CustomRulesetRequest body =
        new CustomRulesetRequest()
            .data(
                new CustomRulesetRequestData()
                    .attributes(
                        new CustomRulesetRequestDataAttributes()
                            .rules(
                                Collections.singletonList(
                                    new CustomRule()
                                        .createdAt(
                                            OffsetDateTime.parse("2026-01-09T13:00:57.473141Z"))
                                        .createdBy("foobarbaz")
                                        .lastRevision(
                                            new CustomRuleRevision()
                                                .attributes(
                                                    new CustomRuleRevisionAttributes()
                                                        .arguments(
                                                            Collections.singletonList(
                                                                new Argument()
                                                                    .description(
                                                                        "YXJndW1lbnQgZGVzY3JpcHRpb24=")
                                                                    .name("YXJndW1lbnRfbmFtZQ==")))
                                                        .category(
                                                            CustomRuleRevisionAttributesCategory
                                                                .SECURITY)
                                                        .checksum(
                                                            "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99")
                                                        .code(
                                                            "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==")
                                                        .createdAt(
                                                            OffsetDateTime.parse(
                                                                "2026-01-09T13:00:57.473141Z"))
                                                        .createdBy("foobarbaz")
                                                        .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=="))
                                                .id("revision-123")
                                                .type(
                                                    CustomRuleRevisionDataType
                                                        .CUSTOM_RULE_REVISION))
                                        .name("my-rule"))))
                    .type(CustomRulesetDataType.CUSTOM_RULESET));

    try {
      CustomRulesetResponse result = apiInstance.updateCustomRuleset("ruleset_name", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling StaticAnalysisApi#updateCustomRuleset");
      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 and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
// Update Custom Ruleset returns "Successfully updated" response
use chrono::{DateTime, Utc};
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::CustomRule;
use datadog_api_client::datadogV2::model::CustomRuleRevision;
use datadog_api_client::datadogV2::model::CustomRuleRevisionAttributes;
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::CustomRuleRevisionTest;
use datadog_api_client::datadogV2::model::CustomRulesetDataType;
use datadog_api_client::datadogV2::model::CustomRulesetRequest;
use datadog_api_client::datadogV2::model::CustomRulesetRequestData;
use datadog_api_client::datadogV2::model::CustomRulesetRequestDataAttributes;
use datadog_api_client::datadogV2::model::Language;

#[tokio::main]
async fn main() {
    let body = CustomRulesetRequest::new().data(
        CustomRulesetRequestData::new()
            .attributes(CustomRulesetRequestDataAttributes::new().rules(Some(
                vec![CustomRule::new(
                    DateTime::parse_from_rfc3339("2026-01-09T13:00:57.473141+00:00")
                        .expect("Failed to parse datetime")
                        .with_timezone(&Utc),
                    "foobarbaz".to_string(),
                    CustomRuleRevision::new(
                        CustomRuleRevisionAttributes::new(
                            vec![Argument::new(
                                "YXJndW1lbnQgZGVzY3JpcHRpb24=".to_string(),
                                "YXJndW1lbnRfbmFtZQ==".to_string(),
                            )],
                            CustomRuleRevisionAttributesCategory::SECURITY,
                            "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99"
                                .to_string(),
                            "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==".to_string(),
                            DateTime::parse_from_rfc3339("2026-01-09T13:00:57.473141+00:00")
                                .expect("Failed to parse datetime")
                                .with_timezone(&Utc),
                            "foobarbaz".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(),
                        ),
                        "revision-123".to_string(),
                        CustomRuleRevisionDataType::CUSTOM_RULE_REVISION,
                    ),
                    "my-rule".to_string(),
                )],
            )))
            .type_(CustomRulesetDataType::CUSTOM_RULESET),
    );
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.UpdateCustomRuleset", true);
    let api = StaticAnalysisAPI::with_config(configuration);
    let resp = api
        .update_custom_ruleset("ruleset_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 and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
/**
 * Update Custom Ruleset returns "Successfully updated" response
 */

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

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

const params: v2.StaticAnalysisApiUpdateCustomRulesetRequest = {
  body: {
    data: {
      attributes: {
        rules: [
          {
            createdAt: new Date(2026, 1, 9, 13, 0, 57, 473141),
            createdBy: "foobarbaz",
            lastRevision: {
              attributes: {
                arguments: [
                  {
                    description: "YXJndW1lbnQgZGVzY3JpcHRpb24=",
                    name: "YXJndW1lbnRfbmFtZQ==",
                  },
                ],
                category: "SECURITY",
                checksum:
                  "8a66c4e4e631099ad71be3c1ea3ea8fc2d57193e56db2c296e2dd8a508b26b99",
                code: "Y29uZHVjdG9yOgogICAgLSBkZXBsb3lfb25seTogdHJ1ZQ==",
                createdAt: new Date(2026, 1, 9, 13, 0, 57, 473141),
                createdBy: "foobarbaz",
                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==",
              },
              id: "revision-123",
              type: "custom_rule_revision",
            },
            name: "my-rule",
          },
        ],
      },
      type: "custom_ruleset",
    },
  },
  rulesetName: "ruleset_name",
};

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

Instructions

First install the library and its dependencies and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"