Guides and Examples
...
Customers
Fetching Customers
21 min
this guide provides comprehensive instructions for retrieving customer data using the nue lifecycle management api learn how to fetch single or multiple customers, include related data, and implement efficient customer data retrieval workflows prerequisites before you begin, ensure you have a valid nue api key with customer read permissions customer ids (either salesforce ids or nue uuids) basic understanding of rest apis and json familiarity with customer data structures authentication all customer retrieval operations 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"); rest endpoints the nue api provides rest endpoints for customer data access // customer endpoints get https //api nue io/customers // get all customers with pagination get https //api nue io/customers/{customerid} // get a specific customer by id advanced filtering customer endpoints support advanced filtering using query parameters you can filter by any customer field except reserved parameters reserved parameters (cannot be used for filtering) customerids , includes , page , limit , predicate dynamic filtering examples // filter by customer type and industry get https //api nue io/customers?recordtype=business\&industry=technology // filter with date ranges and logic operators get https //api nue io/customers?createddate>=2024 01 01& predicate=and // complex filtering with multiple criteria get https //api nue io/customers?billingstate=ca\&annualrevenue>=1000000& predicate=and supported operators equality field=value comparison field>=value , field<=value , field>value , field\<value inequality field!=value , field<>value basic customer retrieval fetch single customer try it now fetch customers ā https //api docs nue io/fetch customers const myheaders = new headers(); myheaders append("nue api key", "your api key here"); myheaders append("content type", "application/json"); // fetch a single customer const customerids = \["d2e04653 ae90 49df a986 134cf64f6d03"]; const encodedcustomerids = encodeuricomponent(json stringify(customerids)); fetch(`https //api nue io/customers?customerids=${encodedcustomerids}`, { method 'get', headers myheaders }) then(response => response json()) then(result => { console log('customer retrieved successfully ', result); if (result status === 'success' && result data length > 0) { const customer = result data\[0]; console log(`\ncustomer ${customer name}`); console log(`customer id ${customer id}`); console log(`account number ${customer externalid}`); console log(`record type ${customer recordtype}`); console log(`status ${customer status}`); console log(`created ${customer createddate}`); } }) catch(error => console log('error ', error)); fetch multiple customers retrieve multiple customers in a single api call // fetch multiple customers const customerids = \[ "d2e04653 ae90 49df a986 134cf64f6d03", "cc5e1f0f 5e14 48cc ab98 9e5b191aa46f", "f1b2c3d4 e5f6 7890 abcd ef1234567890" ]; const encodedcustomerids = encodeuricomponent(json stringify(customerids)); fetch(`https //api nue io/customers?customerids=${encodedcustomerids}`, { method 'get', headers myheaders }) then(response => response json()) then(result => { if (result status === 'success') { console log(`retrieved ${result data length} customers`); result data foreach((customer, index) => { console log(`\n${index + 1} ${customer name}`); console log(` id ${customer id}`); console log(` type ${customer recordtype}`); console log(` status ${customer status}`); console log(` account ${customer externalid}`); }); } }) catch(error => console log('error ', error)); including related data fetch customers with contact information include customer contacts in the response const customerids = \["d2e04653 ae90 49df a986 134cf64f6d03"]; const encodedids = encodeuricomponent(json stringify(customerids)); // include contacts in the response const urlwithcontacts = `https //api nue io/customers?customerids=${encodedids}\&includes=contacts`; fetch(urlwithcontacts, { method 'get', headers myheaders }) then(response => response json()) then(result => { if (result status === 'success' && result data) { result data foreach(customer => { console log(`\nš¢ customer ${customer name}`); console log(` account ${customer accountnumber}`); console log(` email ${customer email || 'not provided'}`); // display contacts if included if (customer contacts && customer contacts length > 0) { console log(`\n š„ contacts (${customer contacts length}) `); customer contacts foreach(contact => { console log(` ⢠${contact firstname} ${contact lastname}`); console log(` email ${contact email || 'not provided'}`); console log(` phone ${contact phone || 'not provided'}`); console log(` role ${contact title || 'not specified'}`); }); } else { console log(' no contacts available'); } }); } }) catch(error => console log('error ', error)); pagination support the customers endpoint supports pagination for retrieving large datasets efficiently paginated customer retrieval // fetch first page of customers with default page size (100) fetch('https //api nue io/customers?page=1\&limit=50', { method 'get', headers myheaders }) then(response => response json()) then(result => { console log(`page ${result pagination page} of ${result pagination totalpages}`); console log(`showing ${result data length} of ${result pagination total} customers`); result data foreach(customer => { console log(` ${customer name} (${customer id})`); }); // check if more pages are available if (result pagination hasnext) { console log('more customers available on next page'); } }) catch(error => console log('error ', error)); pagination with filtering combine pagination with filtering for targeted results // fetch business customers with pagination fetch('https //api nue io/customers?recordtype=business\&page=1\&limit=25', { method 'get', headers myheaders }) then(response => response json()) then(result => { console log(`business customers page ${result pagination page}`); console log(`total ${result pagination total} customers`); result data foreach(customer => { console log(`š¢ ${customer name} ${customer industry || 'industry not specified'}`); }); }); query parameters reference parameter type required description options customerids array\[string] no json encoded array of customer ids \["customer uuid 1", "customer uuid 2"] includes string no related data to include "contacts" , "orders" , "assets" page integer no page number for pagination 1 (default), 2 , 3 , etc limit integer no records per page 100 (default), max 500 recordtype string no filter by customer type "business" , "consumer" when using pagination ( page / limit ), customerids becomes optional without customerids , returns all customers with pagination response structure success response (200 ok) paginated response structure { "status" "success", "data" \[ { "accountnumber" "z100293", "accountsource" "web", "annualrevenue" 5000000 00, "autorenew" "yes", "billcycleday" "7th of month", "billcyclestartmonth" "03", "billingcity" "san francisco", "billingcountry" "us", "billingperiod" "annual", "billingpostalcode" "94005", "billingprorationenabled" "yes", "billingstate" "ca", "billingstreet" "123 main street", "createdbyid" "3865c4c7 f233 4d7f 8426 2eb882856e5c", "createddate" "2025 06 27t23 23 53 002+00 00", "description" "some customer description", "email" "company\@email com", "fax" "+1 650 383 2838", "funding" "500000", "id" "c5786254 06a2 44fe 88d5 3dd5dad66e78", "imagesignedurl" "https //signedurl io", "industry" "agriculture", "lastmodifiedbyid" "3865c4c7 f233 4d7f 8426 2eb882856e5c", "lastmodifieddate" "2025 06 27t23 23 53 002+00 00", "legalentityname" "entityname", "name" "jadiceguyu", "phone" "393 393 2939", "recordtype" "consumer", "shippingcity" "san francisco", "shippingcountry" "us", "shippingpostalcode" "94005", "shippingstate" "ca", "shippingstreet" "123 main street", "site" "website", "timezone" "pacific/kiritimati", "type" "prospect", "website" "https //url com" } ], "warnings" \[], "pagination" { "page" 1, "limit" 100, "total" 247, "totalpages" 3, "hasnext" true, "hasprevious" false } } error handling common retrieval errors error description resolution invalid customer id customer id format invalid verify customer id format customer not found customer does not exist check customer id exists invalid record type invalid record type filter use "business" or "consumer" invalid includes invalid include parameter check available include options robust customer fetching async function safecustomerfetch(customerids, options = {}) { try { // validate inputs if (!array isarray(customerids) || customerids length === 0) { throw new error('customerids must be a non empty array'); } const encodedids = encodeuricomponent(json stringify(customerids)); let url = `https //api nue io/customers?customerids=${encodedids}`; // add optional parameters if (options includes) { url += `\&includes=${options includes}`; } const response = await fetch(url, { method 'get', headers myheaders }); if (!response ok) { throw new error(`http ${response status} ${response statustext}`); } const result = await response json(); if (result status !== 'success') { throw new error(`api error ${result message || 'unknown error'}`); } return { customers result data || \[], found result data? length || 0, requested customerids length }; } catch (error) { console error('customer fetch error ', error); return { customers \[], found 0, requested customerids length, error error message }; } } best practices data retrieval use specific filters to reduce data transfer include related data only when needed to optimize performance batch customer queries efficiently cache frequently accessed customer data performance optimization limit includes to required data only use appropriate timeout settings for api calls monitor api usage and respect rate limits implement proper error handling for network issues business intelligence analyze customer profiles for segmentation insights track customer engagement through contact completeness monitor commercial activity and order patterns generate actionable insights from customer data this comprehensive guide enables you to efficiently retrieve and analyze customer data using the nue lifecycle management api, supporting everything from simple customer lookups to complex portfolio analysis and business intelligence operations