Diving into the New HubSpot API v3 with Real-World Use Cases

Noah Berk

Co-Founder / Strategy

Share

Share on facebook
Share on twitter
Share on linkedin

Introduction

A few weeks ago, HubSpot pushed the v3 version of its API from Beta to Developer Preview, introducing some new game-changing search and import functionalities for developers. To help you better understand these new APIs, we’ll dive deep into the new features and walk through a couple of real-world use cases with code examples. Let’s get started!

Search API

The new Search API allows developers to filter, sort, and search their HubSpot CRM across any object type, including contacts, companies, deals, tickets, products, line items, and quotes (engagements are currently not supported). Default and custom HubSpot properties on any of these objects can be used to search for and return specific records that match your custom filter criteria. Let’s dive a little deeper into the capabilities of these new features and how you can get started with using them:

Filter

With the filter endpoint, you can programmatically return CRM object records that match a given field criterion, the same way you can filter records via HubSpot’s front-end UI. You can combine multiple filters together to utilize AND/OR logic to broaden or narrow your results and can even find associations for Deals and Tickets.

Let’s say you want to return all “hot” deals in your instance, which are determined to be deals with (an amount over $10,000 AND have the value of “standard” for a custom property called “Deal Type”) OR have Deal Type equal to “hot”. Here’s how this API request would look in Python:

As you can see, multiple filters within a filterGroup will be combined using the AND operator, while multiple filterGroups are combined using the OR operator. You can also declare the operator type for each filter within a filterGroup. In our example, we used GTE to declare greater than or equal to and EQ to declare equal to. Check out the official API docs for the full list of available filter operators.

Sort

The sort endpoint allows you to return your results in a specific ascending or descending order. This can be used in conjunction with the filter endpoint to allow you to view your returned results in the desired order, which can be especially useful for data analysis or review.

Continuing our previous example, if we wanted to return our results sorted by amount in descending order, our payload would need to be updated with a sorts parameter:

Search

Lastly, you can now text search against all records across a given object. For example, you can search all Companies with a property that has a value containing the string “tech”. This means that if “tech” is found in any Company property for a given Company record, that record will be returned. Simply specify the search string as the value for the query key in your payload:

One thing to note here is that the search functionality is currently limited to certain properties.

Imports API

This revamped API allows developers to import data into HubSpot via a file without having to log in and use the frontend import tool. Instead, you can import your CSV or Excel files directly through the API, allowing you to create apps that import files programmatically. You can also specify cross-object associations (as you can via the UI), which you declare in the payload. Our simple example CSV has three columns: Deal Name, Deal Type, and Company ID; that last column associates a company record with the deal record. Here is what this payload would look like:

Real-World Use Cases

Now that we have a basic understanding of the capabilities that the new Search and Import APIs offer, let’s take a look at some real-world examples to see these features in action.

Real-Time Integration

Let’s say you’re developing a custom one-way integration between HubSpot and your ERP system, which manages order, invoice, and other accounting information. When an Account record gets created in the ERP, you need a corresponding Company record to be created in HubSpot for sales and marketing outreach. Similarly, when an existing ERP Account record gets updated with new information, its corresponding HubSpot Company record needs to be updated to reflect the new changes. So in order for this logic to work, your integration app needs to be able to know when to create a new company record and when to update an existing company record. 

Prior to the v3 release, the HubSpot APIs could only update a company record (via a PUT request) if it was given the unique HubSpot company ID. So a typical approach might leverage an intermediary database layer that holds lookup tables to enable your integration app to check if a record already exists or not. Specifically, the ERP’s internal Account ID would map to a HubSpot Company ID so your app could find and update the correct company. This approach works just fine, but it introduces another layer to have to develop, manage, and bug-check and can potentially incur more managed costs.

Let’s see how the filter API can be leveraged to eliminate the need for a lookup database altogether, saving development time and tech overhead:

The first step here is to determine which field is being used to look up companies. As you probably already know, it’s never a great idea to rely on strict text matching, as you’re prone to find false positives caused by text variation. So we won’t want to match the ERP Account’s name to the HubSpot Company’s name, as an extra space, comma, dash, or any other string could prevent matches.

