Hey there! You're using an out-of-date browser, so this site probably looks pretty funny. Upgrade your browser for the full experience.

Introduction to the Hubspot API

The HubSpot API has been a great new tool to work with, as it offers an easy-to-use API and a clean interface.

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

Born and raised in
Louisville, Kentucky.


223 S. Clay St

Work With Us

  • This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
  • This field is for validation purposes and should be left unchanged.