DEV Community

Cover image for How to create Hubspot contact using API in NodeJS
matkoklaic
matkoklaic

Posted on

7 2

How to create Hubspot contact using API in NodeJS

Get the API key in Settings -> Integrations -> API Key section of the Hubspot dashboard.

Install the Hubspot API client package:

npm install @hubspot/api-client --save
Enter fullscreen mode Exit fullscreen mode

or using yarn:

yarn add @hubspot/api-client
Enter fullscreen mode Exit fullscreen mode

Import the Hubspot API client library:

const hubspot = require('@hubspot/api-client');
Enter fullscreen mode Exit fullscreen mode

Instantiate Hubspot API client:

const hubspotClient = new hubspot.Client({
    apiKey: process.env.HUBSPOT_API_KEY,
});
Enter fullscreen mode Exit fullscreen mode

Create Hubspot contact:

const properties = {
  email: 'user@example.com',
  firstname: 'Jack',
  lastname: 'Jones',
}
const { response, body } =
  await hubspotClient.crm.contacts.basicApi.create({
    properties,
  });
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more