Instead, we’ll want to use some unique ID field that can’t be altered. In this case, it makes sense to leverage the ERP Account ID. When a new HubSpot company is created, the ERP Account ID should be written to a custom HubSpot field called “ERP Account ID”. Then, when an account gets updated in the ERP, the integration app can lookup the ERP Account ID in HubSpot companies. If it’s found, the app will know to update an existing company; otherwise, a new company should be created with the value of the ERP Account ID.

Let’s see what this logic would look like in a Python script. First, let’s build our filter function to return the HubSpot company that contains a given ERP Account ID:

This simple function takes in an erp_account_id value that it uses to filter companies and return the value of the HubSpot Company ID and erp_account_id. We’re using the requests package to post our payload and are simply printing the text response and returning the JSON response (containing the erp_account_id) to use later in our script.

We’ll also need functions to create a HubSpot company and update a HubSpot company, which will be called in the logic portion of our script. Here’s what these functions might look like:

These functions are nearly identical in that they take in JSON objects containing company_name, erp_account_id, and phone_number and post the payloads with requests. The update_hs_company function also takes in the HubSpot company ID so it knows which company record to update.

Now, we can call these helper functions in our main workhorse function that handles the business logic. First, we’ll call the search_company_by_account_id function to try to find a HubSpot company whose ERP Account ID field matches the account ID number we’re passing into it. If a record is found, we’ll call the update_hs_company function to update the record with any new data. If a record isn’t found, a new company record needs to be created, so we’ll call the create_hs_company function.

Here’s what this logic might look like:

Here, we’re calling the search_company_by_account_id function with erp_account_id passed into it and assigning the JSON response to a variable called search_results. If there are results in that response, we’re indexing into the results object, pulling out the HubSpot company ID, and updating that company with the new data we’ve received. If there is no results object in the search response, this means a company does not exist with the account_id, so we’re calling the create_hs_company function to (you guessed it) create a new company.

Note that this logic block assumes we’ve assigned our newly pulled data to a dictionary called company_data, which contains erp_account_id, company_name, and phone_number.

You can apply this logic regardless of whether your app receives data via a webhook or queries data from a flat file or the ERP directly. And with this logic that uses the Search API, we don’t need to write, update, and look up IDs in a lookup database, saving development time and overhead.

SFTP Server

The Imports API could be a great option to help automate an integration that leverages an SFTP server sitting between HubSpot and a third-party system. If you have clean and ready-to-import CSVs dumped to your SFTP server each day, the Import API endpoint could be used to simply upload that CSV directly into HubSpot.

Let’s say you have a custom Django instance that stores and manages customer subscription statuses for a software product your company sells. The Django instance is built to run a nightly job to query the internal database for subscription updates and dump the results to a CSV on an SFTP server. We’ve written the database query to return a contact’s first name, last name, email, and product subscription status and have formatted the columns to be friendly with the HubSpot Contact data model. Our CSV might look like this:

As long as the columns are static and won’t change, we can write our script to post this file to HubSpot using the requests package. Here’s what our function might look like:

Conclusion

The new search and import capabilities included in HubSpot’s new v3 APIs are game changers for developers. The search functionality can, in many cases, eliminate the need for an intermediary lookup database when pushing new or updated data from a third-party software into HubSpot, saving development time and infrastructure upkeep. Troubleshooting, data review, and backend reports can be quickly and easily performed with the ability to easily pull selected data from your HubSpot portal. And the new import functionality means you can programmatically import your CSVs and Excel spreadsheets into HubSpot without having to log into HubSpot’s frontend and use the manual import wizard.

We’ve already begun implementing these new features in migration and integration projects for our clients and have seen great results so far. Be sure to check out our blog for more tech-focused articles like this.

Related Posts

Get the Latest.

Sign up for monthly blog notifications to learn more about the latest sales and marketing trends.

Ready to drive results?

We want to help your business be what you envision it to be.
Schedule your free consultation here now.

OutboundOps, LLC (dba obo.)

STANDARD TERMS AND CONDITIONS

These Standard Terms and Conditions (the “Terms”) set forth the terms and conditions that govern purchases by any purchaser (the “Client”) of outbound demand generation services and other related services (the “Services”) from OutboundOps, LLC dba obo. Agency (“obo. Agency”). The Terms and any purchase orders, scopes of work and other agreements regarding the Services shall be referred to as the “Agreement.”

