---
title: Show Custom Rule
description: Get a custom rule by name
breadcrumbs: Docs > API > Show Custom Rule
---

> For the complete documentation index, see [llms.txt](https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/llms.txt).

# Show Custom Rule

## v2 (latest)

{% alert level="warning" %}
This endpoint is in Preview and may introduce breaking changes.
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/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}     |
| us3.datadoghq.com | GET https://api.us3.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name} |
| us5.datadoghq.com | GET https://api.us5.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name} |
| app.datadoghq.eu  | GET https://api.datadoghq.eu/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}      |
| ap1.datadoghq.com | GET https://api.ap1.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name} |
| ap2.datadoghq.com | GET https://api.ap2.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name} |
| uk1.datadoghq.com | GET https://api.uk1.datadoghq.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name} |
| app.ddog-gov.com  | GET https://api.ddog-gov.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}      |
| us2.ddog-gov.com  | GET https://api.us2.ddog-gov.com/api/v2/static-analysis/custom/rulesets/{ruleset_name}/rules/{rule_name}  |

### Overview

Get a custom rule by name

### Arguments

#### Path Parameters

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

### Response

{% tabs %}
{% tab label="200" %}
Successful response

{% tabs %}
{% tab label="Model" %}
Response containing a single custom rule.

| Parent field  | Field                          | Type      | Description                                                                                                                                                                                                                                                        |
| ------------- | ------------------------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|               | data [*required*]              | object    | Data object returned in a custom rule response, including its ID, type, and attributes.                                                                                                                                                                            |
| data          | attributes [*required*]        | object    | Attributes of a custom static analysis rule, including its most recent revision and revision history.                                                                                                                                                              |
| attributes    | created_at [*required*]        | date-time | Creation timestamp                                                                                                                                                                                                                                                 |
| attributes    | created_by [*required*]        | string    | Creator identifier                                                                                                                                                                                                                                                 |
| attributes    | last_revision [*required*]     | object    | Most recent revision of the rule, or null when the rule has no revisions.                                                                                                                                                                                          |
| last_revision | arguments [*required*]         | [object]  | Rule arguments                                                                                                                                                                                                                                                     |
| arguments     | description [*required*]       | string    | Base64-encoded argument description                                                                                                                                                                                                                                |
| arguments     | name [*required*]              | string    | Base64-encoded argument name                                                                                                                                                                                                                                       |
| last_revision | category [*required*]          | enum      | Rule category Allowed enum values: `SECURITY`, `BEST_PRACTICES`, `CODE_STYLE`, `ERROR_PRONE`, `PERFORMANCE`.                                                                                                                                                       |
| last_revision | checksum [*required*]          | string    | Code checksum                                                                                                                                                                                                                                                      |
| last_revision | code [*required*]              | string    | Rule code                                                                                                                                                                                                                                                          |
| last_revision | created_at [*required*]        | date-time | Creation timestamp                                                                                                                                                                                                                                                 |
| last_revision | created_by [*required*]        | string    | Creator identifier                                                                                                                                                                                                                                                 |
| last_revision | creation_message [*required*]  | string    | Revision creation message                                                                                                                                                                                                                                          |
| last_revision | cve                            | string    | Associated CVE. Omitted when the revision has no associated CVE.                                                                                                                                                                                                   |
| last_revision | cwe                            | string    | Associated CWE. Omitted when the revision has no associated CWE.                                                                                                                                                                                                   |
| last_revision | description [*required*]       | string    | Full description                                                                                                                                                                                                                                                   |
| last_revision | documentation_url              | string    | Documentation URL. Omitted when the revision has no documentation URL.                                                                                                                                                                                             |
| last_revision | id [*required*]                | string    | Revision identifier                                                                                                                                                                                                                                                |
| last_revision | is_published [*required*]      | boolean   | Whether the revision is published                                                                                                                                                                                                                                  |
| last_revision | is_testing [*required*]        | boolean   | Whether this is a testing revision                                                                                                                                                                                                                                 |
| last_revision | language [*required*]          | enum      | Programming language Allowed enum values: `PYTHON`, `JAVASCRIPT`, `TYPESCRIPT`, `JAVA`, `GO`, `YAML`, `RUBY`, `CSHARP`, `PHP`, `KOTLIN`, `SWIFT`, `DART`, `DOCKERFILE`, `ELIXIR`, `JSON`, `RUST`, `TERRAFORM`, `STARLARK`, `BASH`, `MARKDOWN`, `APEX`, `R`, `SQL`. |
| last_revision | severity [*required*]          | enum      | Rule severity Allowed enum values: `ERROR`, `WARNING`, `NOTICE`, `NONE`.                                                                                                                                                                                           |
| last_revision | short_description [*required*] | string    | Short description                                                                                                                                                                                                                                                  |
| last_revision | should_use_ai_fix [*required*] | boolean   | Whether to use AI for fixes                                                                                                                                                                                                                                        |
| last_revision | tags [*required*]              | [string]  | Rule tags                                                                                                                                                                                                                                                          |
| last_revision | 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                                                                                                                                                                                                                                                      |
| last_revision | tree_sitter_query [*required*] | string    | Tree-sitter query                                                                                                                                                                                                                                                  |
| last_revision | version_id [*required*]        | int64     | Monotonically increasing version number of the revision.                                                                                                                                                                                                           |
| attributes    | name [*required*]              | string    | Rule name                                                                                                                                                                                                                                                          |
| attributes    | revisions [*required*]         | [object]  | Revision history of the rule.                                                                                                                                                                                                                                      |
| revisions     | arguments [*required*]         | [object]  | Rule arguments                                                                                                                                                                                                                                                     |
| arguments     | description [*required*]       | string    | Base64-encoded argument description                                                                                                                                                                                                                                |
| arguments     | name [*required*]              | string    | Base64-encoded argument name                                                                                                                                                                                                                                       |
| revisions     | category [*required*]          | enum      | Rule category Allowed enum values: `SECURITY`, `BEST_PRACTICES`, `CODE_STYLE`, `ERROR_PRONE`, `PERFORMANCE`.                                                                                                                                                       |
| revisions     | checksum [*required*]          | string    | Code checksum                                                                                                                                                                                                                                                      |
| revisions     | code [*required*]              | string    | Rule code                                                                                                                                                                                                                                                          |
| revisions     | created_at [*required*]        | date-time | Creation timestamp                                                                                                                                                                                                                                                 |
| revisions     | created_by [*required*]        | string    | Creator identifier                                                                                                                                                                                                                                                 |
| revisions     | creation_message [*required*]  | string    | Revision creation message                                                                                                                                                                                                                                          |
| revisions     | cve                            | string    | Associated CVE. Omitted when the revision has no associated CVE.                                                                                                                                                                                                   |
| revisions     | cwe                            | string    | Associated CWE. Omitted when the revision has no associated CWE.                                                                                                                                                                                                   |
| revisions     | description [*required*]       | string    | Full description                                                                                                                                                                                                                                                   |
| revisions     | documentation_url              | string    | Documentation URL. Omitted when the revision has no documentation URL.                                                                                                                                                                                             |
| revisions     | id [*required*]                | string    | Revision identifier                                                                                                                                                                                                                                                |
| revisions     | is_published [*required*]      | boolean   | Whether the revision is published                                                                                                                                                                                                                                  |
| revisions     | is_testing [*required*]        | boolean   | Whether this is a testing revision                                                                                                                                                                                                                                 |
| revisions     | language [*required*]          | enum      | Programming language Allowed enum values: `PYTHON`, `JAVASCRIPT`, `TYPESCRIPT`, `JAVA`, `GO`, `YAML`, `RUBY`, `CSHARP`, `PHP`, `KOTLIN`, `SWIFT`, `DART`, `DOCKERFILE`, `ELIXIR`, `JSON`, `RUST`, `TERRAFORM`, `STARLARK`, `BASH`, `MARKDOWN`, `APEX`, `R`, `SQL`. |
| revisions     | severity [*required*]          | enum      | Rule severity Allowed enum values: `ERROR`, `WARNING`, `NOTICE`, `NONE`.                                                                                                                                                                                           |
| revisions     | short_description [*required*] | string    | Short description                                                                                                                                                                                                                                                  |
| revisions     | should_use_ai_fix [*required*] | boolean   | Whether to use AI for fixes                                                                                                                                                                                                                                        |
| revisions     | tags [*required*]              | [string]  | Rule tags                                                                                                                                                                                                                                                          |
| revisions     | 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                                                                                                                                                                                                                                                      |
| revisions     | tree_sitter_query [*required*] | string    | Tree-sitter query                                                                                                                                                                                                                                                  |
| revisions     | version_id [*required*]        | int64     | Monotonically increasing version number of the revision.                                                                                                                                                                                                           |
| data          | id [*required*]                | string    | Rule identifier                                                                                                                                                                                                                                                    |
| data          | type [*required*]              | enum      | Resource type Allowed enum values: `custom_rule`.                                                                                                                                                                                                                  |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "created_at": "2026-01-09T13:00:57.473141Z",
      "created_by": "foobarbaz",
      "last_revision": {
        "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",
        "id": "revision-123",
        "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==",
        "version_id": 1
      },
      "name": "my-rule",
      "revisions": [
        {
          "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",
          "id": "revision-123",
          "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==",
          "version_id": 1
        }
      ]
    },
    "id": "my-rule",
    "type": "custom_rule"
  }
}
```
{% /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       | 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": [
    {
      "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="401" %}
Unauthorized - custom rules not enabled

{% tabs %}
{% tab label="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 label="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 %}
{% /tabs %}
{% /tab %}

{% tab label="404" %}
Rule not found

{% tabs %}
{% tab label="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 label="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 %}
{% /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 ruleset_name="CHANGE_ME"
export rule_name="CHANGE_ME"

# 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/static-analysis/custom/rulesets/${ruleset_name}/rules/${rule_name}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"
```
{% /tab %}

