---
title: "Create a new Automation Rule for an Environment."
method: POST
path: "/orgs/{orgId}/apps/{appId}/envs/{envId}/rules"
tags: ["public", "AutomationRule"]
---

# Create a new Automation Rule for an Environment.

`POST /orgs/{orgId}/apps/{appId}/envs/{envId}/rules`

Items marked as deprecated are still supported (however not recommended) for use and are incompatible with properties of the latest api version. In particular an error is raised if  `images_filter` (deprecated) and `artefacts_filter` are used in the same payload. The same is true for `exclude_images_filter` (deprecated) and `exclude_artefacts_filter`. `match` and `update_to` are still supported but will trigger an error if combined with `match_ref`.

## Path parameters

- `orgId` string, required
- `appId` string, required
- `envId` string, required

## Request body

- AutomationRuleRequest — An Automation Rule defining how and when artefacts in an environment should be updated.
  - `active` boolean — Whether the rule will be processed or not.
  - `artefacts_filter` string[] — A list of artefact names to be processed by the rule. If the array is empty, it implies include all. If `exclude_artefacts_filter` is true, this list describes the artefacts to exclude.
  - `exclude_artefacts_filter` boolean — Whether the artefacts specified in `artefacts_filter` should be excluded (true) or included (false) in the automation rule.
  - `exclude_images_filter` boolean — DEPRECATED: Whether the images specified in `images_filter` should be excluded (true) or included (false) in the automation rule.
  - `images_filter` string[] — DEPRECATED: A list of image IDs to be processed by the rule. If the array is empty, it implies include all. If `exclude_images_filter` is true, this list describes images to exclude.
  - `match` string — DEPRECATED: A regular expression applied to the branch or tag name depending on the value of `update_to`. Defaults to match all if omitted or empty.
  - `match_ref` string — A regular expression applied to the ref of a new artefact version. Defaults to match all if omitted or empty.
  - `type` string, required — Specifies the type of event. Currently, only updates to either branches or tags are supported. Must be `"update"`.
  - `update_to` string — DEPRECATED: Specifies whether the update occurs on commit to branch or creation of tag. Must be one of `"branch"` or `"tag"`.

## Response `201`

The Automation Rule that was created.

- AutomationRuleResponse — An Automation Rule defining how and when artefacts in an environment should be updated.
  - `active` boolean, required — Whether the rule will be processed or not.
  - `artefacts_filter` string[], required — A list of artefact names to be processed by the rule. If the array is empty, it implies include all. If `exclude_artefacts_filter` is true, this list describes the artefacts to exclude.
  - `created_at` string, date-time, required — The timestamp in UTC of when the Automation Rule was created.
  - `exclude_artefacts_filter` boolean, required — Whether the artefacts specified in `artefacts_filter` should be excluded (true) or included (false) in the automation rule.
  - `exclude_images_filter` boolean, required — DEPRECATED: Whether the images specified in `images_filter` should be excluded (true) or included (false) in the automation rule.
  - `id` string, required — The unique ID for this rule.
  - `images_filter` string[], required — DEPRECATED: A list of image IDs to be processed by the rule. If the array is empty, it implies include all. If `exclude_images_filter` is true, this list describes images to exclude.
  - `match` string, required — DEPRECATED: A regular expression applied to the branch or tag name depending on the value of `update_to`. Defaults to match all if omitted or empty.
  - `match_ref` string, required — A regular expression applied to the ref of a new artefact version. Defaults to match all if omitted or empty.
  - `type` string, required — Specifies the type of event. Currently, only updates to either branches or tags are supported. Must be `"update"`.
  - `update_to` string, required — DEPRECATED: Specifies whether the update occurs on commit to branch or creation of tag. Must be one of `"branch"` or `"tag"`.
  - `updated_at` string, date-time, required — The timestamp in UTC of when the Automation Rule was updated.

## Other responses

- `400` — The request was invalid. More detail can be found in the error body.
- `409` — The request itself is valid however it could not be applied based on the current state of the resource. More detail can be found in the error body.
- `422` — Server understands the content type of the request, and the syntax of the request is correct, but it was unable to process the contained instructions

---

[API](https://skmtc.net/humanitec/apis/humanitec-api.md) · [All operations](https://skmtc.net/humanitec/apis/humanitec-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/humanitec/humanitec-api/revisions/e21ad140ec3c/schema)
