A collection of methods related to the Contacts API
Methods
-
Batch update a set of contacts
Name Type Description contactsToUpdate
array 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 properties
object Key/value pair of properties to update. Note:
email
is 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 id
number 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 email
string The email address of the contact
properties
object 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 vid
int The vid of the contact to retrieve
properties
object 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 utk
string The utk (User token) of the contact
properties
object 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 options
object 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 options
object Additional options and paging criteria
Properties:
Name Type Argument Description options.count
number <optional>
Specifies the number of contacts to be returned.
options.timeOffset
number <optional>
This is used along with
vidOffset
to get the next page of results. Each request will return atime-offset
andvid-offset
in the response, and you'd use those offsets in the URL of your next request to get the next page of results.options.vidOffset
number <optional>
This is used along with
timeOffset
to 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 q
string The search term (see https://developers.hubspot.com/docs/methods/contacts/search_contacts)
options
object Additional options and paging criteria
Properties:
Name Type Argument Description options.count
number <optional>
Specifies the number of contacts to be returned.
options.offset
number <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.property
array <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 vid
number VID of contact to update
properties
object 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));