Skip to main content
Products manages the agent’s product catalog: free-form JSON products keyed by an id you choose, listed with pagination and a Lua Query filter, or found by semantic search. Available in tools, jobs, webhooks, triggers, processors, and workflow code steps. A product goes into a basket by its id. Verified against lua-cli 3.33.0.

Quick example

Methods

get()

Returns one page of products, optionally filtered.
number
default:1
Page number, starting at 1.
number
default:10
Products per page.
LuaQuery
Matches product fields; see Lua Query. Options form only.
Returns
ProductPaginationInstance
An iterable page. It has no data property.
Example
ErrorsFailed to get products; No next page and No previous page from the paging helpers.

create()

Creates a product, or updates the product that already has the same id.
{ id: string; [key: string]: any }
required
id is your identifier (a SKU, a catalog id, a UUID you mint) and the only required field. Everything else is free-form.
Returns — the product as a ProductInstance. Example
ErrorsFailed to create product when the platform rejects the write.

delete()

Deletes a product by id.
Returns
boolean
true when the product was removed.
Example
ErrorsFailed to delete product when no product has that id. Returns up to five products semantically closest to a query.
string
required
Natural-language query.
Returns
ProductSearchInstance
An iterable result set with products, length, and the same array helpers as a page. No pagination, no data, and no limit argument: the platform returns at most five matches.
Example
ErrorsFailed to search products.

getById()

Returns one product by id.
Returns — the product as a ProductInstance. There is no null return: an unknown id throws. Example
ErrorsFailed to get product when no product has that id.

ProductInstance

The object create(), getById(), and the page and search results hold. Product fields are readable and writable directly (product.price) and through product.data; direct assignments stay local until save().
Product
The product object, including id.

update()

Merges fields into the product on the server and locally.
Returns — the updated product. ErrorsFailed to update product when the platform reports no update.

delete()

Deletes the product and empties the local data.
Returns — the emptied product object.

save()

Writes the whole local data to the server.
Returnstrue. Example
ErrorsFailed to save product data.

toJSON()

Returns data, which is what JSON.stringify(product) and console.log(product) print.

Types

ProductInstance is exported. Product ({ id: string; [key: string]: any }), ProductFilterOptions, ProductPaginationInstance, and ProductSearchInstance are not; name them from the method that returns them.

See also