Skip to content

Extract Webhook Payload Data with JSON Paths

When you configure a webhook producer endpoint in Relayter, you map incoming JSON payload data to Relayter fields using JSON Path notation. JSON Paths let you navigate nested structures and extract specific values from complex payloads.

JSON Path basics

JSON Path uses dot notation and bracket notation to navigate through JSON objects and arrays:

json
{
  "name": "Product Name",
  "details": {
    "price": 99.99,
    "sku": "ABC123"
  },
  "tags": ["featured", "sale"]
}
  • name — selects the "name" field
  • details.price — navigates into the details object to select price
  • tags.0 — selects the first item in the tags array (zero-indexed)

Filtering arrays

To search within arrays of objects, use filter syntax to find items matching specific conditions:

items[?status=active]

This filters the items array to include only objects where the status field equals "active".

The result of a filter is always an array, even if only one item matches. To access a specific property from filtered results, add it after the filter:

items[?status=active].title

This extracts the title field from each item in the filtered results, returning an array like ["Title 1", "Title 2"].

Supported comparison operators

Relayter supports six comparison operators for filtering:

  • = — equals
  • != — not equals
  • > — greater than
  • >= — greater than or equal
  • < — less than
  • <= — less than or equal

Filter examples

Match exact values:

products[?enabled=true]

Numeric comparisons:

campaigns[?budget>=1000]

Multiple conditions:

items[?status=active&priority>=2]

Filters the items array to only include objects where status equals "active" AND priority is greater than or equal to 2. Conditions are joined with & (AND logic).

Date range filtering:

events[?start_date<=2025-03-20&end_date>=2025-03-20]

This finds all events that include a specific date in their range.

Array indexing

Access specific items in an array using zero-based indexing:

tags.0        # First item
campaigns.2   # Third item

This is useful when you know the structure of your payload and always need a specific array element.

Array flattening

Extract a single property from all objects in an array to create a simplified list:

products.id

This extracts the id field from every object in the products array, giving you an array of just the IDs:

json
[
  "prod-123",
  "prod-456",
  "prod-789"
]

Building effective JSON Paths

Tips for success

  1. Always check your JSON payload structure first — understand the exact nesting and field names before building a path.
  2. Test with sample data — if your webhook producer provides sample payloads, use them to verify your JSON Path extracts the correct values.
  3. Remember zero-based indexing — arrays start at index 0, not 1.
  4. Use exact field names — JSON is case-sensitive; Name and name are different fields.
  5. Account for data types — Date comparisons require the exact stored format (e.g., ISO 8601 dates must match exactly).

Common patterns

Extract a product ID from a nested payload:

body.data.product_id

Find the titles of all active campaigns:

campaigns[?status=active].title

Returns an array of titles from only the active campaigns.

Get a specific item by index from filtered results:

campaigns[?status=active].0.title

Filters campaigns by status, then gets the title of the first matching campaign.

Collect all prices from products:

products.price

Extracts the price field from every product in the array.

Find products within a price range:

products[?price>=10&price<=50].name

Gets product names where the price is between $10 and $50.