---
title: "Create Consume Policy for Virtual Cluster"
method: POST
path: "/v1/event-gateways/{gatewayId}/virtual-clusters/{virtualClusterId}/consume-policies#MaskFields"
tags: ["Event Gateway Virtual Cluster Consume Policies"]
---

# Create Consume Policy for Virtual Cluster

`POST /v1/event-gateways/{gatewayId}/virtual-clusters/{virtualClusterId}/consume-policies#MaskFields`

## Request

- Base URL: `https://global.api.konghq.com`
- URL: `https://global.api.konghq.com/v1/event-gateways/{gatewayId}/virtual-clusters/{virtualClusterId}/consume-policies#MaskFields`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer

Creates a new consume policy associated with the specified Event Gateway virtual cluster.

## Query parameters

- `before` string, uuid
- `after` string, uuid

## Request body

- EventGatewayParsedRecordMaskFieldsConsumePolicyCreate: Redacts string fields of parsed Kafka records using a configurable masking strategy. Only string fields may be selected. Selecting a field that does not exist is ignored; selecting a field that is not a string is a policy error handled by `failure_mode`. Note this policy can only be used as a child of a `EventGatewayConsumeSchemaValidationPolicy` policy. **Requires a minimum runtime version of `1.3`**.
  - `type` 'mask_fields', required: The type name of the policy.
  - `name` string: A unique user-defined name of the policy.
  - `description` string: A human-readable description of the policy.
  - `enabled` boolean: Whether the policy is enabled.
  - `labels` Labels: Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types. Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".
  - `config` EventGatewayParsedRecordMaskFieldsConsumeConfig, required: The configuration of the mask parsed record fields consume policy.
    - `failure_mode` 'error' | 'skip' | 'passthrough' | 'mark', required: Describes how to handle a failure in a policy applied to consumed records. * `error` - the batch is not delivered to the client. Use sparingly: erroring on a batch causes clients to get stuck on the problematic offset and requires manual intervention to skip it. * `skip` - the record is not delivered to the client. * `passthrough` - passes the record to the client even though policy execution failed. * `mark` - passes the record to the client but marks it with a `kong/policy-failure-<id>` header whose value is the reason for the policy failure (truncated to 512 characters). **Requires a minimum runtime version of `1.2`**.
    - `mask_fields` EventGatewayParsedRecordMaskSelector[], required: Selects which fields to mask and how to mask them.
      - `strategy` union, required: The strategy used to redact a matched field value.
        - EventGatewayMaskStrategyKeepChars: Keeps a number of leading and/or trailing characters and replaces the middle with a fixed phrase. If `first + last` is greater than or equal to the value length, the whole value is replaced with the phrase, so it never shows more characters than the original value. The phrase is fixed, so the masked output does not leak the value length.
          - `type` 'keep_chars', required
          - `first` integer: Number of leading characters to keep unmasked.
          - `last` integer: Number of trailing characters to keep unmasked.
          - `phrase` string, required: The phrase that replaces the masked middle of the value.
        - EventGatewayMaskStrategyEmail: Masks an email address by applying a separate strategy to the local part and to the domain.
          - `type` 'email', required
          - `local_part` union, required: The strategy used to redact the local part of an email address.
            - EventGatewayMaskStrategyKeepChars: Keeps a number of leading and/or trailing characters and replaces the middle with a fixed phrase. If `first + last` is greater than or equal to the value length, the whole value is replaced with the phrase, so it never shows more characters than the original value. The phrase is fixed, so the masked output does not leak the value length.
              - …
            - EventGatewayMaskStrategyReplace: Replaces the whole value with a fixed phrase. The masked length does not reflect the original value length.
              - …
          - `domain` union, required: The strategy used to redact the domain of an email address.
            - EventGatewayMaskStrategyKeepChars: Keeps a number of leading and/or trailing characters and replaces the middle with a fixed phrase. If `first + last` is greater than or equal to the value length, the whole value is replaced with the phrase, so it never shows more characters than the original value. The phrase is fixed, so the masked output does not leak the value length.
              - …
            - EventGatewayMaskEmailDomainKeepAll: Keeps the whole domain unmasked.
              - …
            - EventGatewayMaskStrategyReplace: Replaces the whole value with a fixed phrase. The masked length does not reflect the original value length.
              - …
        - EventGatewayMaskStrategyReplace: Replaces the whole value with a fixed phrase. The masked length does not reflect the original value length.
          - `type` 'replace', required
          - `phrase` string, required: The phrase to replace the value with.
      - `paths` object[], required
        - `match` string, required: A field selector. It can select nested fields and array entries. Currently supported are exact matches.
  - `condition` string: A string containing the boolean expression that determines whether the policy is applied. When the policy is applied as a child policy of schema_validation, the expression can also reference `record.value` fields.
  - `parent_policy_id` string, uuid, required: The unique identifier of the parent schema validation policy.

## Response `201`

Created

- EventGatewayPolicy: A policy associated with an Event Gateway.
  - `type` string, required: The type name of the policy.
  - `name` string: A unique user-defined name of the policy.
  - `description` string: A human-readable description of the policy.
  - `enabled` boolean: Whether the policy is enabled.
  - `labels` Labels: Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types. Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".
  - `id` string, uuid, required: The unique identifier of the policy.
  - `config` object, nullable: The configuration of the policy.
  - `created_at` string, date-time, required: An ISO-8601 timestamp representation of entity creation date.
  - `parent_policy_id` string, uuid, nullable: The unique identifier of the parent policy, if any.
  - `updated_at` string, date-time, required: An ISO-8601 timestamp representation of entity update date.
  - `condition` string: A string containing the boolean expression that determines whether the policy is applied.

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden

## Changes

- **2026-11-05** `f018071a4515`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/kong/apis/konnect-api/changes/v1/event-gateways/:gatewayId/virtual-clusters/:virtualClusterId/consume-policies%23MaskFields/post.md)

---

[API](https://skmtc.dev/kong/apis/konnect-api.md) - [All operations](https://skmtc.dev/kong/apis/konnect-api/llms.txt) - [OpenAPI document](https://skmtc.dev/kong/apis/konnect-api/revisions/f018071a4515?raw)
