Skip to main content
Version: 1.0.x

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, etc.

  • url
    The full URL string of the request.

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

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

  • method
    The HTTP method used for the request (e.g., 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 (separate from the examples elsewhere in our docs) 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.