githubEdit

Filtering Portal Resources by Custom Metadata

Use customer_resources_filters to control which resources are visible to customers in a portal, based on custom_metadata on property_listings and reservations.

When creating a customer portal, you can use the customer_resources_filters parameter to control which resources (property listings, reservations) are visible to the customer. Filters match against the custom_metadata you set on resources in customer_data.


How It Works

  1. Tag resources with custom_metadata — when passing property_listings or reservations in customer_data, include a custom_metadata object with key-value pairs on each resource.

  2. Set customer_resources_filters when creating the portal — provide an array of filter objects that specify which custom_metadata values a resource must have to be visible.

  3. Filtering is enforced server-side — the customer portal only returns resources whose custom_metadata matches all specified filters.


Filter Structure Reference

Each filter in the customer_resources_filters array is an object with the following fields:

Field
Type
Description

field

String

The custom_metadata field name to filter on. Must start with a letter or underscore and contain only alphanumeric characters and underscores.

operation

String

The comparison operation. Currently only "=" (equals) is supported.

value

String or Boolean

The value to compare against.


Key Behaviors

  • AND logic — when multiple filters are provided, a resource must match all of them to be visible.

  • Exact match — the = operation performs an exact match against the custom_metadata value.

  • Server-side enforcement — filtering happens on the server. The customer portal API only returns matching resources.

  • Field name rules — field names must match the regex ^[a-zA-Z_]\w*$ (start with a letter or underscore, followed by alphanumeric characters or underscores).


Examples

Example 1: Filtering Property Listings by Region

Create property listings with a region field in custom_metadata, then filter to show only European properties.

Example 2: Multiple Filters (AND Logic)

When you provide multiple filters, a resource must match all of them. Here, only property listings that are both premium and in Europe are shown.

Example 3: Boolean Filters

Filter by a boolean custom_metadata value, such as showing only premium listings.

Example 4: Filtering Reservations

Filters also apply to reservations. Here, only reservations that are both premium and in Europe are shown.


Verifying Filters

After creating a portal, you can verify the configured filters by retrieving the portal via the customer API. The response includes customer_resources_filters in the portal configuration.

The response will include the filters you configured:

Last updated

Was this helpful?