Skip to main content
Feedback

JSONPath selector for flow & quota configurations

Our advanced configuration system allows you to use JSONPath expressions to dynamically extract values from both the request and response objects of an API call. This capability enable flow and quotas configurations to be defined based on properties which reside within the API call.

Overview

When an API call is processed, it is broken down into two main objects:

  • $.request – Contains details about the outgoing API request sent by your service.
  • $.response – Contains details about the incoming API response sent to your API provider.

Within these objects, several properties are exposed so that you can tailor your flow or quota strategies to almost any aspect of the API call. By using JSONPath expressions, you can directly reference nested values within these objects.

Supported JSONPath objects and properties

Below is an overview of the primary objects and their accessible sub-properties.

$.request

This object represents the incoming API request and may include:

  • headers
    The complete set of HTTP headers sent with the request.

  • body
    The payload or data contained in the request. This could be in JSON, form-data, and so on.

  • url
    The full URL string of the request.

  • url.path_parameter
    Any parameters extracted from the URL path (for example, /users/{id}).

  • url.query_parameter
    Key/value pairs representing the query parameters in the URL.

  • method
    The HTTP method used for the request (for example, GET, POST, PUT).

  • timestamp
    The time at which the request was sent. This can be useful for rate-limiting or logging purposes.

$.response

This object represents the API response and may include:

  • headers
    The HTTP headers included in the response.

  • body
    The response payload. When the API returns JSON data, you can extract values directly from it.

  • status_code The HTTP status code indicating the result of the API call.

  • duration
    The time taken to process the request, which might be useful for performance-based configurations.

Using JSONPath in configurations

By specifying a JSONPath expression in your configuration (for instance, in the counter_value_path field of a quota definition), you instruct the system to extract a specific value from either the request or response. This allows you to set quotas or control flows based on dynamic properties—such as token consumption, payload size, or any other measurable attribute.

Example configuration snippet

Below is an illustrative example demonstrating how you might configure a quota that references a value from the API response.

quotas:
- id: custom-quota
filter:
url: api.example.com/v1/data
strategy:
fixed_window_custom_counter:
max: 1000
interval: 1
interval_unit: minute
counter_value_path: |
$.response.body.usage.token_count

In this example, the counter_value_path is set to $.response.body.usage.token_count, which means the quota will be evaluated based on the numeric value found at that JSONPath in the API response.

On this Page