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.

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay