﻿---
title: Create rules using the YAML editor
description: Define {{alerting-v2}} rules as YAML for version control, infrastructure-as-code, and bulk provisioning.
url: https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/5528/explore-analyze/alerting/kibana-alerting-v2/rules/create-rule-with-yaml-v2
products:
  - Kibana
applies_to:
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Unavailable
---

# Create rules using the YAML editor
The YAML editor lets you define rules as text documents rather than filling in a form. Use it when you want to version-control rule definitions alongside your other configuration, manage rules through infrastructure-as-code tooling, copy or adapt a rule quickly without re-entering settings by hand, or provision many rules at once.
If you're creating a rule from scratch and want guidance through each setting, the [rule builder](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/5528/explore-analyze/alerting/kibana-alerting-v2/rules/create-rule-from-rule-builder-v2) is the better starting point. If you have a query already working in Discover, you can [create a rule directly from there](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/5528/explore-analyze/alerting/kibana-alerting-v2/rules/create-rule-from-discover-v2).
For the full list of supported YAML fields and their accepted values, refer to [YAML rule schema reference](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/5528/explore-analyze/alerting/kibana-alerting-v2/rules/yaml-rule-schema-reference-v2).