Netzo Logo

hubspot

HubSpot is a customer relationship management (CRM) platform.

Usage

import { hubspot } from 'netzo/apis/hubspot.ts'

const api = hubspot({
  privateAppAccessToken: Deno.env.get('HUBSPOT_PRIVATE_APP_ACCESS_TOKEN')
})

Configuration

The hubspot factory function expects an object with the following, and returns an object with an API client api.

ParamTypeDefaultDescription
privateAppAccessTokenstringDeno.env.get('HUBSPOT_PRIVATE_APP_ACCESS_TOKEN')the access token to use for authentication
Refer to the API documentation to get the required information.

Examples

The following examples assume you have created an api client instance.

Find contacts

Find all contacts that match the query.

const query: QueryContacts = {}
const result = await api.crm.v3.objects.contacts.get<Contacts>(query)
const resultData = result.results

Add contact

Add a new contact.

const data: DataAddOrUpdateContact = {
  properties: {
    company: 'Company X',
    email: '[email protected]'
  }
}
const resultData = await api.crm.v3.objects.contacts.post<AddOrUpdateContactResult>(data)

Update contact

Update a contact by id.

const data: DataAddOrUpdateContact = {
  properties: {
    company: 'New Company Name',
  }
}
const resultData = await api.crm.v3.objects.contacts[CONTACT_ID].patch<AddOrUpdateContactResult>(data)

Delete contact

Delete a contact by id.

await api.crm.v3.objects.contacts[CONTACT_ID].delete<void>()

Find forms

Find all forms that match the query.

const query: QueryForms = {}
const resultData = await api.forms.v2.forms.get<Form[]>(query)

Find submissions

Find all submissions that correspond to a specific form.

const query: QuerySubmissions = {}
const result = await api['form-integrations'].v1.submissions.forms[FORM_ID].get<FormSubmissions>(query)
const resultData = result.results

Find deals

Find all deals that match the query.

const query: QueryDeals = {}
const result = await api.crm.v3.objects.deals.get<Deals>(query)
const resultData = result.results

Add deal

Add a new deal.

const data: DataAddDeal = {
  properties: {
    amount: '1000.00',
    dealname: 'New deal'
  }
}
const resultData = await api.crm.v3.objects.deals.post<AddDealResult>(data)

References