Unify Logo Footer.svg
API Manager
Logo
Custom Policy

Custom Policy

Logo

4 mins READ

Run your own automation as part of the API request pipeline to enforce governance rules that built-in policy types cannot cover.

Overview

Custom Policy connects an automation you have built to the request pipeline. When the API Manager receives a call, it runs your automation either before the request reaches the backing resource (API Filter) or after the resource returns a response (Outbound API Policy Filter). Your automation decides whether to allow the call to proceed and can modify the request or response in any way your business logic requires.

Use custom policies when standard governance needs — rate limiting, CORS, JWT validation, IP control — are not enough. Common scenarios include bespoke authorization against an internal system, dynamic request enrichment from a database, or response redaction based on caller context.

Custom Policy configuration panel showing Filter Type and Automation fields

custom_policy.png
custom_policy.png
custom_policy-1.png
custom_policy-1.png

API Filter and Outbound API Policy Filter

A Custom Policy runs in one of two directions, selected when you create the policy:

API Filter

An API Filter is an inbound policy — it runs before the backing resource is invoked. Your automation receives the incoming request including headers, body, query parameters, and caller metadata. It returns whether to proceed or reject:

  • If it returns proceed, the request (with any modifications the automation applied) continues to the next policy in the chain or to the backing resource.

  • If it returns reject, the chain stops immediately. The backing resource is never invoked, and the caller receives the error response your automation specifies.

Use API Filters for custom authorization checks, dynamic header enrichment before the backing automation runs, or any pre-processing logic specific to your organization.

Outbound API Policy Filter

An Outbound API Policy Filter is an outbound policy — it runs after the backing resource has produced a response. Your automation receives both the original request and the response (body, status code, and headers). It can modify what is returned to the caller but cannot reject a completed invocation.

Use Outbound API Policy Filters for response masking or redaction based on caller context, adding computed metadata to the response body, or removing sensitive fields before the response leaves the gateway.

Field Reference

Field

Description

Policy Name *

A unique identifier used across logs, dashboards, and policy attachment configurations.

Tags

Custom labels to organize and filter the policy by environment, team, or functionality.

Filter Type *

The direction the automation runs. Select API Filter to intercept the incoming request before the backing resource, or Outbound API Policy Filter to process the response after the backing resource returns.

Automation *

The callable automation to invoke. The automation receives the request context (and, for Outbound API Policy Filters, the response context) and must return a proceed or reject decision along with any request or response modifications.

How It Works

  1. Policy chain reached — the platform reaches the Custom Policy's position in the policy execution order.

  2. Automation invoked — the selected automation runs, receiving the full request context (and response context, for Outbound API Policy Filters).

  3. Decision returned — the automation returns a proceed or reject signal, along with any modifications to the request or response it wants to apply.

  4. Chain continues or stops — a proceed signal passes the modified request to the next policy or to the backing resource. A reject signal stops the chain and returns the error to the caller.

  5. Response path — for Outbound API Policy Filters, the modified response is passed back through the remainder of the outbound chain before being returned to the caller.

Attaching to an API Group

Once a Custom Policy is created, attach it to one or more API Groups, Endpoints, or Access Profiles from their respective policy settings. Drag policies into the desired execution order when multiple policies are applied at the same level. API Filter policies run before the backing resource on every matched call; Outbound API Policy Filters run after.

Notes

  • Use built-in policy types (rate limiting, CORS, JWT validation, IP control) for standard API gateway concerns — they are optimized for those cases. Reserve custom policies for business-specific logic that the built-in types cannot express.

  • Keep automation logic fast — a Custom Policy runs synchronously on every matched API call, and its latency is added to the caller's response time.

  • If the automation errors or times out, the request is rejected with a server error. Test the automation thoroughly before attaching it to a production API Group.

  • An API Filter automation has access to the full incoming request; an Outbound API Policy Filter automation has access to both the request and the response.

FAQs

What is the difference between an API Filter and an Outbound API Policy Filter?

An API Filter runs before the backing resource is invoked and can accept, reject, or modify the incoming request. An Outbound API Policy Filter runs after the backing resource returns a response and can modify the outgoing response. Use API Filter for pre-processing and access control; use Outbound API Policy Filter for post-processing and response shaping.

Can a Custom Policy reject a request?

An API Filter automation can return a reject decision, which immediately stops the policy chain and returns an error to the caller — the backing resource is never invoked. Outbound API Policy Filters run after the resource has already responded, so they can modify but not reject a completed invocation.

What data does my automation receive?

For an API Filter, the automation receives the full incoming request — headers, body, query parameters, path, HTTP method, and caller metadata. For an Outbound API Policy Filter, it additionally receives the response body, status code, and response headers from the backing resource.

How is a Custom Policy different from a Request Transformer?

A Request Transformer modifies specific request fields — headers, body, parameters — using a declarative field-by-field configuration with no custom code. A Custom Policy runs a full automation, giving you access to external systems, conditional logic, and any transformation the platform can express. Use Request Transformer for straightforward field operations; use Custom Policy when you need to call another system or apply complex business logic.