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.
ProductPaginationInstance
An iterable page. It has no
data property.Failed 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 sameid.
{ 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.ProductInstance.
Example
Failed to create product when the platform rejects the write.
delete()
Deletes a product by id.boolean
true when the product was removed.Failed to delete product when no product has that id.
search()
Returns up to five products semantically closest to a query.string
required
Natural-language query.
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.Failed to search products.
getById()
Returns one product by id.ProductInstance. There is no null return: an unknown id throws.
Example
Failed to get product when no product has that id.
ProductInstance
The objectcreate(), 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.Failed to update product when the platform reports no update.
delete()
Deletes the product and empties the localdata.
save()
Writes the whole localdata to the server.
true.
Example
Failed to save product data.
toJSON()
Returnsdata, 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
Baskets— add products to a basket byidOrders— orders created from a basket- Lua Query — the filter
get()accepts - Commerce REST API — the same catalog over HTTP

