---
title: AssignmentFilter
description: Verifies that a specified condition is met. If the condition is met or if no condition is specified, the value is assigned to the target. Values can be assigned before the request is handled and after the response is handled.
component: pinggateway
version: 2026
page_id: pinggateway:reference:AssignmentFilter
canonical_url: https://docs.pingidentity.com/pinggateway/2026/reference/AssignmentFilter.html
revdate: 2026-02-23T12:00:00Z
section_ids:
  AssignmentFilter-usage: Usage
  AssignmentFilter-properties: Properties
  AssignmentFilter-example: Examples
  AssignmentFilter-example-addinfo: Add info to a session
  AssignmentFilter-example-capturecred: Capture and store login credentials
---

# AssignmentFilter

Verifies that a specified condition is met. If the condition is met or if no condition is specified, the value is assigned to the target. Values can be assigned before the request is handled and after the response is handled.

## Usage

```none
{
  "name": string,
  "type": "AssignmentFilter",
  "config": {
    "onRequest": [
      {
        "condition": runtime condition<boolean>,
        "target": lvalue-expression,
        "value": runtime expression
      }, ...
    ],
    "onResponse": [
      {
        "condition": runtime condition<boolean>,
        "target": lvalue-expression,
        "value": runtime expression
      }, ...
    ]
  }
}
```

## Properties

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

  Defines a list of assignment bindings to evaluate before the request is handled.

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

  Defines a list of assignment bindings to evaluate after the response is handled.

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

  A [condition](Conditions.html). If the condition's expression evaluates to `true`, PingGateway assigns the value to the target.

  Default: `true`

* `"target"`: *<[lvalue-expression](preface.html#definition-lvalue-expression)>, required*

  Expression that yields the target object whose value is to be set.

* `"value"`: *runtime expression<[object](preface.html#definition-object)> , optional*

  The value to be set in the target. The value can be a string, information from the context, or even a whole map of information.

## Examples

### Add info to a session

The following example assigns a value to a session to keep empty JWT-based session cookies:

```json
{
  "type": "AssignmentFilter",
  "config": {
    "onRequest": [{
      "target": "${session.authUsername}",
      "value": "I am root"
    }]
  }
}
```

### Capture and store login credentials

The following example captures credentials and stores them in the PingGateway session during a login request. Notice that the credentials are captured on the request but aren't marked as valid until the response returns a positive 302. The credentials could then be used to log a user in to a different application:

```json
{
  "name": "PortalLoginCaptureFilter",
  "type": "AssignmentFilter",
  "config": {
    "onRequest": [
      {
        "target": "${session.authUsername}",
        "value": "${request.queryParams['username'][0]}"
      },
      {
        "target": "${session.authPassword}",
        "value": "${request.queryParams['password'][0]}"
      },
      {
        "comment": "Authentication has not yet been confirmed.",
        "target": "${session.authConfirmed}",
        "value": "${false}"
      }
    ],
    "onResponse": [
      {
        "condition": "${response.status.code == 302}",
        "target": "${session.authConfirmed}",
        "value": "${true}"
      }
    ]
  }
}
```
