DataPower API
Gateway

redact - DataPower API Gateway

Use the redact policy to completely remove or to redact specified fields from the request body, the response body, and the activity logs. You might find this policy useful for removing or blocking out sensitive data (for example, credit card details) for legal, security, or other reasons.

Gateway support

Note: This page describes the redact policy implementation in the DataPower® API Gateway. If you are using the DataPower Gateway (v5 compatible), see redact - DataPower Gateway (v5 compatible).

For information on the different types of gateway, see API Connect gateway types.

Table 1. Table showing which gateways support this policy, and the corresponding policy version
Gateway Policy version
DataPower API Gateway 2.0.0

This topic describes how to configure the policy in your OpenAPI source; for details on how to configure the policy in the assembly user interface, see Redaction - DataPower API Gateway.

About

The redact policy has the following format:
- redact:
    version: version
    title: title
    description: description
    redactions:
      - action: remove_or_redact
        path: JSONata_expression_for_field_to_remove_or_redact
                .
                .
                .
    root: content_source
Note: With the DataPower API Gateway, the input to the redact policy must be parsed data. One way to produce parsed data is to use a parse policy before a redact policy in your assembly flow, which provides explicit control of the parse action.

Properties

The following table describes the properties of the redact policy.
Table 2. redact policy properties
Property Required Description Data type
version Yes The policy version number string
title No A title for the policy. string
description No A policy description. string
root No Specifies the data source that contains the content to which the redact or remove action applies. If the root property is omitted, the action is applied to the entire API context.

You can use any supported JSONata path expression.

If you want to apply the action to either request or response data, specify a value of message.body. The actual content to which the action is applied then depends on the positioning of the redact policy in the overall assembly flow; for example:
  • If positioned at the beginning, the action is applied to the client request.
  • If positioned after an invoke policy, the action is applied to the response from the back end.
  • If positioned at the end, the action is applied to the response that is returned to the client.

If, in your assembly flow, the redact policy is used after a log policy that specifies gather-only for the mode property, specify a root value of log.request_body for the logged request payload, or log.response_body for the logged response payload.

string
path Yes Specifies a JSONata path expression that identifies the fields to redact or remove from the source. For more information, see Constructing JSONata expressions to redact fields string
action Yes Specifies whether you want to remove or redact the content.
Supply one of the following values:
  • remove: Completely removes the specified fields.
  • redact: Redacts (obfuscates with "*"s) the fields to block out the data.

The default value is redact.

Note: If a numerical value is being redacted, the redacted value is depicted as ****** and the type is changed to string.
string

Example

# Specify separate remove and redact actions

- redact:
    version: 2.0.0
    title: remove price, redact author
    redactions:
      - action: remove
        path: xpath($, ''//price'')"
      - action: redact
        path: $.**.author"
    root: message.body