# Associating objects

HubSpot provides an [**Associations API**](https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4) that lets you create relationships between two objects (e.g., contacts and deals, companies and tickets). To use it, you must supply:

* The **object IDs** of both items you want to associate.
* The appropriate **association type ID**, which varies depending on the specific object types involved (e.g., contact-to-deal, deal-to-company).

This allows you to programmatically link records and maintain relational context across your CRM data.

{% embed url="<https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4#company-to-object>" %}

## Using Hubspot workflows to associate objects

Finding the object IDs needed for associations can be API-intensive, often requiring multiple lookups. To reduce this load and streamline your Middle workflow, you can offload the association step to a HubSpot workflow.

We recommend using a unique identifier, such as `external_customer_id`, to link objects. By referencing this unique property, HubSpot workflows can associate records without requiring your integration to perform direct ID lookups.

<figure><img src="/files/Uq7XmKmcRwsycZtLOYMz" alt=""><figcaption><p>A Create Association action that uses member ID on both a deal and contact object to associate the two</p></figcaption></figure>

We also recommend creating a **dedicated workflow for each object type** you intend to associate. This ensures associations are applied regardless of the order in which the objects are created.

For example, if you're associating **Deals** and **Contacts**, you should create two separate workflows:

* One that triggers when a **Deal** is created or when an `external_customer_id` is added.
* Another that triggers when a **Contact** is created or when its `external_customer_id` is added.

This approach ensures that the association is made as soon as both objects have matching identifiers, even if they’re created at different times.

{% embed url="<https://www.loom.com/share/7634aedd383b4948b432036d531356e2?sid=f376a3ad-faf9-4e95-b67b-e655adf20bbb>" %}
Video on using a workflow to create associations between two Hubspot objects
{% endembed %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.middle.app/middle-docs/guides/app-reference/hubspot/associating-objects.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
