New Transparent capture is in preview. Record every app's traffic with no proxy configuration, on Windows, macOS and Linux. Learn more

statusCodeFilter Filter

Select exchanges whose response status code is one of an explicit list, useful when class level filters such as 4XX or 5XX are too broad.

statusCodeFilter is the precise selector when class level rules are too broad. Combine it with capture, header or tagging actions to react to specific status codes such as 401, 429 or 503 without affecting the rest of the response traffic.

When to use this filter

Use statusCodeFilter when you need to react to one or a few specific status codes rather than an entire 1XX, 2XX, 3XX, 4XX or 5XX class. The filter accepts a list of integers, which makes a single rule expressive enough to cover several codes that share an action.

Typical situations:

  • Reacting to 401 and 403 to surface authentication and authorization problems separately from generic 4XX traffic.
  • Capturing only 429 Too Many Requests responses to investigate a throttling incident.
  • Tagging 503 Service Unavailable independently from other 5XX codes that may have different causes.

The filter evaluates on the responseHeaderReceivedFromRemote scope, so the status code is available the moment the response line is parsed. Prefer the class scoped filters (statusCodeSuccessFilter, statusCodeClientErrorFilter, ...) when you do not need exact codes.

Real world examples

Tag every authentication failure

Apply a tag to any exchange that returned 401 Unauthorized or 403 Forbidden so you can correlate them in the timeline.

rules:
- filter:
    typeKind: StatusCodeFilter
    statusCodes:
    - 401
    - 403
  actions:
  - typeKind: ApplyTagAction
    tag:
      value: auth-failure

Capture rate limited responses

Send only 429 Too Many Requests responses to a dedicated capture so you can analyse the surrounding traffic without saving everything.

rules:
- filter:
    typeKind: StatusCodeFilter
    statusCodes:
    - 429
  actions:
  - typeKind: CaptureSessionAction

Inject a Retry-After header on 503

Add a Retry-After hint to any 503 response that does not already provide one, making the upstream behaviour more predictable for clients.

rules:
- filter:
    typeKind: StatusCodeFilter
    statusCodes:
    - 503
  actions:
  - typeKind: AddResponseHeaderAction
    headerName: Retry-After
    headerValue: '30'

Reference

statusCodeFilter

Description

Select exchanges according to HTTP status code.

Evaluation scope

Evaluation scope defines the timing where this filter will be applied.

responseHeaderReceivedFromRemote This scope occurs the moment fluxzy has done parsing the response header.

YAML configuration name

statusCodeFilter

Settings

The following table describes the customizable properties available for this filter:

Property Type Description DefaultValue
statusCodes list1 | List of status code | system.Collections.Generic.List1[System.Int32]
inverted boolean Negate the filter result false

Example of usage

This filter has no specific usage example

.NET reference

View definition of StatusCodeFilter for .NET integration.

See also

The following filters are related to this filter:

Frequently asked questions

Can I list status codes from different classes in the same filter?

Yes. The list is purely numerical, so 200, 304 and 429 can live in the same rule even though they belong to different status classes.

How is it different from statusCodeClientErrorFilter and friends?

The class filters cover an entire range such as 4XX. statusCodeFilter requires you to enumerate each code, which is more verbose but also more precise when a class is too broad.

What happens if statusCodes is empty?

An empty list never matches. Always include at least one code, or use a class filter if you want every response in a range.

Can I select responses outside of the listed codes?

Yes, set inverted: true. The rule then fires every time the response code is not part of the list.

Learn more about Fluxzy rules