Guides and Examples
...
Products
Fetching Customer Products
11 min
this guide covers the customer scoped product catalog endpoint ( get /customers/{customerid}/products ), which returns products filtered to only the price book entries relevant to a specific customer based on their account level pricing attributes prerequisites before you begin, ensure you have a valid nue api key a customer id (nue id or salesforce external id) products published with pricing attributes configured in the catalog basic knowledge of rest apis and json when to use this endpoint use get /customers/{customerid}/products instead of get /catalog/products when you need to show a customer only the products and pricing tiers they are eligible for this is especially useful for self service portals and customer facing storefronts where different customer segments see different product offerings get /catalog/products — returns the full published catalog with all price book entries get /customers/{customerid}/products — returns the catalog filtered to only the price book entries that match the customer's account attributes authentication all requests require authentication using your nue api key in the nue api key header const myheaders = new headers(); myheaders append("nue api key", "your api key here"); myheaders append("content type", "application/json"); how filtering works the endpoint evaluates each price book entry's pricing attributes against the customer's account fields rule behavior no pricing attributes price book entry is universal — always included for every customer account level attributes attributes mapped to quote accountid {fieldname} are resolved against the customer's account fields all account level conditions must match for the pbe to be included any wildcard a pricing attribute with value any matches any customer, regardless of the customer's field value quote level attributes attributes not mapped to quote accountid are ignored at catalog level — they are evaluated at order time product exclusion products with zero matching price book entries after filtering are excluded from the response entirely bundle options product options within bundles are filtered by the same rules options whose pbe does not match are removed example given a catalog with pricing attributes based on the customer's type field product pbe pricing attribute matches "channel partner" matches "prospect" platform license standard (none) yes (universal) yes (universal) platform license partner tier quote accountid type = channel partner yes no support license enterprise quote accountid type = enterprise no no a customer with type = "channel partner" would see platform license with both pbes (standard + partner tier) a prospect would see platform license with only the standard pbe support license would be excluded for both since the enterprise pbe does not match either customer type fetching customer products basic example fetch the filtered product catalog for a specific customer const myheaders = new headers(); myheaders append("nue api key", "your api key here"); myheaders append("content type", "application/json"); const customerid = "d2e04653 ae90 49df a986 134cf64f6d03"; fetch(`https //api nue io/customers/${customerid}/products`, { method 'get', headers myheaders }) then(response => response json()) then(result => { console log(`status ${result status}`); console log(`products available ${result data length}`); result data foreach(product => { console log(`\n ${product name} `); console log(`sku ${product sku}`); console log(`price book entries ${product pricebookentries length}`); product pricebookentries foreach(pbe => { console log(` ${pbe uom name} $${pbe listprice} (${pbe currencyisocode})`); }); // display bundle options if applicable if (product configurable && product productoptions) { console log(`bundle options ${product productoptions length}`); product productoptions foreach(opt => { console log(` ${opt product? name || opt productoptionid}`); }); } }); }) catch(error => console log('error ', error)); using a salesforce external id the endpoint accepts either a nue customer id or a salesforce account id const salesforceaccountid = "001em00001f0992iab"; fetch(`https //api nue io/customers/${salesforceaccountid}/products`, { method 'get', headers myheaders }) then(response => response json()) then(result => { console log(`products for sf account ${result data length}`); }) catch(error => console log('error ', error)); building a customer storefront use the filtered catalog to build a product selection ui where customers only see what they are eligible to purchase async function loadstorefront(customerid) { const response = await fetch( `https //api nue io/customers/${customerid}/products`, { method 'get', headers myheaders } ); const result = await response json(); if (result status !== 'success') { console error('failed to load catalog ', result); return; } const standaloneproducts = result data filter(p => !p configurable); const bundles = result data filter(p => p configurable); console log('standalone products '); standaloneproducts foreach(p => { const entry = p pricebookentries\[0]; console log(` ${p name} — $${entry listprice}/${entry uom name}`); }); console log('\nbundles '); bundles foreach(p => { console log(` ${p name}`); p productoptions? foreach(opt => { const type = opt bundled ? 'included' opt required ? 'required' 'optional'; console log(` \[${type}] ${opt product? name}`); }); }); } loadstorefront("d2e04653 ae90 49df a986 134cf64f6d03"); response reference the response shape is identical to get /catalog/products , wrapped in the standard self service response envelope field type description status string "success" or "error" data array array of product objects, filtered to only those with matching price book entries warnings array any warnings generated during processing each product in data has the same schema as get /catalog/products — including pricebookentries , productoptions , productfeatures , and all standard product fields the only difference is that non matching price book entries and product options have been removed error responses status error code description 404 customer not found no customer found with the provided id 401 unauthorized invalid or missing api key