---
title: "POST /dns/v1/projects/{project}/responsePolicies/{responsePolicy}/rules"
method: POST
path: "/dns/v1/projects/{project}/responsePolicies/{responsePolicy}/rules"
tags: ["responsePolicyRules"]
---

# POST /dns/v1/projects/{project}/responsePolicies/{responsePolicy}/rules

`POST /dns/v1/projects/{project}/responsePolicies/{responsePolicy}/rules`

Creates a new Response Policy Rule.

## Path parameters

- `project` string, required
- `responsePolicy` string, required

## Query parameters

- `clientOperationId` string

## Request body

- ResponsePolicyRule — A Response Policy Rule is a selector that applies its behavior to queries that match the selector. Selectors are DNS names, which may be wildcards or exact matches. Each DNS query subject to a Response Policy matches at most one ResponsePolicyRule, as identified by the dns_name field with the longest matching suffix.
  - `ruleName` string — An identifier for this rule. Must be unique with the ResponsePolicy.
  - `dnsName` string — The DNS name (wildcard or exact) to apply this rule to. Must be unique within the Response Policy Rule.
  - `localData` ResponsePolicyRuleLocalData
    - `localDatas` ResourceRecordSet[] — All resource record sets for this selector, one per resource record type. The name must match the dns_name.
      - `kind` string
      - `name` string — For example, www.example.com.
      - `type` string — The identifier of a supported record type. See the list of Supported DNS record types.
      - `ttl` integer — Number of seconds that this `ResourceRecordSet` can be cached by resolvers.
      - `rrdatas` string[] — As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) -- see examples.
      - `signatureRrdatas` string[] — As defined in RFC 4034 (section 3.2).
      - `routingPolicy` RRSetRoutingPolicy — A RRSetRoutingPolicy represents ResourceRecordSet data that is returned dynamically with the response varying based on configured properties such as geolocation or by weighted random selection.
        - `geo` RRSetRoutingPolicyGeoPolicy — Configures a `RRSetRoutingPolicy` that routes based on the geo location of the querying user.
          - `items` RRSetRoutingPolicyGeoPolicyGeoPolicyItem[] — The primary geo routing configuration. If there are multiple items with the same location, an error is returned instead.
            - `rrdatas` string[]
            - `signatureRrdatas` string[] — DNSSEC generated signatures for all the `rrdata` within this item. When using health-checked targets for DNSSEC-enabled zones, you can only use at most one health-checked IP address per item.
            - `healthCheckedTargets` RRSetRoutingPolicyHealthCheckTargets — HealthCheckTargets describes endpoints to health-check when responding to Routing Policy queries. Only the healthy endpoints will be included in the response. Set either `internal_load_balancer` or `external_endpoints`. Do not set both.
              - …
            - `kind` string
            - `location` string — The geo-location granularity is a GCP region. This location string should correspond to a GCP region. e.g. "us-east1", "southamerica-east1", "asia-east1", etc.
          - `kind` string
          - `enableFencing` boolean — Without fencing, if health check fails for all configured items in the current geo bucket, we failover to the next nearest geo bucket. With fencing, if health checking is enabled, as long as some targets in the current geo bucket are healthy, we return only the healthy targets. However, if all targets are unhealthy, we don't failover to the next nearest bucket; instead, we return all the items in the current bucket even when all targets are unhealthy.
        - `kind` string
        - `primaryBackup` RRSetRoutingPolicyPrimaryBackupPolicy — Configures a RRSetRoutingPolicy such that all queries are responded with the primary_targets if they are healthy. And if all of them are unhealthy, then we fallback to a geo localized policy.
          - `primaryTargets` RRSetRoutingPolicyHealthCheckTargets — HealthCheckTargets describes endpoints to health-check when responding to Routing Policy queries. Only the healthy endpoints will be included in the response. Set either `internal_load_balancer` or `external_endpoints`. Do not set both.
            - `internalLoadBalancers` RRSetRoutingPolicyLoadBalancerTarget[] — Configuration for internal load balancers to be health checked.
              - …
            - `externalEndpoints` string[] — The Internet IP addresses to be health checked. The format matches the format of ResourceRecordSet.rrdata as defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1)
          - `backupGeoTargets` RRSetRoutingPolicyGeoPolicy — Configures a `RRSetRoutingPolicy` that routes based on the geo location of the querying user.
            - `items` RRSetRoutingPolicyGeoPolicyGeoPolicyItem[] — The primary geo routing configuration. If there are multiple items with the same location, an error is returned instead.
              - …
            - `kind` string
            - `enableFencing` boolean — Without fencing, if health check fails for all configured items in the current geo bucket, we failover to the next nearest geo bucket. With fencing, if health checking is enabled, as long as some targets in the current geo bucket are healthy, we return only the healthy targets. However, if all targets are unhealthy, we don't failover to the next nearest bucket; instead, we return all the items in the current bucket even when all targets are unhealthy.
          - `kind` string
          - `trickleTraffic` number, double — When serving state is `PRIMARY`, this field provides the option of sending a small percentage of the traffic to the backup targets.
        - `wrr` RRSetRoutingPolicyWrrPolicy — Configures a RRSetRoutingPolicy that routes in a weighted round robin fashion.
          - `items` RRSetRoutingPolicyWrrPolicyWrrPolicyItem[]
            - `healthCheckedTargets` RRSetRoutingPolicyHealthCheckTargets — HealthCheckTargets describes endpoints to health-check when responding to Routing Policy queries. Only the healthy endpoints will be included in the response. Set either `internal_load_balancer` or `external_endpoints`. Do not set both.
              - …
            - `kind` string
            - `weight` number, double — The weight corresponding to this `WrrPolicyItem` object. When multiple `WrrPolicyItem` objects are configured, the probability of returning an `WrrPolicyItem` object's data is proportional to its weight relative to the sum of weights configured for all items. This weight must be non-negative.
            - `rrdatas` string[]
            - `signatureRrdatas` string[] — DNSSEC generated signatures for all the `rrdata` within this item. When using health-checked targets for DNSSEC-enabled zones, you can only use at most one health-checked IP address per item.
          - `kind` string
        - `healthCheck` string — The fully qualified URL of the HealthCheck to use for this RRSetRoutingPolicy. Format this URL like `https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks/{healthCheck}`. https://cloud.google.com/compute/docs/reference/rest/v1/healthChecks
  - `behavior` 'behaviorUnspecified' | 'bypassResponsePolicy' — Answer this query with a behavior rather than DNS data.
  - `kind` string

## Response `200`

Successful response

---

[API](https://skmtc.dev/google/apis/dns.md) · [All operations](https://skmtc.dev/google/apis/dns/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/google/dns/revisions/7bb4167e3366/schema)