1. OFFER FOR SALE.

All agreements between the Client and obo. Agency to purchase the Services shall be governed by the terms and conditions herein. The Client and obo. Agency agree that any modifications, changes, alterations of the terms and conditions herein, with respect to any specific proposal, must be in writing and signed by the Client and obo. Agency. obo. Agency hereby objects to any additional or different terms which may be contained in any of the Client’s purchase orders, acknowledgements or other documents or any communications received from the Client, and the Client and obo. Agency hereby agree that any such attempts shall be null and void and not deemed a part of the terms and conditions hereunder or any resulting order. 

Any offer hereunder shall expire thirty (30) days following its date, unless the Client executes and returns to obo. Agency that proposal for the applicable Services within such thirty (30) day period. No order may be cancelled, modified or altered by the Client, without written consent of obo. Agency, which may be withheld in its sole discretion.

2. FEES AND PAYMENT.

The fees for the Services are set forth in the applicable proposal provided by obo. Agency and otherwise are based on obo. Agency’s current fees, in effect at the time of order, for the Services. The Client acknowledges and agrees that, if it purchases Services with a minimum period for the Services, such amounts shall be due and payable if this Agreement is terminated sooner.

obo. Agency shall provide the Client with invoices, no more frequently than monthly, for the fees due from the Client under the Agreement. All payments for the Services are payable only in United States Dollars. The Client shall make payment for any and all monthly fees on or before the first day of the applicable month for Services. Unless obo. Agency requires payment in advance or upon different terms, for any other services, the Client shall make payment for all fees within thirty (30) days following the date of invoice.

Subject to the limitations above, payments may be made only in cash or by check or wire transfer or by certain credit cards provided that Client provides credit card authorization satisfactory to obo. Agency.

Charges will be assessed on past due accounts as follows: (i) a late charge at a rate equal to the lesser of one and one-half percent (1.5%) per month or the highest rate permitted by applicable law, and (ii) reasonable collection costs and expenses, including attorneys’ fees and court costs.

The Client’s failure to pay in accordance with the provisions of this Section 2 shall entitle obo.

Agency, without prejudice to its rights to damages, to suspend or cancel any outstanding orders or Services or require further assurance of payment from the Client.

3. TERM AND TERMINATION.

