This section discusses how to integrate your account type objects. You can store any custom data that is pertinent by creating custom fields for companies, and populating them when creating or updating company objects. Please see the Companies API Overview for more information on all available endpoints.
If any users are intending on using the HubSpot CRM as well as your bespoke CRM, you’ll want to ensure that your database contains the latest information. However, if the HubSpot CRM (or any other external system syncing with your instance of HubSpot) is not going to be used to create or modify company-type objects, you may not need to implement functions to keep this data up to date, as your database will always be authoritative. Please note that it is possible to modify company properties within the Marketing platform by using Workflows. If you intend on creating workflows to do this, you'll need to implement this functionality to ensure that these changes sync to your external system.
Poll the ‘Get Recently Created Companies’ and the ‘Get Recently Modified Companies‘ endpoints every five minutes for any new or updated companies from HubSpot, and then update your internal database with the new data. We recommend keeping a timestamp of the last update to any given company property within your internal system, and then comparing that with a timestamp taken whenever an update API call is made to HubSpot to ensure that your internal database always contains the latest data.
To create a Company in HubSpot, use the ‘Create a Company‘ endpoint. This will return the company in JSON format; pay attention to the returned ‘companyId’ property, which is the unique identifier of the company within HubSpot. Store this Id against the relevant newly created company, as this is the internal unique identifier and you will need it to refer to the company in any subsequent API calls, as well as to associate a contact with the company. Ideally, you'll keep a mapping of HubSpot company ids to your application's company identifier.
To update a company, use the ‘Update a Company’ endpoint, passing the relevant 'companyId' with the request. Again, this will return the company in JSON format, along with HTTP status code 200.
We recommend keeping a timestamp of the last update to any company property within your internal system, and then comparing that with a timestamp taken whenever an update API call is made to ensure that your internal database always has the newest data.
You can delete a company by using the ‘Delete a Company‘ endpoint, passing the relevant ‘companyId’ with the call. Successful deletion of the company will be indicated by the return of HTTP status 200 with the response, which will be a JSON object with two fields; 'deleted', which will return true when the contact has been successfully deleted, as well as the ‘companyId’ of the deleted company.