Platform and CRM Integrations + Custom Applications

Introduction to the Hubspot API

By:

Nick Stewart
Nick Stewart

on 6/20/2019

Recently we’ve started to expand from Act-On and started developing for the HubSpot platform. HubSpot is a “full platform of marketing, sales, customer service, and CRM software - plus the methodology, resources, and support - to help businesses”. Needless to say, it has been a joy to work with HubSpot as it offers an easy-to-use API and clean interface.

Let’s go over setting up a test environment and making sample API calls (with PHP) to create/update contacts and fill out a form.

Creating a Test Environment

Creating a testing environment within HubSpot is extremely easy (and very useful). After logging in, in the navigation bar there is a link for testing and from there you can create a test environment. The environment will “remain active as long as it’s receiving API calls and it will expire if it’s been inactive for 90 days”.

Getting Started with the API

Ryan Winchester has developed a handy HubSpot PHP API client, which can be found on Github. Once you’ve added it to your project, the first thing you need to is setup your client. I wrapped my client connection in a function that returns the connection, that way I can call it as needed.

All the resources provided by the HubSpot PHP API client can be found here and they should match the HubSpot methods, which can be found here.

Adding a Contact and Properties

Let’s say I want to add a new contact and update a property for the contact – HubSpot makes this easy enough with the createOrUpdate method. This allows you, just as the name suggests, to create or update a contact, by passing an email address (for the contact) and any properties you would like to update.

Submitting a Form

Now what if you wanted to submit a form, for example you have a questionnaire in your app that results need to be saved to a form in HubSpot – again, HubSpot makes this easy with the Submit Form method. You need to pass the portal id, form GUID, your field value (should mimic the field in HubSpot), and you can pass an optional hs_context field, which contains the IP address, page name and URL, and hutk (which is the tracking cookie value used by HubSpot).

Share to

Related Posts

Integrating Salesforce with WordPress

By: Mark Biek on 10/30/2017

Here at VIA, we love to build things. So, when the Center for Non-Profit Excellence approached us about a project, we jumped at the chance to build them a new, custom Salesforce integration for their WordPress website.

Read More »
We Made You an Open Source Salesforce Command-line Tool, You're Welcome

By: Mark Biek on 5/7/2018

Easily explore the Salesforce REST API with our new command-line tool.

Read More »