Guides and Examples
...
Customers
Updating Customer
25 min
this guide provides comprehensive instructions for updating existing customers using the nue lifecycle management api learn how to modify customer information, update billing configurations, and implement efficient customer management workflows prerequisites before you begin, ensure you have a valid nue api key with customer update permissions valid customer id (either salesforce id or nue uuid) understanding of customer data structures basic knowledge of rest apis and json authentication all customer update 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"); basic customer updates update basic information try it now update customer ā https //api docs nue io/update customer const myheaders = new headers(); myheaders append("nue api key", "your api key here"); myheaders append("content type", "application/json"); // update basic customer information const customerid = "d2e04653 ae90 49df a986 134cf64f6d03"; const updatedata = { name "acme corporation ltd", // updated company name email "billing\@acme corp com", // new billing email phone "+1 555 0199", // updated phone number description "leading provider of innovative business solutions" }; fetch(`https //api nue io/orders/customers/${customerid}`, { method 'patch', headers myheaders, body json stringify(updatedata) }) then(response => response json()) then(result => { if (result status === 'success') { const customer = result data\[0]; console log('customer updated successfully ', result); console log(`updated ${customer name}`); console log(`email ${customer email}`); console log(`phone ${customer phone}`); console log(`last modified ${customer lastmodifieddate}`); // handle any warnings if (result warnings && result warnings length > 0) { console warn('warnings ', result warnings); } } else { console error('update failed ', result); } }) catch(error => console log('error ', error)); update business information modify business specific details for enterprise customers const businessupdatedata = { // business details legalentityname "acme corporation limited llc", industry "financial services", // changed from technology annualrevenue 15000000, // updated revenue numberofemployees 150, // grown from 100 companysize "101 250 employees", ownership "public", // changed from private funding "ipo", // contact updates timezone "america/chicago", // relocated headquarters fax "+1 555 0200" }; const customerid = "d2e04653 ae90 49df a986 134cf64f6d03"; fetch(`https //api nue io/customers/${customerid}`, { method 'patch', headers myheaders, body json stringify(businessupdatedata) }) then(response => response json()) then(result => { if (result status === 'success') { const customer = result data\[0]; console log('ā
business information updated '); console log(`company ${customer name} (${customer legalentityname})`); console log(`industry ${customer industry}`); console log(`revenue $${customer annualrevenue? tolocalestring()}`); console log(`employees ${customer numberofemployees}`); console log(`ownership ${customer ownership}`); console log(`timezone ${customer timezone}`); }) catch(error => console log('error ', error)); billing configuration updates update payment and billing settings modify billing cycle, payment methods, and related configurations const billingupdatedata = { // billing cycle changes billcycleday 15, // changed from 1st to 15th billcyclestartmonth "07", // start new cycle in july // payment configuration paymentmethod "ach", // changed from credit card paymentterm "net 15", // faster payment terms autorenew "yes", // enable auto renewal billingprorationenabled "no", // disable proration // tax configuration taxexempt "exempt", // customer became tax exempt entityid "tax exempt 001", entityusecode "non profit" }; const customerid = "d2e04653 ae90 49df a986 134cf64f6d03"; fetch(`https //api nue io/customers/${customerid}`, { method 'patch', headers myheaders, body json stringify(billingupdatedata) }) then(response => response json()) then(result => { if (result status === 'success') { const customer = result data\[0]; console log('š³ billing configuration updated '); console log(`bill cycle day ${customer billcycleday} starting ${customer billcyclestartmonth}`); console log(`payment method ${customer paymentmethod}`); console log(`payment terms ${customer paymentterm}`); console log(`auto renew ${customer autorenew}`); console log(`tax status ${customer taxexempt}`); console log(`proration ${customer billingprorationenabled ? 'enabled' 'disabled'}`); } }) catch(error => console log('error ', error)); update address information modify billing and shipping addresses const addressupdatedata = { // updated billing address billingstreet "456 new business plaza, suite 200", billingcity "new york", billingstate "ny", billingpostalcode "10001", billingcountry "united states", // updated shipping address shippingstreet "789 distribution center way", shippingcity "newark", shippingstate "nj", shippingpostalcode "07102", shippingcountry "united states" }; const customerid = "d2e04653 ae90 49df a986 134cf64f6d03"; fetch(`https //api nue io/customers/${customerid}`, { method 'patch', headers myheaders, body json stringify(addressupdatedata) }) then(response => response json()) then(result => { if (result status === 'success') { const customer = result data\[0]; console log('š address information updated '); console log('\nbilling address '); console log(` ${customer billingstreet}`); console log(` ${customer billingcity}, ${customer billingstate} ${customer billingpostalcode}`); console log(` ${customer billingcountry}`); console log('\nshipping address '); console log(` ${customer shippingstreet}`); console log(` ${customer shippingcity}, ${customer shippingstate} ${customer shippingpostalcode}`); console log(` ${customer shippingcountry}`); }) catch(error => console log('error ', error)); advanced update patterns customer lifecycle management handle customer status changes and lifecycle events class customerlifecyclemanager { constructor(apikey) { this apikey = apikey; this headers = new headers(); this headers append("nue api key", apikey); this headers append("content type", "application/json"); } async upgradetoenterprise(customerid, upgradedata) { try { console log(`š upgrading customer ${customerid} to enterprise `); // prepare enterprise upgrade data const enterpriseconfig = { // business growth indicators annualrevenue upgradedata newrevenue, numberofemployees upgradedata newemployeecount, companysize this calculatecompanysize(upgradedata newemployeecount), // enhanced billing configuration paymentterm "net 15", // better terms for enterprise billingprorationenabled "yes", // more flexible billing autorenew "yes", // ensure continuity // account management description `enterprise customer upgraded on ${new date() toisostring() split('t')\[0]}`, accountsource "enterprise upgrade" }; const response = await fetch(`https //api nue io/customers/${customerid}`, { method 'patch', headers this headers, body json stringify(enterpriseconfig) }); if (!response ok) { throw new error(`upgrade failed ${response status} ${response statustext}`); } const result = await response json(); if (result status !== 'success') { throw new error(`upgrade failed ${result error? message || 'unknown error'}`); } const updatedcustomer = result data\[0]; // log upgrade completion console log('ā
enterprise upgrade completed '); console log(` customer ${updatedcustomer name}`); console log(` new revenue $${updatedcustomer annualrevenue? tolocalestring()}`); console log(` employees ${updatedcustomer numberofemployees}`); console log(` company size ${updatedcustomer companysize}`); // handle any warnings if (result warnings && result warnings length > 0) { console warn('warnings ', result warnings); } // trigger additional enterprise setup await this setupenterprisefeatures(updatedcustomer); return updatedcustomer; } catch (error) { console error('ā enterprise upgrade failed ', error); throw error; } } async changepaymentmethod(customerid, newpaymentmethod, additionalconfig = {}) { try { console log(`š³ updating payment method for customer ${customerid} `); const paymentupdate = { paymentmethod newpaymentmethod, additionalconfig }; // adjust payment terms based on method if (newpaymentmethod === "ach") { paymentupdate paymentterm = "net 15"; // faster for ach } else if (newpaymentmethod === "wire transfer") { paymentupdate paymentterm = "net 7"; // even faster for wire } const response = await fetch(`https //api nue io/customers/${customerid}`, { method 'patch', headers this headers, body json stringify(paymentupdate) }); if (!response ok) { throw new error(`payment method update failed ${response status}`); } const result = await response json(); if (result status !== 'success') { throw new error(`payment method update failed ${result error? message || 'unknown error'}`); } const customer = result data\[0]; console log('ā
payment method updated '); console log(` method ${customer paymentmethod}`); console log(` terms ${customer paymentterm}`); return customer; } catch (error) { console error('ā payment method update failed ', error); throw error; } } async relocatecustomer(customerid, newaddress, newtimezone) { try { console log(`š relocating customer ${customerid} `); const relocationdata = { billingstreet newaddress street, billingcity newaddress city, billingstate newaddress state, billingpostalcode newaddress postalcode, billingcountry newaddress country, timezone newtimezone, // update description to track relocation description `customer relocated to ${newaddress city}, ${newaddress state} on ${new date() toisostring() split('t')\[0]}` }; const response = await fetch(`https //api nue io/customers/${customerid}`, { method 'patch', headers this headers, body json stringify(relocationdata) }); if (!response ok) { throw new error(`relocation failed ${response status}`); } const result = await response json(); if (result status !== 'success') { throw new error(`relocation failed ${result error? message || 'unknown error'}`); } const customer = result data\[0]; console log('ā
customer relocation completed '); console log(` new location ${customer billingcity}, ${customer billingstate}`); console log(` timezone ${customer timezone}`); return customer; } catch (error) { console error('ā customer relocation failed ', error); throw error; } } calculatecompanysize(employees) { if (employees <= 10) return "1 10 employees"; if (employees <= 50) return "11 50 employees"; if (employees <= 100) return "51 100 employees"; if (employees <= 250) return "101 250 employees"; if (employees <= 500) return "251 500 employees"; if (employees <= 1000) return "501 1000 employees"; return "1000+ employees"; } async setupenterprisefeatures(customer) { // mock enterprise feature setup console log(`š§ setting up enterprise features for ${customer name} `); // in real implementation, this would // enable advanced billing features // set up dedicated account management // configure enterprise integrations // update service level agreements console log('ā
enterprise features configured'); } } // usage examples const lifecyclemanager = new customerlifecyclemanager("your api key here"); // upgrade to enterprise lifecyclemanager upgradetoenterprise( "d2e04653 ae90 49df a986 134cf64f6d03", { newrevenue 25000000, newemployeecount 300 } ) then(customer => { console log('enterprise upgrade completed'); }); // change payment method lifecyclemanager changepaymentmethod( "d2e04653 ae90 49df a986 134cf64f6d03", "ach", { billingprorationenabled "yes" } ) then(customer => { console log('payment method updated'); }); // relocate customer lifecyclemanager relocatecustomer( "d2e04653 ae90 49df a986 134cf64f6d03", { street "100 tech park drive", city "austin", state "tx", postalcode "73301", country "united states" }, "america/chicago" ) then(customer => { console log('customer relocation completed'); }); bulk customer updates efficiently update multiple customers with similar changes class bulkcustomerupdater { constructor(apikey) { this apikey = apikey; this headers = new headers(); this headers append("nue api key", apikey); this headers append("content type", "application/json"); } async updatemultiplecustomers(customerupdates, options = {}) { const results = { successful \[], failed \[], total customerupdates length }; console log(`š starting bulk update of ${customerupdates length} customers `); // process updates with controlled concurrency const concurrency = options concurrency || 5; for (let i = 0; i < customerupdates length; i += concurrency) { const batch = customerupdates slice(i, i + concurrency); const batchpromises = batch map(update => this updatesinglecustomer(update customerid, update data) then(customer => ({ customerid update customerid, customer, success true })) catch(error => ({ customerid update customerid, error error message, success false })) ); const batchresults = await promise all(batchpromises); batchresults foreach(result => { if (result success) { results successful push(result); console log(`ā
updated ${result customer name}`); } else { results failed push(result); console log(`ā failed ${result customerid} ${result error}`); } }); // add delay between batches to respect rate limits if (i + concurrency < customerupdates length) { await this delay(1000); // 1 second delay } } console log(`\nš bulk update completed `); console log(` successful ${results successful length}`); console log(` failed ${results failed length}`); console log(` total ${results total}`); return results; } async updatesinglecustomer(customerid, updatedata) { const response = await fetch(`https //api nue io/customers/${customerid}`, { method 'patch', headers this headers, body json stringify(updatedata) }); if (!response ok) { throw new error(`http ${response status} ${response statustext}`); } const result = await response json(); if (result status !== 'success') { throw new error(`update failed ${result error? message || 'unknown error'}`); } return result data\[0]; } delay(ms) { return new promise(resolve => settimeout(resolve, ms)); } } // usage example update payment terms for multiple customers const bulkupdater = new bulkcustomerupdater("your api key here"); const customerupdates = \[ { customerid "customer 1 id", data { paymentterm "net 15", autorenew "yes" } }, { customerid "customer 2 id", data { paymentterm "net 15", autorenew "yes" } }, { customerid "customer 3 id", data { paymentterm "net 15", autorenew "yes" } } ]; bulkupdater updatemultiplecustomers(customerupdates, { concurrency 3 }) then(results => { console log('bulk update process completed'); if (results failed length > 0) { console log('failed updates need attention ', results failed); } }); error handling and validation robust update implementation async function safecustomerupdate(customerid, updatedata, options = {}) { const myheaders = new headers(); myheaders append("nue api key", "your api key here"); myheaders append("content type", "application/json"); try { // validate customer id if (!customerid || typeof customerid !== 'string') { throw new error('valid customer id is required'); } // validate update data if (!updatedata || typeof updatedata !== 'object') { throw new error('update data is required and must be an object'); } // remove read only fields if present const sanitizeddata = { updatedata }; delete sanitizeddata id; delete sanitizeddata accountnumber; delete sanitizeddata createddate; delete sanitizeddata createdbyid; delete sanitizeddata lastmodifieddate; delete sanitizeddata lastmodifiedbyid; // validate specific fields if (sanitizeddata billcycleday && (sanitizeddata billcycleday < 1 || sanitizeddata billcycleday > 31)) { throw new error('billcycleday must be between 1 and 31'); } if (sanitizeddata email && !isvalidemail(sanitizeddata email)) { throw new error('invalid email format'); } // perform update const response = await fetch(`https //api nue io/customers/${customerid}`, { method 'patch', headers myheaders, body json stringify(sanitizeddata) }); if (!response ok) { const errortext = await response text(); throw new error(`update failed ${response status} ${errortext}`); } const result = await response json(); if (result status !== 'success') { throw new error(`update failed ${result error? message || 'unknown error'}`); } const updatedcustomer = result data\[0]; // log successful update if (options verbose) { console log(`ā
customer ${updatedcustomer name} updated successfully`); console log(` last modified ${updatedcustomer lastmodifieddate}`); } // handle any warnings if (result warnings && result warnings length > 0 && options verbose) { console warn('warnings ', result warnings); } return { success true, customer updatedcustomer, customerid customerid }; } catch (error) { console error(`ā failed to update customer ${customerid} `, error message); return { success false, error error message, customerid customerid }; } } function isvalidemail(email) { const emailregex = /^\[^\s@]+@\[^\s@]+\\ \[^\s@]+$/; return emailregex test(email); } // usage with error handling safecustomerupdate( "d2e04653 ae90 49df a986 134cf64f6d03", { email "new billing\@acme com", paymentterm "net 15", billcycleday 15 }, { verbose true } ) then(result => { if (result success) { console log('update completed ', result customer name); } else { console log('update failed, implement retry or escalation logic'); } }); updatable fields reference core information name customer name legalentityname legal entity name email primary email address phone primary phone number fax fax number timezone customer timezone description customer description business information industry industry classification annualrevenue annual revenue amount numberofemployees employee count companysize company size category ownership ownership type funding funding information billing configuration billcycleday day of month for billing (1 31) billcyclestartmonth starting month (01 12) autorenew auto renewal setting paymentmethod primary payment method paymentterm payment terms billingprorationenabled proration setting taxexempt tax exemption status entityid entity identifier entityusecode entity use code address information billing billingstreet , billingcity , billingstate , billingpostalcode , billingcountry shipping shippingstreet , shippingcity , shippingstate , shippingpostalcode , shippingcountry relationships parentcustomerid parent customer reference orderprimarycontactid primary contact for orders common update scenarios change business growth // company growth update const growthupdate = { annualrevenue 50000000, numberofemployees 500, companysize "501 1000 employees" }; payment method migration // switch from credit card to ach const paymentmigration = { paymentmethod "ach", paymentterm "net 15" }; address relocation // office relocation const relocation = { billingstreet "new address", billingcity "new city", billingstate "ny", timezone "america/new york" }; best practices update strategy validate data before sending updates use partial updates only send changed fields implement retry logic for transient failures log all updates for audit trails handle concurrent updates appropriately monitor integration warnings for enterprise customers performance batch related updates when possible respect rate limits (1000 requests/minute) use controlled concurrency for bulk operations implement proper error handling and recovery cache customer data to minimize api calls security validate all input data before api calls use https for all requests store api keys securely (environment variables) implement proper authentication checks log security related errors for monitoring data integrity validate business rules before updates maintain data consistency across related records handle dependent data appropriately implement proper versioning for audit trails this comprehensive guide enables you to efficiently update customer information using the nue lifecycle management api, supporting everything from simple field updates to complex lifecycle management workflows