Learn how to configure and add your first contact with SendX Node JS SDK
npm install sendx-javascript-sdk --save
import sendx from 'sendx-javascript-sdk'; let defaultClient = sendx.ApiClient.instance; // Configure API key authorization: apiKeyAuth let apiKeyAuth = defaultClient.authentications['apiKeyAuth']; apiKeyAuth.apiKey = 'YOUR API KEY'; let apiInstance = new sendx.ContactApi(); // ContactApi | let contactRequest = new sendx.ContactRequest(); // ContactRequest | contactRequest.email = "jane@doe.com"; contactRequest.firstName = "Jane"; contactRequest.lastName = "Doe"; contactRequest.company = "Tech Solutions Inc."; contactRequest.lastTrackedIp = "34.94.159.140"; contactRequest.customFields = { "1231nfenife213": "VIP", "1434bife23bfij32": "Special Offer Subscriber" }; contactRequest.lists = ["234b324bjed32", "234bij3e2eyv3v2i"]; contactRequest.tags = ["234bijn2ei2jbu4", "2342bijhb2ijneni"]; apiInstance.createContact(contactRequest).then((data) => { console.log('API called successfully. Contact created: ' + JSON.stringify(data, null, 2)); }, (error) => { console.error(error); });
Was this page helpful?