Provide an example of CURL requests for associations

Hello! I’m trying to create requests to associate objects (contacts) with another objects (deals) using CURL and private app keys. Could someone please provide an example for me to do this?

Hi @MDadykin

You can use the Associations API with a simple “curl” call. For example, to associate a contact with a deal using a private app token:

curl --request PUT \
--url “https://api.hubapi.com/crm/v4/objects/deals/{dealId}/associations/contacts/{contactId}/deal_to_contact” \
--header “Authorization: Bearer YOUR_PRIVATE_APP_TOKEN” \
--header “Content-Type: application/json”

Replace {dealId} and {contactId} with the actual IDs. The last part (deal_to_contact) is the association type.

HubSpot maintains a list of valid association types in their docs:

(Accounts Dashboard | HubSpot )

curl --request GET \
--url “https://api.hubapi.com/crm/v4/objects/deals/{dealId}/associations/contacts” \
--header “Authorization: Bearer YOUR_PRIVATE_APP_TOKEN”

That’ll return all linked contacts for a deal.

By the way, if you ever find yourself managing tons of these associations across multiple systems, there are platforms like Stacksync that keep associations consistent automatically between HubSpot and ERPs/SQL databases in real time no need to juggle all the API calls yourself.

Hope this helps.

Thank you very much!