Enhanced REST API Response Filtering
Starting 25A release, the REST API framework supports applying default response filters automatically to the endpoint if one is defined in format $ENDPOINT_ID_$REGISTRY. Please note that there would be no change in the way custom filter keys work and this wouldn't impact any existing filterKeys defined.
This enhancement simplifies the process of using filterKeys to optimize response payload by eliminating the need to modify existing API invocations and reducing the overhead typically involved in modifying the current implementation.
Steps to Enable
Create a new response filter in the following format "$ENDPOINT_ID_$REGISTRY" by invoking the createFilter API (POST: /ccadmin/v1/responseFilters). Please refer to this document for more information on responseFilters.
ENDPOINT_ID represents the REST API ID, such as listSkus, getSku etc.
REGISTRY represents the application registry. Possible values are 'admin','store','agent'.
Sample Payloads to create new response filters using createFilter API:
- Creating a filter key for the listSkus API with the store registry
{
"exclude": "items.parentProducts.relatedProducts",
"key": "listSkus_store"
} - Creating a filter key for the getSku API with the store registry
{
"exclude":"parentProducts.relatedProducts.CountryOfOrigin,parentProducts.relatedProducts.active,parentProducts.relatedProducts.addOnProducts",
"key": "getSku_store"
}
Similar default response filtering configuration can be applied on other API’s to reduce payload size.