[Yandex Cloud documentation](../../../index.md) > [Yandex Cloud CDN](../../index.md) > [Step-by-step guides](../index.md) > Resources > Setting up an HTTP response

# Setting up HTTP responses

A CDN resource can return a particular HTTP code and content instead of a standard response to all requests.

HTTP responses can be set up either globally or for a particular URI in [location rules](../../concepts/location-rules.md).

## Setting up a redirect {#redirect}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder where your resource is located.
  1. Navigate to **Cloud CDN**.
  1. Click the resource name.
  1. Navigate to the **HTTP headers and methods** tab.
  1. In the top-right corner, click ![image](../../../_assets/console-icons/pencil.svg) **Edit**.
  1. Under **Response settings**, enable **Custom HTTP response**.
  1. In the **Response type** field, select `Configure redirect`.
  1. Specify a response code.

      The following codes are supported: `301`, `302`, `303`, `307`, and `308`.

  1. Specify a URL to redirect user requests to.
  1. Click **Save**.

- REST API {#rest-api}

  To enable the option, add the `staticResponse` section when using the [create](../../api-ref/Resource/create.md) or [update](../../api-ref/Resource/update.md) method for a [Resource](../../api-ref/Resource/index.md):

  ```json
  "staticResponse": {
    "enabled": "<true_or_false>",
    "code": "string",
    "content": "string"
  }
  ```

  Where:

  * `enabled`: Enabling the option:
      * `true` enables the option.
      * `false` disables the option.

  * `code`: Response code.

      The following codes are supported: `301`, `302`, `303`, `307`, and `308`.

  * `content`: Specify a URL to redirect user requests to.

- gRPC API {#grpc-api}

  To enable the option, add the `static_response` section when using the [ResourceService/Create](../../api-ref/grpc/Resource/create.md) or [ResourceService/Update](../../api-ref/grpc/Resource/update.md) call:

  ```json
  "static_response": {
    "enabled": "<true_or_false>",
    "code": "string",
    "content": "string"
  }
  ```

  Where:

  * `enabled`: Enabling the option:
      * `true` enables the option.
      * `false` disables the option.

  * `code`: Response code.

      The following codes are supported: `301`, `302`, `303`, `307`, and `308`.

  * `content`: Specify a URL to redirect user requests to.

{% endlist %}

It may take up to 15 minutes for the new settings of the existing resource to apply to the CDN servers. After that, we recommend [purging the resource cache](purge-cache.md).


## Setting a response content {#content}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the folder where your resource is located.
  1. Navigate to **Cloud CDN**.
  1. Click the resource name.
  1. Navigate to the **HTTP headers and methods** tab.
  1. In the top-right corner, click ![image](../../../_assets/console-icons/pencil.svg) **Edit**.
  1. Under **Response settings**, enable **Custom HTTP response**.
  1. In the **Response type** field, select `Set response content`.
  1. Specify a response code.

      Codes from the [HTTP Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) are supported, except for those having `Unassigned` in the description.

  1. Specify JSON, HTML, or plain text you need to return to the client in the response body.
  1. Click **Save**.

- REST API {#rest-api}

  To enable the option, add the `staticResponse` section when using the [create](../../api-ref/Resource/create.md) or [update](../../api-ref/Resource/update.md) method for a [Resource](../../api-ref/Resource/index.md):

  ```json
  "staticResponse": {
    "enabled": "<true_or_false>",
    "code": "string",
    "content": "string"
  }
  ```

  Where:

  * `enabled`: Enabling the option:
      * `true` enables the option.
      * `false` disables the option.

  * `code`: Response code.

      Codes from the [HTTP Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) are supported, except for those having `Unassigned` in the description.

  * `content`: JSON, HTML, or plain text you need to return to the client in the response body.

- gRPC API {#grpc-api}

  To enable the option, add the `static_response` section when using the [ResourceService/Create](../../api-ref/grpc/Resource/create.md) or [ResourceService/Update](../../api-ref/grpc/Resource/update.md) call:

  ```json
  "static_response": {
    "enabled": "<true_or_false>",
    "code": "string",
    "content": "string"
  }
  ```

  Where:

  * `enabled`: Enabling the option:
      * `true` enables the option.
      * `false` disables the option.

  * `code`: Response code.

      Codes from the [HTTP Status Code Registry](https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml) are supported, except for those having `Unassigned` in the description.

  * `content`: JSON, HTML, or plain text you need to return to the client in the response body.

{% endlist %}

It may take up to 15 minutes for the new settings of the existing resource to apply to the CDN servers. After that, we recommend [purging the resource cache](purge-cache.md).