---
title: "Create deployment rule"
method: POST
path: "/api/v2/deployment_gates/{gate_id}/rules"
tags: ["Deployment Gates"]
---

# Create deployment rule

`POST /api/v2/deployment_gates/{gate_id}/rules`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/deployment_gates/{gate_id}/rules`
- Auth: API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`

Endpoint to create a deployment rule. A gate for the rule must already exist.

## Path parameters

- `gate_id` string, required

## Request body

- CreateDeploymentRuleParams: Parameters for creating a deployment rule.
  - `data` CreateDeploymentRuleParamsData: Parameters for creating a deployment rule.
    - `attributes` CreateDeploymentRuleParamsDataAttributes, required: Parameters for creating a deployment rule.
      - `dry_run` boolean: Whether this rule is run in dry-run mode.
      - `name` string, required: The name of the deployment rule.
      - `options` union, required: Options for deployment rule response representing either faulty deployment detection or monitor options.
        - DeploymentRuleOptionsFaultyDeploymentDetection: Faulty deployment detection options for deployment rules.
          - `duration` integer: The duration for faulty deployment detection.
          - `excluded_resources` string[]: Resources to exclude from faulty deployment detection.
        - DeploymentRuleOptionsMonitor: Monitor options for deployment rules.
          - `duration` integer: Seconds the monitor needs to stay in OK status for the rule to pass.
          - `query` string, required: Monitors that match this query are evaluated.
      - `type` string, required: The type of the deployment rule (faulty_deployment_detection or monitor).
    - `type` 'deployment_rule', required: Deployment rule resource type.

## Response `200`

OK

- DeploymentRuleResponse: Response for a deployment rule.
  - `data` DeploymentRuleResponseData: Data for a deployment rule.
    - `attributes` DeploymentRuleResponseDataAttributes, required: Basic information about a deployment rule.
      - `created_at` string, date-time, required: The timestamp when the deployment rule was created.
      - `created_by` DeploymentRuleResponseDataAttributesCreatedBy, required: Information about the user who created the deployment rule.
        - `handle` string: The handle of the user who created the deployment rule.
        - `id` string, required: The ID of the user who created the deployment rule.
        - `name` string: The name of the user who created the deployment rule.
      - `dry_run` boolean, required: Whether this rule is run in dry-run mode.
      - `gate_id` string, required: The ID of the deployment gate.
      - `name` string, required: The name of the deployment rule.
      - `options` union, required: Options for deployment rule response representing either faulty deployment detection or monitor options.
        - DeploymentRuleOptionsFaultyDeploymentDetection: Faulty deployment detection options for deployment rules.
          - `duration` integer: The duration for faulty deployment detection.
          - `excluded_resources` string[]: Resources to exclude from faulty deployment detection.
        - DeploymentRuleOptionsMonitor: Monitor options for deployment rules.
          - `duration` integer: Seconds the monitor needs to stay in OK status for the rule to pass.
          - `query` string, required: Monitors that match this query are evaluated.
      - `type` 'faulty_deployment_detection' | 'monitor', required: The type of the deployment rule.
      - `updated_at` string, date-time: The timestamp when the deployment rule was last updated.
      - `updated_by` DeploymentRuleResponseDataAttributesUpdatedBy: Information about the user who updated the deployment rule.
        - `handle` string: The handle of the user who updated the deployment rule.
        - `id` string, required: The ID of the user who updated the deployment rule.
        - `name` string: The name of the user who updated the deployment rule.
    - `id` string, required: Unique identifier of the deployment rule.
    - `type` 'deployment_rule', required: Deployment rule resource type.

## Other responses

- `400`: Bad request.
- `401`: Unauthorized
- `403`: Forbidden
- `429`: Too many requests
- `500`: Internal Server Error

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/da68bf029e4c?raw)
