Set max age for recommended items

You can set a maximum allowed age for the items recommended. Note that this feature will work only if you are sharing the published_time in the inventory metadata. For more on sharing that information, see the fields with timestamps section of Defining your Inventory.

You need to specify the maximum age in seconds with the field name maxAgeInSeconds inside the opts of your query. Here is how you would make such a query if you want to limit results to 1 day old:

$p('register', {
                  max: 10, // Large number requested so you can see our full range of items
                  widget: 'default-widget', // name of widget
                  opts: {maxAgeInSeconds: 86400},
                  callback: function(resp) {
                    console.log(JSON.stringify(resp, null, 2));
                    console.log("// TEST.");

Since the restrictions are placed separately for each registered widget, you have the flexibility of setting different restrictions based on the widget, as well as changing the age restrictions over time.

Corresponding option for model query API endpoint

If using the model query API endpoint, you can pass the maximum age in seconds with the parameter name maxAgeInseconds. For more details, see the model query API endpoint documentation.