A collection of methods related to the Contacts API
Methods
-
Batch update a set of contacts
Name Type Description contactsToUpdatearray Array of contact updates, see example below
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.contacts.batchUpdateContacts([{ id: 129838129313, updates: { email: 'sdjfhksdjf@boo.com', phone_no: '9128301982312' } }, { id: 2319082301823, updates: { email: 'skdjflkjsfdsfs@boo.com', phone_no: '1293801293801923' } }, { id: 271263871623, updates: { email: 'mxcxmncvmxc@boo.com', phone_no: '01823981023' } }, { id: 127361287312, updates: { email: 'yqeuyiqwuyeiquwey@boo.com', phone_no: '127398172398123' } } // ..... ]).then(response => console.log(response)) -
Create or update a contact
Name Type Description propertiesobject Key/value pair of properties to update. Note:
emailis a required key.Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.contacts.createOrUpdateContact({ email: 'foo@bar.com', first_name: 'Foo', last_name: 'Bar' }).then(response => console.log(response)); -
Remove a contact
Name Type Description idnumber Id of contact to remove
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.contacts.deleteContact(82739182731).then(response => console.log(response)); -
Get contact by email
Name Type Description emailstring The email address of the contact
propertiesobject Optional extra properties to add to the request - see developer docs
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.contacts.getByEmail('foo@bar.com').then(response => console.log(response)) -
Get contact by ID
Name Type Description vidint The vid of the contact to retrieve
propertiesobject Optional extra properties to add to the request - see developer docs
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.contacts.getById(123412313).then(response => console.log(response)) -
Get contact by UTK (user token)
Name Type Description utkstring The utk (User token) of the contact
propertiesobject Optional extra properties to add to the request - see developer docs
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.contacts.getByUtk('jdalksjd82739jaskdksadjhkds').then(response => console.log(response)) -
Get all contacts
Name Type Description optionsobject Additional options & filters to apply
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.contacts.getContacts({ limit: 25 }).then(response => console.log(response)); -
Get recently modified contacts
Name Type Description optionsobject Additional options and paging criteria
Properties:
Name Type Argument Description options.countnumber <optional>
Specifies the number of contacts to be returned.
options.timeOffsetnumber <optional>
This is used along with
vidOffsetto get the next page of results. Each request will return atime-offsetandvid-offsetin the response, and you'd use those offsets in the URL of your next request to get the next page of results.options.vidOffsetnumber <optional>
This is used along with
timeOffsetto get the next page of results.Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.contacts.getRecentlyModified({count: 5}).then(response => console.log(response)) -
Search contacts
Name Type Description qstring The search term (see https://developers.hubspot.com/docs/methods/contacts/search_contacts)
optionsobject Additional options and paging criteria
Properties:
Name Type Argument Description options.countnumber <optional>
Specifies the number of contacts to be returned.
options.offsetnumber <optional>
This parameter is used to page through the results. Every call to this endpoint will return an offset value. This value is used in the offset= parameter of the next call to get the next page of contacts.
options.propertyarray <optional>
The properties in the "contact" object in the returned data will only include the property or properties that you request.
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); const contacts = await hs.contacts.search('john', { count: 5 }) -
Update contact properties, by VID
Name Type Description vidnumber VID of contact to update
propertiesobject Key/value pair of properties to update.
Returns:
Type Description Promise Example
const hs = new HubspotClient(props); hs.contacts.updateContactByVid(123456, { first_name: 'Foo', last_name: 'Bar' }).then(response => console.log(response));