{% tab label="Go" %}
```go
// Show Custom Rule returns "Successful response" response

package main

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

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

func main() {
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.GetCustomRule", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewStaticAnalysisApi(apiClient)
	resp, r, err := api.GetCustomRule(ctx, "ruleset_name", "rule_name")

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

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

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
```
{% /tab %}

{% tab label="Java" %}
```java
// Show Custom Rule returns "Successful response" 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.CustomRuleResponse;

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

    try {
      CustomRuleResponse result = apiInstance.getCustomRule("ruleset_name", "rule_name");
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling StaticAnalysisApi#getCustomRule");
      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://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
```
{% /tab %}

{% tab label="Python" %}
```python
"""
Show Custom Rule returns "Successful response" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.static_analysis_api import StaticAnalysisApi

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["get_custom_rule"] = True
with ApiClient(configuration) as api_client:
    api_instance = StaticAnalysisApi(api_client)
    response = api_instance.get_custom_rule(
        ruleset_name="ruleset_name",
        rule_name="rule_name",
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
```
{% /tab %}

{% tab label="Ruby" %}
```ruby
# Show Custom Rule returns "Successful response" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
  config.unstable_operations["v2.get_custom_rule".to_sym] = true
end
api_instance = DatadogAPIClient::V2::StaticAnalysisAPI.new
p api_instance.get_custom_rule("ruleset_name", "rule_name")
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
```
{% /tab %}

{% tab label="Rust" %}
```rust
// Show Custom Rule returns "Successful response" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_static_analysis::StaticAnalysisAPI;

#[tokio::main]
async fn main() {
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.get_custom_rule", true);
    let api = StaticAnalysisAPI::with_config(configuration);
    let resp = api
        .get_custom_rule("ruleset_name".to_string(), "rule_name".to_string())
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
```
{% /tab %}

{% tab label="TypeScript" %}
```typescript
/**
 * Show Custom Rule returns "Successful response" response
 */

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

const configuration = client.createConfiguration({
  authMethods: {
    AuthZ: {
      accessToken: process.env.DD_BEARER_TOKEN as string,
    },
  },
});
configuration.unstableOperations["v2.getCustomRule"] = true;
const apiInstance = new v2.StaticAnalysisApi(configuration);

const params: v2.StaticAnalysisApiGetCustomRuleRequest = {
  rulesetName: "ruleset_name",
  ruleName: "rule_name",
};

apiInstance
  .getCustomRule(params)
  .then((data: v2.CustomRuleResponse) => {
    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://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"
```
{% /tab %}
{% /tabs %}
