---
title: "POST /v1/{+parent}/deployPolicies"
method: POST
path: "/v1/{+parent}/deployPolicies"
tags: ["projects"]
---

# POST /v1/{+parent}/deployPolicies

`POST /v1/{+parent}/deployPolicies`

Creates a new DeployPolicy in a given project and location.

## Path parameters

- `parent` string, required

## Query parameters

- `deployPolicyId` string
- `requestId` string
- `validateOnly` boolean

## Request body

- DeployPolicy — A `DeployPolicy` resource in the Cloud Deploy API. A `DeployPolicy` inhibits manual or automation-driven actions within a Delivery Pipeline or Target.
  - `name` string — Output only. Name of the `DeployPolicy`. Format is `projects/{project}/locations/{location}/deployPolicies/{deployPolicy}`. The `deployPolicy` component must match `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`
  - `annotations` object — Optional. User annotations. These attributes can only be set and used by the user, and not by Cloud Deploy. Annotations must meet the following constraints: * Annotations are key/value pairs. * Valid annotation keys have two segments: an optional prefix and name, separated by a slash (`/`). * The name segment is required and must be 63 characters or less, beginning and ending with an alphanumeric character (`[a-z0-9A-Z]`) with dashes (`-`), underscores (`_`), dots (`.`), and alphanumerics between. * The prefix is optional. If specified, the prefix must be a DNS subdomain: a series of DNS labels separated by dots(`.`), not longer than 253 characters in total, followed by a slash (`/`). See https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set for more details.
  - `createTime` string, google-datetime — Output only. Time at which the deploy policy was created.
  - `labels` object — Labels are attributes that can be set and used by both the user and by Cloud Deploy. Labels must meet the following constraints: * Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. * All characters must use UTF-8 encoding, and international characters are allowed. * Keys must start with a lowercase letter or international character. * Each resource is limited to a maximum of 64 labels. Both keys and values are additionally constrained to be <= 128 bytes.
  - `rules` PolicyRule[] — Required. Rules to apply. At least one rule must be present.
    - `rolloutRestriction` RolloutRestriction — Rollout restrictions.
      - `actions` string[] — Optional. Rollout actions to be restricted as part of the policy. If left empty, all actions will be restricted.
      - `id` string — Required. Restriction rule ID. Required and must be unique within a DeployPolicy. The format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.
      - `invokers` string[] — Optional. What invoked the action. If left empty, all invoker types will be restricted.
      - `timeWindows` TimeWindows — Time windows within which actions are restricted. See the [documentation](https://cloud.google.com/deploy/docs/deploy-policy#dates_times) for more information on how to configure dates/times.
        - `oneTimeWindows` OneTimeWindow[] — Optional. One-time windows within which actions are restricted.
          - `endDate` Date — Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp
            - `year` integer — Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
            - `day` integer — Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
            - `month` integer — Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
          - `endTime` TimeOfDay — Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`.
            - `seconds` integer — Seconds of a minute. Must be greater than or equal to 0 and typically must be less than or equal to 59. An API may allow the value 60 if it allows leap-seconds.
            - `hours` integer — Hours of a day in 24 hour format. Must be greater than or equal to 0 and typically must be less than or equal to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
            - `minutes` integer — Minutes of an hour. Must be greater than or equal to 0 and less than or equal to 59.
            - `nanos` integer — Fractions of seconds, in nanoseconds. Must be greater than or equal to 0 and less than or equal to 999,999,999.
          - `startDate` Date — Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp
            - `year` integer — Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
            - `day` integer — Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
            - `month` integer — Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
          - `startTime` TimeOfDay — Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`.
            - `seconds` integer — Seconds of a minute. Must be greater than or equal to 0 and typically must be less than or equal to 59. An API may allow the value 60 if it allows leap-seconds.
            - `hours` integer — Hours of a day in 24 hour format. Must be greater than or equal to 0 and typically must be less than or equal to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
            - `minutes` integer — Minutes of an hour. Must be greater than or equal to 0 and less than or equal to 59.
            - `nanos` integer — Fractions of seconds, in nanoseconds. Must be greater than or equal to 0 and less than or equal to 999,999,999.
        - `timeZone` string — Required. The time zone in IANA format [IANA Time Zone Database](https://www.iana.org/time-zones) (e.g. America/New_York).
        - `weeklyWindows` WeeklyWindow[] — Optional. Recurring weekly windows within which actions are restricted.
          - `daysOfWeek` string[] — Optional. Days of week. If left empty, all days of the week will be included.
          - `endTime` TimeOfDay — Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`.
            - `seconds` integer — Seconds of a minute. Must be greater than or equal to 0 and typically must be less than or equal to 59. An API may allow the value 60 if it allows leap-seconds.
            - `hours` integer — Hours of a day in 24 hour format. Must be greater than or equal to 0 and typically must be less than or equal to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
            - `minutes` integer — Minutes of an hour. Must be greater than or equal to 0 and less than or equal to 59.
            - `nanos` integer — Fractions of seconds, in nanoseconds. Must be greater than or equal to 0 and less than or equal to 999,999,999.
          - `startTime` TimeOfDay — Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may choose to allow leap seconds. Related types are google.type.Date and `google.protobuf.Timestamp`.
            - `seconds` integer — Seconds of a minute. Must be greater than or equal to 0 and typically must be less than or equal to 59. An API may allow the value 60 if it allows leap-seconds.
            - `hours` integer — Hours of a day in 24 hour format. Must be greater than or equal to 0 and typically must be less than or equal to 23. An API may choose to allow the value "24:00:00" for scenarios like business closing time.
            - `minutes` integer — Minutes of an hour. Must be greater than or equal to 0 and less than or equal to 59.
            - `nanos` integer — Fractions of seconds, in nanoseconds. Must be greater than or equal to 0 and less than or equal to 999,999,999.
  - `updateTime` string, google-datetime — Output only. Most recent time at which the deploy policy was updated.
  - `suspended` boolean — Optional. When suspended, the policy will not prevent actions from occurring, even if the action violates the policy.
  - `etag` string — The weak etag of the `DeployPolicy` resource. This checksum is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
  - `selectors` DeployPolicyResourceSelector[] — Required. Selected resources to which the policy will be applied. At least one selector is required. If one selector matches the resource the policy applies. For example, if there are two selectors and the action being attempted matches one of them, the policy will apply to that action.
    - `deliveryPipeline` DeliveryPipelineAttribute — Contains criteria for selecting DeliveryPipelines.
      - `id` string — Optional. ID of the `DeliveryPipeline`. The value of this field could be one of the following: * The last segment of a pipeline name * "*", all delivery pipelines in a location
      - `labels` object — DeliveryPipeline labels.
    - `target` TargetAttribute — Contains criteria for selecting Targets. This could be used to select targets for a Deploy Policy or for an Automation.
      - `id` string — Optional. ID of the `Target`. The value of this field could be one of the following: * The last segment of a target name * "*", all targets in a location
      - `labels` object — Target labels.
  - `description` string — Optional. Description of the `DeployPolicy`. Max length is 255 characters.
  - `uid` string — Output only. Unique identifier of the `DeployPolicy`.

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/clouddeploy.md) · [All operations](https://skmtc.net/google/apis/clouddeploy/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/clouddeploy/versions/a8819765974a/schema)
