[Yandex Cloud documentation](../../index.md) > [Yandex Serverless Containers](../index.md) > [Step-by-step guides](index.md) > Invoking a container > Invoking a container asynchronously

# Invoking a container asynchronously

{% note info %}

This feature is at the [Preview](../../overview/concepts/launch-stages.md) stage.

{% endnote %}

## Configure asynchronous invocation {#async}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the [folder](../../resource-manager/concepts/resources-hierarchy.md#folder) with your [container](../concepts/container.md).
  1. Navigate to **Serverless Containers**.
  1. Select the container whose [revision](../concepts/container.md#revision) you want to create.
  1. Navigate to the **Editor** tab.
  1. Under **Asynchronous invocation**:

      1. Enable asynchronous invocation.
      1. Specify a service account with the `serverless-containers.containerInvoker` [role](../security/index.md#serverless-containers-containerinvoker) for asynchronous invocations.

  1. Click **Create revision**.

- 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.

    To configure asynchronous invocation, run this command:

    ```bash
    yc serverless container revision deploy \
      --container-name <container_name> \
      --image <Docker_image_URL> \
      --service-account-id <service_account_ID> \
      --async-service-account-id <ID_of_service_account_for_asynchronous_invocations>
    ```


    Where:

    * `--service-account-id`: [ID of the service account](../../iam/operations/sa/get-id.md) with the `serverless-containers.editor` [role](../security/index.md#serverless-containers-editor) or higher.
    * `--async-service-account-id`: ID of the service account with the `serverless-containers.containerInvoker` [role](../security/index.md#serverless-containers-containerinvoker) for asynchronous invocations.

    Result:

    ```text
    done (6s)
    id: bba1r76l8f73********
    container_id: bbado1g2mtqj********
    created_at: "2025-09-08T12:03:32.797Z"
    image:
      image_url: cr.yandex/crpmfvcgnl26********/ubuntu:hello
      image_digest: sha256:96ab2d89a82fcfc63e24b9ef26de8b3b11ed1043cec41d4359a8de8b********
    resources:
      memory: "134217728"
      cores: "1"
      core_fraction: "100"
    execution_timeout: 3s
    concurrency: "1"
    service_account_id: ajelprpohp7r********
    status: ACTIVE
    log_options:
      folder_id: b1g681qpemb4********
    runtime:
      http: {}
    async_invocation_config:
      service_account_id: ajeaim70pe1u********
    ```

- 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 guides 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 configure asynchronous invocation:

  1. Open the Terraform configuration file and add the `async_invocation` section to the container description:

      ```hcl
      resource "yandex_serverless_container" "test-container" {
        name               = "<container_name>"
        memory             = "<RAM_amount>"
        execution_timeout  = "<execution_timeout>"
        service_account_id = "<service_account_ID>"

        image {
          url = <container_image_path>
        }

        async_invocation {
          service_account_id = "<service_account_ID>"
        }
      }
      ```

      Where:

      * `async_invocation`: Asynchronous invocation settings:

          * `service_account_id`: Service account with the `serverless-containers.containerInvoker` [role](../security/index.md#serverless-containers-containerinvoker).

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

  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 check the container update and settings using the [management console](https://console.yandex.cloud) or this [CLI](../../cli/quickstart.md) command:

  ```bash
  yc serverless serverless-container revision get <container_revision_ID>
  ```

- API {#api}

  To configure asynchronous invocation, use the [deployRevision](../containers/api-ref/Container/deployRevision.md) REST API method for the [Container](../containers/api-ref/Container/index.md) resource or the [ContainerService/DeployRevision](../containers/api-ref/grpc/Container/deployRevision.md) gRPC API call.

{% endlist %}


## Invoke the container {#invoke}

When [invoking](invoke.md) the container over HTTP, specify the `X-Ycf-Container-Integration-Type: async` header.


## Useful links {#see-also}

* [Asynchronous container invocation](../concepts/invoke-async.md)