---
title: "POST /v1/projects/{projectsId}/firewallpolicies"
method: POST
path: "/v1/projects/{projectsId}/firewallpolicies"
tags: ["projects"]
---

# POST /v1/projects/{projectsId}/firewallpolicies

`POST /v1/projects/{projectsId}/firewallpolicies`

## Request

- Base URL: `https://recaptchaenterprise.googleapis.com`
- URL: `https://recaptchaenterprise.googleapis.com/v1/projects/{projectsId}/firewallpolicies`
- Auth: OAuth 2 and OAuth 2
  - Implicit: `https://accounts.google.com/o/oauth2/auth`
  - Scopes: `https://www.googleapis.com/auth/cloud-platform`
  - Authorization code: `https://accounts.google.com/o/oauth2/auth`
  - Token URL: `https://accounts.google.com/o/oauth2/token` scopes: `https://www.googleapis.com/auth/cloud-platform`

Creates a new FirewallPolicy, specifying conditions at which reCAPTCHA Enterprise actions can be executed. A project may have a maximum of 1000 policies.

## Path parameters

- `projectsId` string, required

## Request body

- GoogleCloudRecaptchaenterpriseV1FirewallPolicy: A FirewallPolicy represents a single matching pattern and resulting actions to take.
  - `actions` GoogleCloudRecaptchaenterpriseV1FirewallAction[]: Optional. The actions that the caller should take regarding user access. There should be at most one terminal action. A terminal action is any action that forces a response, such as `AllowAction`, `BlockAction` or `SubstituteAction`. Zero or more non-terminal actions such as `SetHeader` might be specified. A single policy can contain up to 16 actions.
    - `allow` GoogleCloudRecaptchaenterpriseV1FirewallActionAllowAction: An allow action continues processing a request unimpeded.
    - `block` GoogleCloudRecaptchaenterpriseV1FirewallActionBlockAction: A block action serves an HTTP error code a prevents the request from hitting the backend.
    - `includeRecaptchaScript` GoogleCloudRecaptchaenterpriseV1FirewallActionIncludeRecaptchaScriptAction: An include reCAPTCHA script action involves injecting reCAPTCHA JavaScript code into the HTML returned by the site backend. This reCAPTCHA script is tasked with collecting user signals on the requested web page, issuing tokens as a cookie within the site domain, and enabling their utilization in subsequent page requests.
    - `redirect` GoogleCloudRecaptchaenterpriseV1FirewallActionRedirectAction: A redirect action returns a 307 (temporary redirect) response, pointing the user to a reCAPTCHA interstitial page to attach a token.
    - `setHeader` GoogleCloudRecaptchaenterpriseV1FirewallActionSetHeaderAction: A set header action sets a header and forwards the request to the backend. This can be used to trigger custom protection implemented on the backend.
      - `key` string: Optional. The header key to set in the request to the backend server.
      - `value` string: Optional. The header value to set in the request to the backend server.
    - `substitute` GoogleCloudRecaptchaenterpriseV1FirewallActionSubstituteAction: A substitute action transparently serves a different page than the one requested.
      - `path` string: Optional. The address to redirect to. The target is a relative path in the current host. Example: "/blog/404.html".
  - `condition` string: Optional. A CEL (Common Expression Language) conditional expression that specifies if this policy applies to an incoming user request. If this condition evaluates to true and the requested path matched the path pattern, the associated actions should be executed by the caller. The condition string is checked for CEL syntax correctness on creation. For more information, see the [CEL spec](https://github.com/google/cel-spec) and its [language definition](https://github.com/google/cel-spec/blob/master/doc/langdef.md). A condition has a max length of 500 characters.
  - `description` string: Optional. A description of what this policy aims to achieve, for convenience purposes. The description can at most include 256 UTF-8 characters.
  - `name` string: Identifier. The resource name for the FirewallPolicy in the format `projects/{project}/firewallpolicies/{firewallpolicy}`.
  - `path` string: Optional. The path for which this policy applies, specified as a glob pattern. For more information on glob, see the [manual page](https://man7.org/linux/man-pages/man7/glob.7.html). A path has a max length of 200 characters.

## Response `200`

Successful response

- GoogleCloudRecaptchaenterpriseV1FirewallPolicy: A FirewallPolicy represents a single matching pattern and resulting actions to take.
  - `actions` GoogleCloudRecaptchaenterpriseV1FirewallAction[]: Optional. The actions that the caller should take regarding user access. There should be at most one terminal action. A terminal action is any action that forces a response, such as `AllowAction`, `BlockAction` or `SubstituteAction`. Zero or more non-terminal actions such as `SetHeader` might be specified. A single policy can contain up to 16 actions.
    - `allow` GoogleCloudRecaptchaenterpriseV1FirewallActionAllowAction: An allow action continues processing a request unimpeded.
    - `block` GoogleCloudRecaptchaenterpriseV1FirewallActionBlockAction: A block action serves an HTTP error code a prevents the request from hitting the backend.
    - `includeRecaptchaScript` GoogleCloudRecaptchaenterpriseV1FirewallActionIncludeRecaptchaScriptAction: An include reCAPTCHA script action involves injecting reCAPTCHA JavaScript code into the HTML returned by the site backend. This reCAPTCHA script is tasked with collecting user signals on the requested web page, issuing tokens as a cookie within the site domain, and enabling their utilization in subsequent page requests.
    - `redirect` GoogleCloudRecaptchaenterpriseV1FirewallActionRedirectAction: A redirect action returns a 307 (temporary redirect) response, pointing the user to a reCAPTCHA interstitial page to attach a token.
    - `setHeader` GoogleCloudRecaptchaenterpriseV1FirewallActionSetHeaderAction: A set header action sets a header and forwards the request to the backend. This can be used to trigger custom protection implemented on the backend.
      - `key` string: Optional. The header key to set in the request to the backend server.
      - `value` string: Optional. The header value to set in the request to the backend server.
    - `substitute` GoogleCloudRecaptchaenterpriseV1FirewallActionSubstituteAction: A substitute action transparently serves a different page than the one requested.
      - `path` string: Optional. The address to redirect to. The target is a relative path in the current host. Example: "/blog/404.html".
  - `condition` string: Optional. A CEL (Common Expression Language) conditional expression that specifies if this policy applies to an incoming user request. If this condition evaluates to true and the requested path matched the path pattern, the associated actions should be executed by the caller. The condition string is checked for CEL syntax correctness on creation. For more information, see the [CEL spec](https://github.com/google/cel-spec) and its [language definition](https://github.com/google/cel-spec/blob/master/doc/langdef.md). A condition has a max length of 500 characters.
  - `description` string: Optional. A description of what this policy aims to achieve, for convenience purposes. The description can at most include 256 UTF-8 characters.
  - `name` string: Identifier. The resource name for the FirewallPolicy in the format `projects/{project}/firewallpolicies/{firewallpolicy}`.
  - `path` string: Optional. The path for which this policy applies, specified as a glob pattern. For more information on glob, see the [manual page](https://man7.org/linux/man-pages/man7/glob.7.html). A path has a max length of 200 characters.

---

[API](https://skmtc.dev/google/apis/recaptchaenterprise.md) - [All operations](https://skmtc.dev/google/apis/recaptchaenterprise/llms.txt) - [OpenAPI document](https://skmtc.dev/google/apis/recaptchaenterprise/revisions/26f34c638048?raw)
