---
title: SwitchFilter
description: Verifies that a specified condition is met. If the condition is met or no condition is specified, the request is diverted to the associated handler, with no further processing by the switch filter.
component: pinggateway
version: 2026
page_id: pinggateway:reference:SwitchFilter
canonical_url: https://docs.pingidentity.com/pinggateway/2026/reference/SwitchFilter.html
revdate: 2025-08-26T18:26:39Z
section_ids:
  SwitchFilter-usage: Usage
  SwitchFilter-properties: Properties
  SwitchFilter-example: Example
---

# SwitchFilter

Verifies that a specified condition is met. If the condition is met or no condition is specified, the request is diverted to the associated handler, with no further processing by the switch filter.

## Usage

```none
{
    "name": string,
    "type": "SwitchFilter",
    "config": {
        "onRequest": [
            {
                "condition": runtime condition<boolean>,
                "handler": Handler reference
            },
            ...
        ],
        "onResponse": [
            {
                "condition": runtime condition<boolean>,
                "handler": Handler reference
            },
            ...
        ]
    }
}
```

## Properties

* `"onRequest"`: *array of [objects](preface.html#definition-object), optional*

  Conditions to test (and handler to dispatch to, if `true`) before the request is handled.

* `"onResponse"`: *array of [objects](preface.html#definition-object), optional*

  Conditions to test (and handler to dispatch to, if `true`) after the response is handled.

* `"condition"`: *runtime condition<[boolean](preface.html#definition-boolean)>, optional*

  A flag defined using a [condition](Conditions.html) to indicate that a condition is met:

  * `true`: The request is dispatched to the handler.

  * `false`: The request is not dispatched to the handler, and the next condition in the list is tried.

    When the expression of the last condition in the list returns `false`, PingGateway passes the request to the next filter or handler in the chain.

  Default: `true`

* `"handler"`: *Handler [reference](preface.html#definition-reference), required*

  The [Handler](Handlers.html) to which PingGateway dispaches the request if the associated condition yields `true`.

  Provide the name of a Handler object defined in the heap or an inline Handler configuration object.

## Example

This example intercepts the response if it is equal to 200 and executes the LoginRequestHandler. This filter might be used in a login flow where the request for the login page must go through to the target, but the response should be intercepted in order to send the login form to the application. This is typical for scenarios where there is a hidden value or cookie returned in the login page, which must be sent in the login form:

```json
{
    "name": "SwitchFilter",
    "type": "SwitchFilter",
    "config": {
        "onResponse": [
            {
                "condition": "${response.status.code == 200}",
                "handler": "LoginRequestHandler"
            }
        ]
    }
}
```
