Guides and Examples
...
Contacts
Getting Started with Contact Management
13 min
this guide walks you through the essential contact management operations in the nue self service api you'll learn how to create, retrieve, and update contacts with practical examples prerequisites before you begin, ensure you have a valid nue api key access to the nue lifecycle manager api basic understanding of rest apis and json at least one customer record in your system (contacts must be associated with customers) authentication all contact 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"); creating your first contact contacts must always be created under a specific customer this establishes the organizational relationship and ensures proper data hierarchy basic contact creation try it now create contact for customer https //api docs nue io/create contact for customer required vs optional fields when creating a contact, several fields are required firstname (required) the contact's first name lastname (required) the contact's last name name (required) the contact's full name email (required) unique email address for the contact optional but commonly used fields include title job title or position phone primary phone number mobilephone mobile phone number address fields for shipping and billing purposes retrieving contact information you can retrieve contacts using their email addresses, which is particularly useful for authentication and lookup scenarios retrieve contacts by email try it now fetch contact by emails https //api docs nue io/fetch contact by emails retrieve contacts with customer information you can also retrieve customers with their associated contacts using the includes=contacts parameter on the customer endpoint // retrieve customer with all contacts const customerids = \['cc5e1f0f 5e14 48cc ab98 9e5b191aa46f']; const encodedids = encodeuricomponent(json stringify(customerids)); fetch(`https //api nue io/customers?customerids=${encodedids}\&includes=contacts`, requestoptions) then(response => response json()) then(result => { result data foreach(customer => { console log(`customer ${customer name}`); if (customer contacts && customer contacts length > 0) { console log('contacts '); customer contacts foreach(contact => { console log(` ${contact name} (${contact email}) ${contact title}`); }); } }); }); updating contact information as contact information changes, you'll need to update their records use the patch endpoint to modify specific fields while preserving others basic contact update try it now update contact https //api docs nue io/update contact common patterns and best practices 1\ error handling always implement proper error handling for your contact operations fetch(apiurl, requestoptions) then(response => { if (!response ok) { throw new error(`http error! status ${response status}`); } return response json(); }) then(result => { if (result status === 'success') { // handle success console log('operation successful ', result data); } else { // handle api level errors console error('api error ', result message); } }) catch(error => { console error('network error ', error); }); 2\ email validation before creating contacts, validate email addresses function validateemail(email) { const emailregex = /^\[^\s@]+@\[^\s@]+\\ \[^\s@]+$/; return emailregex test(email); } function validatecontact(contact) { if (!contact firstname || !contact lastname || !contact name || !contact email) { throw new error('firstname, lastname, name, and email are required'); } if (!validateemail(contact email)) { throw new error('invalid email format'); } return true; } 3\ storing contact ids always store the contact id returned from creation for future operations // after successful contact creation const contactid = result data\[0] id; localstorage setitem('currentcontactid', contactid); // later retrieval const storedcontactid = localstorage getitem('currentcontactid'); next steps now that you understand basic contact management, you can explore customer contact relationships to understand organizational hierarchies learn about contact roles and permissions for self service portals implement advanced contact workflows for complex business scenarios study contact data validation and all available fields move on to advanced contact workflows to learn about complex scenarios like bulk operations, contact role management, and integration patterns