Configuration reference
The Traffic Policy configuration reference for this action.Supported phases
on_http_response
Type
response-body-find-replace
Configuration fields
Array of replacement rules to apply to the response body. Rules are applied in order.Minimum
1 replacement required.Regular expression pattern to match. Supports RE2 syntax.
CEL interpolation is supported for dynamic patterns.
Replacement string. Use
$1, $2, etc. to reference capture groups from the pattern.
CEL interpolation is supported for dynamic replacements.
If omitted or empty, matched text is deleted.Behavior
When this action executes, it buffers the entire response body, applies all replacement rules in order, and updates theContent-Length header if present.
Pattern matching
Thefrom field accepts RE2 regular expressions.
All matches in the body are replaced, not just the first occurrence.
Capture groups
You can use capture groups in your pattern and reference them in the replacement:CEL expressions
Bothfrom and to fields support CEL interpolation for dynamic values:
from field, the resulting string must be a valid regular expression.
Content-Length handling
After replacements are applied, the action automatically updates theContent-Length
header to reflect the new body size.
Ordering
Replacement rules are applied in the order they are specified. Later rules operate on the result of earlier rules.Examples
Redacting sensitive data from AI responses
The following configuration redacts personal information from AI model responses.Example Traffic Policy document
Example response
Before (original response body):Adding disclaimers to AI responses
Append legal disclaimers or warnings to AI-generated content:Sanitizing error messages
Remove internal error details from responses before sending to clients:Action result variables
The following variables are made available for use in subsequent expressions and CEL interpolations after the action has run. Variable values will only apply to the last action execution, results are not concatenated.Related actions
- Request Body Find & Replace - Modify request bodies
- SSE Find & Replace - Modify Server-Sent Events streams