Namespace: hs/contacts

hs/contacts

A collection of methods related to the Contacts API

Methods

hs/contacts.batchUpdateContacts (contactsToUpdate)Promise asyncstatic

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))

hs/contacts.createOrUpdateContact (properties)Promise asyncstatic

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));

hs/contacts.deleteContact (id)Promise asyncstatic

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));

hs/contacts.getByEmail (email, properties)Promise asyncstatic

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))

hs/contacts.getById (vid, properties)Promise asyncstatic

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))

hs/contacts.getByUtk (utk, properties)Promise asyncstatic

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))

hs/contacts.getContacts (options)Promise asyncstatic

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));

hs/contacts.getRecentlyModified (options)Promise asyncstatic

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 a time-offset and vid-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))

hs/contacts.search (q, options)Promise asyncstatic

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 })

hs/contacts.updateContactByVid (vid, properties)Promise asyncstatic

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));