Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Yandex SmartCaptcha
  • Getting started
    • All guides
    • Creating a CAPTCHA
    • Deleting a CAPTCHA
    • Obtaining the keys
    • Advanced method of adding the widget
    • Verifying the CAPTCHA response
    • Viewing operations on service resources
    • Migrating to the new condition format in the API, CLI, and Terraform
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Updating current configurations
  • Condition description format
  • Updating the CLI
  • Examples of using the new field
  1. Step-by-step guides
  2. Migrating to the new condition format in the API, CLI, and Terraform

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

Written by
Yandex Cloud
Updated at June 18, 2026
  • Updating current configurations
  • Condition description format
  • Updating the CLI
  • Examples of using the new field

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 your commands and configurations.

Earlier, multiple values in the host condition were provided as a list. Now you need to combine such values into a single text field, separated by |.

The hosts field is also renamed to host_matcher.

Updating current configurationsUpdating current configurations

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

Condition description format {matching-format}Condition description 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.

Example of different condition types in the old format:

exact_match = example.com
exact_not_match = example.net

Example of combining conditions in the new format:

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

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

The ~ symbol can be used as logical negation.

Updating the CLIUpdating the CLI

  1. Update the CLI to the latest version:

    yc components update
    
  2. View the new field format in the create and update commands:

    yc smartcaptcha captcha create -h
    yc smartcaptcha captcha update -h
    

Examples of using the new fieldExamples of using the new field

CLI
Terraform
API

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

  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 and captcha update.

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

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 yandex_smartcaptcha_captcha properties, see this provider guide.

Example of a request with the new field:

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 on methods, see the REST API reference: Captcha.Create and Captcha.Update for the Captcha resource.

See alsoSee also

  • Creating a CAPTCHA
  • Getting CAPTCHA details
  • Verifying the CAPTCHA response

Was the article helpful?

Previous
Viewing operations on service resources
Next
All tutorials
© 2026 Direct Cursus Technology L.L.C.