The term of this Agreement shall commence on the effective date as set forth in the applicable proposal, and if not specified, on the date that the proposal is signed (the “Effective Date”) and shall continue in effect, until terminated, in accordance with the terms and conditions set forth in this Agreement, until the date that is the time period specified in the applicable proposal following the Effective Date (and if not specified for six (6) months following the Effective Date, and shall automatically renew for additional terms of equal period unless either party provides thirty (30) days’ written notice to the other party at any time and for any reason whatsoever of its intention to terminate the agreement for convenience (the “Term”).

Either party may terminate this Agreement for a material breach of any provision of this Agreement by the other party upon fourteen (14) days’ prior written notice to the other party, such notice to set forth in detail such breach, and the breaching party’s failure to cure such breach. Either party may terminate this Agreement immediately without breach or penalty by written notice to the other party in the event the other party: (i) institutes or has instituted against it proceedings for bankruptcy (which, in the case of proceedings against it, shall remain for ninety (90) days undismissed), (ii) shall consent to the appointment of a receiver for all or substantially all of its property, (iii) shall make a general assignment for the benefit of its creditors, or shall admit in writing its inability to pay its debts as they become due; or (iv) shall be adjudged a bankrupt or insolvent by a court of competent jurisdiction.

At obo. Agency’s sole discretion, the Services may be immediately terminated or suspended if the Client violates any part of this Agreement. Upon termination of obo. Agency’s engagement hereunder, the Client shall pay to obo. Agency the fees payable to obo. Agency for the Services rendered through the date of termination in accordance with Section 2 hereof.

4. WARRANTY.

obo. Agency warrants to the Client that the Services shall meet the requirements of the applicable proposal and industry standards for a period of sixty (60) days from the date of delivery of the Services to the Client. For purposes of clarity, this limited warranty shall not be applicable to: (a) technical and other issues related to the Client’s website, hardware, software or data that are not related to the Services, including without limitation, development, creation and enhancement of the Client’s website, (b) technical and other issues resulting from any third party’s services or involvement regarding the Client’s website or (c) technical or other issues related to Client’s compliance with data security and other privacy laws that are not within the scope of the obo. Agency Services hereunder.

obo. Agency’s sole responsibility shall be, at its option, during the warranty period either: (i) to repair any warranty issues related to the Services or (ii) to refund to the Client the amounts paid during the warranty period, less a reasonable allowance for use, for such Services with warranty issues.

THIS WARRANTY IS THE SOLE AND EXCLUSIVE WARRANTY GIVEN BY OBO. AGENCY WITH RESPECT TO THE SERVICES PROVIDED BY OBO. AGENCY. EXCEPT AS EXPRESSLY SET FORTH HEREIN, TO THE MAXIMUM EXTENT PERMITTED BY LAW, OBO. AGENCY DISCLAIMS ALL WARRANTIES OF ANY KIND, EITHER EXPRESS, IMPLIED, STATUTORY OR COMMON LAW, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND TITLE. SOME JURISDICTIONS DO NOT ALLOW THE WAIVER OR EXCLUSION OF SOME WARRANTIES SO THEY MAY NOT APPLY. IF THIS EXCLUSION IS HELD TO BE UNENFORCEABLE BY A COURT OF COMPETENT JURISDICTION, THEN ALL EXPRESS, IMPLIED AND STATUTORY WARRANTIES SHALL BE LIMITED IN DURATION TO A PERIOD OF SIXTY (60) DAYS FROM THE DATE OF PROVISION OF EACH PORTION OF THE SERVICES, AND NO WARRANTIES SHALL APPLY AFTER THAT PERIOD.

5. LIMITATION OF LIABILITY.
THE CLIENT EXPRESSLY UNDERSTANDS AND AGREES THAT OBO. AGENCYSHALL NOT BE LIABLE TO THE CLIENT OR ANY THIRD PARTY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE, CONSEQUENTIAL OR EXEMPLARY DAMAGES, EVEN IF OBO. AGENCY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, WHETHER SUCH LIABILITY IS BASED UPON CONTRACT, TORT, NEGLIGENCE OR OTHER LEGAL THEORY. THE CLIENT EXPRESSLY UNDERSTANDS AND AGREES THAT OBO. AGENCY’S CUMULATIVE LIABILITY TO THE CLIENT UNDER THIS AGREEMENT SHALL NOT EXCEED THE AGGREGATE AMOUNT PAID TO OBO. AGENCY UNDER THIS AGREEMENT DURING THE FOUR (4) MONTH PRIOR TO ANY CLAIM.

The Client acknowledges that all delivery dates are approximate. In no event shall obo. Agency be liable for any delays in delivery of the Services.

6. INTELLECTUAL PROPERTY.

obo. Agency agrees that the Client shall own all right, title and interest in and to any pre-existing works of Client, including without limitation, content owned by Client that is provided to obo. Agency (the “Pre-Existing Works”). In the event that any Pre-Existing Works are incorporated into or are used in conjunction with the Services under this Agreement, then during the Term, the Client hereby grants to obo. Agency a fully paid up, non-exclusive, non-transferable, non-sublicensable license to use the Pre-Existing Works solely to provide the Services hereunder.

Upon payment in full for all Services rendered under this Agreement, obo. Agency hereby transfers and assigns to the Client all right, title and interest in and to all work performed in conjunction with the Services, but not including the Licensed IP. For purposes of this Agreement, “Licensed IP” shall mean any and all photographs, artwork and other content and materials that were licensed (not purchased by obo. Agency) for the Services. During the Term, obo. Agency hereby grants to the Client a fully paid up, non-exclusive, non-transferable, non-sublicensable license to use the Licensed IP solely in connection with the Services.

The Client acknowledges that obo. Agency retains all right, title and interest in and to any and all processes, procedures, methods and know-how related to the performance of the Services and any and all related copyrights, trademarks, patents, trade secrets and other intellectual property and proprietary rights. obo. Agency’s name and logo, and all related service names, marks and slogans are the trademarks, service marks or registered trademarks of obo. Agency and may not be used or modified in any manner without the prior written consent of obo. Agency.

7. CONFIDENTIALITY.
At all times during the term of this Agreement and for two (2) years thereafter, the receiving party shall keep confidential and not disclose, directly or indirectly, and shall not use for the benefit of itself of any other third party any Confidential Information of the disclosing party, except that the receiving party may disclose Confidential Information of the disclosing party to its employees and subcontractors to the extent necessary to enable each party to exercise its rights hereunder. “Confidential Information” means any trade secrets or information whether in written, digital, oral or other form which is confidential or proprietary to the disclosing party, including, but not limited to, software, inventions, customer lists, financial information, business methods and processes, and any other materials or information related to any aspect of the business or activities of the disclosing party which are not generally known to others engaged in similar businesses or activities. Notwithstanding the foregoing, Confidential Information does not include information which: (i) was publicly known or generally known within the trade at the time of disclosure; (ii) becomes public knowledge or generally known within the trade without breach of this Agreement by either party or any of its directors, officers or employees; (iii) was information already known by the receiving party at the time of disclosure without a duty of confidentiality, or information independently developed by the receiving party’s personnel who did not have access to the information disclosed by the disclosing party; (iv) is required to be disclosed by law; or (v) is obtained by a party, its officers or employees from third parties who are under no obligation of confidentiality with respect to the information. If the receiving party is required to disclose any Confidential Information by a court order or other specific governmental action, the receiving party may comply with such disclosure requirement, unless the disclosing party, at its own expense, is successful in having the effect of such requirement stayed pending an appeal or further review thereof, or revised, rescinded or otherwise nullified. In all events, the receiving party agrees to notify the disclosing party promptly if at any time a request or demand of any kind is made to the receiving party to disclose any of the disclosing party’s Confidential Information. The disclosing party shall have the right, at its cost, to intervene in any proceeding in which the receiving party is being asked to disclose any of the disclosing party’s Confidential Information.

8. TAXES AND OTHER CHARGES.
The Client shall pay, in addition to the prices as set forth herein, any and all occupation tax, use tax, property tax, sales tax, excise tax, value-added tax, duty, custom, inspection or testing fee, or any other tax, fee or charge of any nature whatsoever, except for taxes on obo. Agency’s income, imposed by any governmental authority on or measured by the transaction between obo. Agency and the Client. The Client shall indemnify, defend and hold harmless obo. Agency against all claims, losses, damages, liabilities, costs and expenses, including reasonable attorneys’ fees, to the extent such claims arise out of any breach of this Section.

9. REPRESENTATIONS.
The Client represents and warrants to obo. Agency that: (i) he is at least 18 years old; (ii) in the event that the Client is an entity, that it has the full right, power and authority to enter into this Agreement; (iii) the performance by the Client of its obligations and duties hereunder, do not and will not violate any agreement to which the Client is a party or by which the Client is otherwise bound; and (iv) the Client’s use of the Services complies in all respects with all applicable laws, statutes, regulations, ordinances and other rules including without limitation, all Federal, state and international laws in connection with data security and privacy of personal data of any identifiable natural person. The Client further represents and warrants that the Client shall ensure that privacy notices posted on Client’s website shall inform users of their rights under all applicable laws.
.
The Client further represents and warrants to obo. Agency that the Client shall not violate, misappropriate or infringe upon any patent, copyright, trademark, trade secret and/or other intellectual property or proprietary rights of any third party.

10. INDEMNIFICATION.
The Client shall indemnify, defend and hold harmless obo.Agency and its directors, officers, employees and agents from and against any and all claims, losses, damages, liabilities, costs and expenses, including reasonable attorneys’ fees, that arise out of, result from or are related to (i) a breach by the Client of any warranty, representation or covenant set forth herein, (ii) the Client’s negligence or willful misconduct, and (iii) violation, misappropriation or infringement upon any patent, copyright, trademark, trade secret and/or other intellectual property or proprietary rights of any third party.

11. GOVERNING LAW.
THE PARTIES AGREE THAT THIS AGREEMENT AND THE RELATIONSHIP BETWEEN THE PARTIES SHALL BE GOVERNED BY AND CONSTRUED IN ACCORDANCE WITH THE LAWS OF THE STATE OF MARYLAND, WITHOUT REGARD TO ITS PRINCIPLES OF CONFLICTS OF LAWS AND WITHOUT REGARD TO THE UNIFORM COMPUTER INFORMATION TRANSACTIONS ACT. THE PARTIES AGREE THAT THE UNITED NATIONS CONVENTION ON CONTRACTS FOR THE INTERNATIONAL SALE OF GOODS SHALL NOT APPLY TO THIS AGREEMENT. THE PARTIES AGREE TO SUBMIT TO THE EXCLUSIVE  JURISDICTION AND VENUE OF THE FEDERAL AND/OR STATE COURTS IN THE STATE OF MARYLAND FOR THE RESOLUTION OF ANY DISPUTES AMONGST THE PARTIES UNDER THIS AGREEMENT.

12. NOTICES.
Any notice provided pursuant to this Agreement shall be in writing and shall be deemed given (i) if by hand delivery, upon receipt thereof; (ii) if mailed, two (2) days after deposit in the U.S. mails, postage prepaid, certified mail return receipt requested, or (iii) if sent via overnight courier, upon receipt.

13. GENERAL INFORMATION.
This Agreement constitutes the entire agreement between the parties with respect to the subject matter herein, superseding any prior agreements between the parties. The Client further acknowledges and agrees that the Client may not assign any part of this Agreement without obo. Agency’s prior written consent, which may be withheld at its sole discretion. This Agreement shall inure to the benefit of each party’s successors and assigns. obo. Agency shall not be deemed to be in breach of the Agreement and thereby liable to the Client or any third party for any delays in the performance of its obligations hereunder caused by fire, explosion, act of God, strikes, war, riot, government regulation, inability to obtain necessary labor, materials or manufacturing facilities or any other act or cause beyond the reasonable control of obo. Agency. The failure of obo. Agency to exercise or enforce any right or provision of this Agreement shall not constitute a waiver of such right or provision. If any provision of this Agreement is found by a court of competent jurisdiction to be invalid, the parties nevertheless agree that the court should endeavor to give effect to the parties’ intentions as reflected in the provision, and the other provisions of this Agreement shall remain in full force and effect.

14. CONTACTING OBO.AGENCY
If the Client has any questions about this Agreement, or any question or problem regarding the Services, the Client can contact obo. Agency by mail at:
obo. Agency
7165 Columbia Gateway Drive, Suite A

Columbia, MD 21046

Or by telephone at (410) 650-5708.

Effective: August 01, 2019.

obo. : Privacy Policy

Purpose

This privacy notice discloses the practices for obo. Agency (OBO) and applies to information collected by this website.

OBO places a high value on your privacy and the expectation that any information collected by OBO remains confidential and is made available only to persons who have a legitimate right to know. OBO recognizes that all employees have an ethical and legal obligation to keep your information confidential and to protect and safeguard this information against unauthorized use. 

Information We Collect

OBO only has access to collect confidential information that you choose to disclose. Confidential information includes, but is not limited to: name, email address, phone number, and address. 

OBO is the sole owner of the information collected and will not sell, trade, or give any confidential information to a third party without express permission. OBO will use gathered information to respond to you regarding the reason you contacted OBO or display/deliver materials, such as emails and content.

Disclosure of Information

An employee may access, discuss, use, and disclose confidential information only for OBO business as it relates to that employee’s specific job functions and/or responsibilities. Only “Minimally Necessary” information may be disclosed within OBO. “Minimally Necessary” means that only the amount of confidential information necessary to accomplish the intended purpose may be disclosed.

Access to Information

Confidential information may only be accessed by employees if related to specific job functions and responsibilities.

If you wish to correct, update, or otherwise modify information provided to OBO, please reach out via email or phone number. You may opt out of future correspondence at any time by contacting OBO via email or phone number.

Security

OBO has security measures in place to protect against the loss, misuse, or alteration of any information under our control, both online and offline.

Change to This Privacy Policy

This website privacy policy is effective as of the date of its posting. OBO may change this privacy policy over time.

How to Contact Us:

If you have any questions regarding this privacy policy, please contact OBO at office@oboagency.com or 410-650-5708 with a detailed description of your inquiry. 

Last Updated October 7th, 2021