[Yandex Cloud documentation](../../index.md) > [Yandex SmartCaptcha](../index.md) > [Step-by-step guides](index.md) > Migrating to the new condition format in the API, CLI, and Terraform

# Updating the condition format in the API, CLI, and Terraform

{% note warning %}

Starting June 9, 2026, Yandex SmartCaptcha will migrate to the new format of conditions and field names in captcha display rules. If using the API, CLI, or Terraform, update commands and configurations.

{% endnote %}

Earlier, multiple values in the `host` condition were provided as a list. Must now be entered in a single text field, separated by `|`.

The `hosts` field is also renamed to `host_matcher`.

## Updating current configurations {#existing-configurations}

All rules created in the old format will be automatically migrated to the new format. Your current settings will continue to apply correctly.

## Condition description format {matching-format}

#|
|| **Old format** | **New format** ||
|| `hosts`:

* example.com
* example.net | `host_matcher`:

example\\.com\|example\\.net ||
|#

If the old configuration uses different condition types for this field, combine them into a [regular expression](https://en.wikipedia.org/wiki/Regular_expression).

Example of different condition types in the old format:

```text
exact_match = example.com
exact_not_match = example.net
```

Example of combining conditions in the new format:

```text
"pireRegexMatch": "example\.com|~(example\.net)"
```

If special characters, such as `(`, `)`, `{`, `}`, `[`, `]`, `.`, `*`, `+`, `?`, `^`, `$`, `|`, `\`, `&`, or `~` are used as regular characters, escape them with `\`.

You can use `~` as logical negation.

## CLI update {#cli-updates}

1. [Update the CLI](../../cli/operations/update-cli.md) to the latest version:

   ```bash
   yc components update
   ```

1. View the new field format in the `create` and `update` commands:

   ```bash
   yc smartcaptcha captcha create -h
   yc smartcaptcha captcha update -h
   ```

## Examples of using the new field {#migration-examples}

{% list tabs group=instructions %}

- CLI {#cli}

  If you specify display rules in a command, use the new format:

  ```bash
    yc smartcaptcha captcha create \
    --name captcha \
    --security-rules '[
      {
        name = "captcha-rule",
        priority = 1,
        condition = {
          host = {
            host-matcher = {
              match = {
                pire-regex-match = "example.com|example.net"
              }
            }
          }
        }
      }
    ]'
  ```

  If you store captcha display rules in a YAML file, update the `host` condition field for the `--security-rules-file` parameter.

  For more information about the commands, see the CLI reference: [captcha create](../../cli/cli-ref/smartcaptcha/cli-ref/captcha/create.md) and [captcha update](../../cli/cli-ref/smartcaptcha/cli-ref/captcha/update.md).

- Terraform {#tf}

  In the Terraform configuration, replace the `hosts` section with `host_matcher`:

  ```hcl
  resource "yandex_smartcaptcha_captcha" "yandex-smartcaptcha-captcha" {
    name = "test-terraform-yandex-smartcaptcha-captcha"
    security_rule {
      name = "rule-condition-migration"
      priority = 1
      condition {
        host {
          host_matcher {
            pire_regex_match = "a|b"
          }
        }
      }
    }
  }
  ```

  For more on the properties of the `yandex_smartcaptcha_captcha` resource, see [this provider guide](../../terraform/resources/smartcaptcha_captcha.md).

- API {#api}

  Example of a request with the new field:

  ```bash
  curl -X POST \
    'https://smartcaptcha.api.cloud.yandex.net/smartcaptcha/v1/captchas' \
    -H "Authorization: Bearer $(yc iam create-token)" \
    -H 'Content-Type: application/json' \
    -d '{
      "folderId": "<folder_ID>",
      "name": "captcha",
      "securityRules": [
        {
          "name": "captcha-rule",
          "priority": 1,
          "condition": {
            "host": {
              "hostMatcher": {
                "pireRegexMatch": "a|b"
              }
            }
          }
        }
      ]
    }'
  ```

  For more information about the methods, see the REST API reference: [Captcha.Create](../api-ref/Captcha/create.md) and [Captcha.Update](../api-ref/Captcha/update.md) for the [Captcha](../api-ref/Captcha/index.md) resource.

{% endlist %}

#### Useful links {#see-also}

* [Creating a CAPTCHA](create-captcha.md)
* [Getting CAPTCHA details](get-info.md)
* [Verifying the CAPTCHA response](validate-captcha.md)