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.
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:
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.
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
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
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'
Select exchanges according to HTTP status code.
Evaluation scope defines the timing where this filter will be applied.
responseHeaderReceivedFromRemote This scope occurs the moment fluxzy has done parsing the response header.
statusCodeFilter
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 |
This filter has no specific usage example
View definition of StatusCodeFilter for .NET integration.
The following filters are related to this 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.
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.
An empty list never matches. Always include at least one code, or use a class filter if you want every response in a range.
Yes, set inverted: true. The rule then fires every time the response code is not part of the list.