For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/api/latest/application-security/get-a-waf-policy.md. A documentation index is available at /llms.txt.

Get a WAF Policy

GET https://api.ap1.datadoghq.com/api/v2/remote_config/products/asm/waf/policies/{policy_id}https://api.ap2.datadoghq.com/api/v2/remote_config/products/asm/waf/policies/{policy_id}https://api.datadoghq.eu/api/v2/remote_config/products/asm/waf/policies/{policy_id}https://api.ddog-gov.com/api/v2/remote_config/products/asm/waf/policies/{policy_id}https://api.us2.ddog-gov.com/api/v2/remote_config/products/asm/waf/policies/{policy_id}https://api.uk1.datadoghq.com/api/v2/remote_config/products/asm/waf/policies/{policy_id}https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/policies/{policy_id}https://api.us3.datadoghq.com/api/v2/remote_config/products/asm/waf/policies/{policy_id}https://api.us5.datadoghq.com/api/v2/remote_config/products/asm/waf/policies/{policy_id}

Overview

Retrieve a WAF policy by ID.

Arguments

Path Parameters

Name

Type

Description

policy_id [required]

string

The ID of the policy.

Response

OK

Response object that includes a single WAF policy.

Expand All

Field

Type

Description

data

object

Object for a single WAF policy.

attributes

object

A WAF policy.

description [required]

string

Description of the WAF policy.

isDefault

boolean

Make this policy the default policy. The default policy is applied to every service not specifically assigned to another policy.

name [required]

string

The name of the WAF policy.

protectionPresets

[string]

Presets enabled on this policy.

rules

[object]

Rule overrides applied by the policy.

blocking [required]

boolean

When blocking is enabled, the rule will block the traffic matched by this rule.

enabled [required]

boolean

When false, this rule will not match any traffic.

extended_data_collection

boolean

When true, collects additional data from the WAF for this rule.

id [required]

string

Override the parameters for this WAF rule identifier.

rulesets

[object]

DEPRECATED: Deprecated: Ruleset overrides. Use protectionPresets instead.

blocking [required]

boolean

When blocking is enabled, the ruleset will block the traffic it matches.

enabled [required]

boolean

When false, this ruleset will not match any traffic.

id [required]

string

The identifier of the ruleset to override.

scope

[object]

The scope of the WAF policy.

env [required]

string

The environment scope for the WAF policy.

service [required]

string

The service scope for the WAF policy.

version

int64

Version of the WAF ruleset maintained by Datadog used by this policy. 0 is the default value.

id

string

The ID of the policy.

meta

object

Metadata associated with the WAF policy.

added_at

date-time

The date and time the WAF policy was created.

added_by

string

The handle of the user who created the WAF policy.

added_by_name

string

The name of the user who created the WAF policy.

modified_at

date-time

The date and time the WAF policy was last updated.

modified_by

string

The handle of the user who last updated the WAF policy.

modified_by_name

string

The name of the user who last updated the WAF policy.

type

enum

The type of the resource. The value should always be policy. Allowed enum values: policy

default: policy

{
  "data": {
    "attributes": {
      "description": "Policy applied to internal web applications.",
      "isDefault": false,
      "name": "Internal Network Policy",
      "protectionPresets": [
        "attack-tools"
      ],
      "rules": [
        {
          "blocking": false,
          "enabled": true,
          "extended_data_collection": false,
          "id": "rasp-001-002"
        }
      ],
      "rulesets": [
        {
          "blocking": false,
          "enabled": true,
          "id": "attack_tool"
        }
      ],
      "scope": [
        {
          "env": "prod",
          "service": "billing-service"
        }
      ],
      "version": 0
    },
    "id": "2857c47d-1e3a-4300-8b2f-dc24089c084b",
    "meta": {
      "added_at": "2021-01-01T00:00:00Z",
      "added_by": "john.doe@datadoghq.com",
      "added_by_name": "John Doe",
      "modified_at": "2021-01-01T00:00:00Z",
      "modified_by": "john.doe@datadoghq.com",
      "modified_by_name": "John Doe"
    },
    "type": "policy"
  }
}

Not Authorized

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

{
  "errors": [
    "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

                  # Path parameters
export policy_id="recommended"
# Curl command
curl -X GET "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.uk1.datadoghq.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.datadoghq.com/api/v2/remote_config/products/asm/waf/policies/${policy_id}" \ -H "Accept: application/json" \ -H "DD-API-KEY: ${DD_API_KEY}" \ -H "DD-APPLICATION-KEY: ${DD_APP_KEY}"
"""
Get a WAF Policy returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.application_security_api import ApplicationSecurityApi

# there is a valid "policy" in the system
POLICY_DATA_ID = environ["POLICY_DATA_ID"]

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = ApplicationSecurityApi(api_client)
    response = api_instance.get_application_security_waf_policy(
        policy_id=POLICY_DATA_ID,
    )

    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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
# Get a WAF Policy returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::ApplicationSecurityAPI.new

# there is a valid "policy" in the system
POLICY_DATA_ID = ENV["POLICY_DATA_ID"]
p api_instance.get_application_security_waf_policy(POLICY_DATA_ID)

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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
// Get a WAF Policy returns "OK" 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() {
	// there is a valid "policy" in the system
	PolicyDataID := os.Getenv("POLICY_DATA_ID")

	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewApplicationSecurityApi(apiClient)
	resp, r, err := api.GetApplicationSecurityWafPolicy(ctx, PolicyDataID)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `ApplicationSecurityApi.GetApplicationSecurityWafPolicy`:\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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
// Get a WAF Policy returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ApplicationSecurityApi;
import com.datadog.api.client.v2.model.ApplicationSecurityPolicyResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    ApplicationSecurityApi apiInstance = new ApplicationSecurityApi(defaultClient);

    // there is a valid "policy" in the system
    String POLICY_DATA_ID = System.getenv("POLICY_DATA_ID");

    try {
      ApplicationSecurityPolicyResponse result =
          apiInstance.getApplicationSecurityWafPolicy(POLICY_DATA_ID);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println(
          "Exception when calling ApplicationSecurityApi#getApplicationSecurityWafPolicy");
      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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
// Get a WAF Policy returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_application_security::ApplicationSecurityAPI;

#[tokio::main]
async fn main() {
    // there is a valid "policy" in the system
    let policy_data_id = std::env::var("POLICY_DATA_ID").unwrap();
    let configuration = datadog::Configuration::new();
    let api = ApplicationSecurityAPI::with_config(configuration);
    let resp = api
        .get_application_security_waf_policy(policy_data_id.clone())
        .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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
/**
 * Get a WAF Policy returns "OK" response
 */

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

const configuration = client.createConfiguration();
const apiInstance = new v2.ApplicationSecurityApi(configuration);

// there is a valid "policy" in the system
const POLICY_DATA_ID = process.env.POLICY_DATA_ID as string;

const params: v2.ApplicationSecurityApiGetApplicationSecurityWafPolicyRequest =
  {
    policyId: POLICY_DATA_ID,
  };

apiInstance
  .getApplicationSecurityWafPolicy(params)
  .then((data: v2.ApplicationSecurityPolicyResponse) => {
    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.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"