[Yandex Cloud documentation](../../index.md) > [Yandex SmartCaptcha](../index.md) > [Step-by-step guides](index.md) > Deleting a CAPTCHA

# Deleting a CAPTCHA

In this section, you will learn how to delete a [CAPTCHA](../concepts/validation.md).

{% list tabs group=instructions %}

- Management console {#console}

    1. In the [management console](https://console.yandex.cloud), select a folder.
    1. Navigate to **SmartCaptcha**.
    1. Select the CAPTCHA and click ![image](../../_assets/console-icons/ellipsis.svg) → **Delete**.
    1. Confirm the deletion.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. See the description of the CLI command for deleting a CAPTCHA:

      ```bash
      yc smartcaptcha captcha delete --help
      ```

  1. Getting a list of available CAPTCHAs:
     
     ```bash
     yc smartcaptcha captcha list
     ```
     
     Result:
     
     ```text
     +----------------------+---------+---------------------+------------+----------------+----------------+-------------+
     |          ID          |  NAME   |       CREATED       | COMPLEXITY | PRE-CHECK TYPE | CHALLENGE TYPE | RULES COUNT |
     +----------------------+---------+---------------------+------------+----------------+----------------+-------------+
     | bpne29ifsca8******** | test    | 2025-02-24 17:16:13 | MEDIUM     | CHECKBOX       | IMAGE_TEXT     |           0 |
     | bpnm7lhokq2t******** | prod    | 2025-02-26 09:12:02 | MEDIUM     | CHECKBOX       | IMAGE_TEXT     |           0 |
     | bpn43btuo4g9******** | website | 2025-02-26 09:12:42 | MEDIUM     | CHECKBOX       | IMAGE_TEXT     |           0 |
     +----------------------+---------+---------------------+------------+----------------+----------------+-------------+
     ```
  1. Delete the CAPTCHA by running the CLI command with its name or ID specified:

      ```bash
      yc smartcaptcha captcha delete <CAPTCHA_name_or_ID>
      ```

      Result:
      
      ```text
      id: bpnd6cm6qpr5********
      folder_id: b1g0ijbfaqsn********
      cloud_id: b1gia87mbaom********
      client_key: ysc1_2lla0Yn6dhlnEaTv2QNg2BhuA8Nqlyk4L7pZk3dz********
      created_at: "2025-03-02T21:38:48.830498Z"
      name: my-first-captcha
      allowed_sites:
        - exmaple.ru
        - exmaple.kz
      complexity: MEDIUM
      style_json: '{"focus-color":"rgb(250, 192, 0)","base-background-color":"#fff"}'
      turn_off_hostname_check: true
      pre_check_type: CHECKBOX
      challenge_type: IMAGE_TEXT
      security_rules:
        - name: rule1
          priority: "11"
          description: My first security rule.
          condition:
            host:
              hosts:
                - exact_match: example.com
                - exact_match: example.net
          override_variant_uuid: variant-1
        - name: rule2
          priority: "12"
          condition:
            source_ip:
            geo_ip_match:
              locations:
                - ru
                - kz
          override_variant_uuid: variant-2
      override_variants:
        - uuid: variant-1
          description: override variant 1
          complexity: EASY
          pre_check_type: CHECKBOX
          challenge_type: SILHOUETTES
        - uuid: variant-2
          description: override variant 2
          complexity: HARD
          pre_check_type: SLIDER
          challenge_type: KALEIDOSCOPE
      ```

- Terraform {#tf}

   With [Terraform](https://www.terraform.io/), you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.
   
   Terraform is distributed under the [Business Source License](https://github.com/hashicorp/terraform/blob/main/LICENSE). The [Yandex Cloud provider for Terraform](https://github.com/yandex-cloud/terraform-provider-yandex) is distributed under the [MPL-2.0](https://www.mozilla.org/en-US/MPL/2.0/) license.
   
   For more information about the provider resources, see the relevant documentation on the [Terraform](https://www.terraform.io/docs/providers/yandex/index.html) website or [its mirror](../../terraform/index.md).

   If you do not have Terraform yet, [install it and configure the Yandex Cloud provider](../../tutorials/infrastructure-management/terraform-quickstart.md#install-terraform).
   
   
   To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), [authenticate](../../terraform/authentication.md) using the appropriate method.

   To delete a CAPTCHA created with Terraform:

   1. Open the Terraform configuration file and delete the section describing the `yandex_smartcaptcha_captcha` resource:

      {% cut "Terraform CAPTCHA configuration example" %}

      ```hcl
      resource "yandex_smartcaptcha_captcha" "<captcha_name>" {
        name                    = "<captcha_name>"
        turn_off_hostname_check = True
        complexity              = "<challenge_difficulty>"
        pre_check_type          = "<main_challenge_type>"
        challenge_type          = "<additional_challenge_type>"
      
        style_json = jsonencode({
          light    = jsonencode(<json_object>)
          dark = jsonencode(<json_object>)
        })
      
        allowed_sites = [
          "<first_host>",
          "<second_host>"
        ]
      
        # First challenge variant
        override_variant {
          uuid        = "<variant_1_ID>"
          description = "<option_1_description>"
      
          complexity     = "<challenge_difficulty>"
          pre_check_type = "<main_challenge>"
          challenge_type = "<additional_challenge>"
        }
      
        # Second challenge variant 
        override_variant {
          uuid        = "<variant_2_ID"
          description = "<variant_2_description>"
      
          complexity     = "<challenge_difficulty>"
          pre_check_type = "<main_challenge>"
          challenge_type = "<additional_challenge>"
        }
      
        # First rule
        security_rule {
          name                  = "<rule_1_name>"
          priority              = <rule_1_priority>
          description           = "<rule_1_description>"
          override_variant_uuid = "<challenge_variant_ID>"
      
          condition {
            host {
              hosts {
                exact_match = "example.com"
              }
              hosts {
                exact_match = "example.net"
              }
            }
          }
        }
      
        # Second rule
        security_rule {
          name                  = "<rule_2_name>"
          priority              = <rule_2_priority>
          description           = "<rule_2_description>"
          override_variant_uuid = "<challenge_variant_ID>"
      
          condition {
            source_ip {
              geo_ip_match {
                locations = ["ru", "kz"]
              }
            }
          }
        }
      }
      ```

      {% endcut %}

   1. Apply the changes:
      
      1. In the terminal, navigate to the configuration file directory.
      1. Make sure the configuration is correct using this command:
      
         ```bash
         terraform validate
         ```
      
         If the configuration is valid, you will get this message:
      
         ```bash
         Success! The configuration is valid.
         ```
      
      1. Run this command:
      
         ```bash
         terraform plan
         ```
      
         You will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors in the configuration.
      1. Apply the configuration changes:
      
         ```bash
         terraform apply
         ```
      
      1. Type `yes` and press **Enter** to confirm the changes.
      
      You can verify that the resources have been deleted in the [management console](https://console.yandex.cloud) or using this [CLI](../../cli/index.md) command:

      ```bash
      yc smartcaptcha captcha list
      ```

- API {#api}

   To delete a CAPTCHA, use the [delete](../api-ref/Captcha/delete.md) REST API method for the [Captcha](../api-ref/Captcha/index.md) resource or the [Captcha/Delete](../api-ref/grpc/Captcha/delete.md) gRPC API call.

{% endlist %}

The [keys](../concepts/keys.md) of the deleted CAPTCHA will no longer be valid. All service requests made with these keys will return error.