SCALIX help

← All tools

hubspot_associate_objects

HubSpot write medium risk

Part of the HubSpot Agent.

What it does

Create an association (relationship) between two HubSpot CRM records -- contact<->deal, and a note to a contact or deal (the app requests no company scopes). Uses the HubSpot CRM API 2026-09 (date-based version) default endpoint to add the standard unlabeled association without needing an associationTypeId, or accepts an explicit HUBSPOT_DEFINED/USER_DEFINED type when a labeled association is required. Returns the standard envelope {success:true,data} where data is {applied, result}; result is the resulting association (fromObjectTypeId, fromObjectId, toObjectId, association labels/typeIds). Use after creating/upserting a contact and a deal separately (since contacts batch/upsert does not associate) to link the client's LinkedIn lead to its pipeline opportunity. Two-phase (ADR-028/029, the same gate as Google and LinkedIn writes): the first call (no preview_id) builds the request locally, apart from the read-only lookups described here, and returns a preview_id - nothing is changed in HubSpot; after the user approves that preview in a later message, re-call with that preview_id and identical arguments to COMMIT (single-use, 30 min; a changed, forged or replayed token fails closed). The preview includes both records, read in the connected portal when the preview is made (a contact's first and last name, a deal's name; not re-read at commit): an id that portal does not have is refused as not_found, naming from_object_id or to_object_id. Where consent_confirmed exists it must be true at preview and at commit. [POLICY] Associate ONLY the authorizing client's own records; never link records across clients or to enriched/external entities. The association must reflect a real relationship for the client's consented purpose. [REMINDER] Associating is idempotent -- re-adding the same default association is a no-op. Both records are read at preview in the connected portal; show them to the user before linking. [WHEN TO USE] Use to connect a client's own existing contact and deal; do NOT stitch together cross-account, prospecting, or appended data.

When to use it

Use to connect a client's own existing contact and deal; do NOT stitch together cross-account, prospecting, or appended data.

Inputs

NameTypeRequiredDescription
from_object_typestringyesSource object type, e.g. "contacts", "deals", "notes".
from_object_idstringyesSource record id. Read at preview: an id the connected portal does not have is refused (not_found).
to_object_typestringyesTarget object type, e.g. "contacts", "deals", "notes".
to_object_idstringyesTarget record id. Read at preview: an id the connected portal does not have is refused (not_found).
association_typesarraynoOptional explicit labeled types [{associationCategory, associationTypeId}] (e.g., contact->deal typeId 4 / deal->contact 3). Omit to use the default unlabeled association endpoint.
preview_idstringnoOmit it to preview: nothing is applied, and the call returns a preview_id bound to this exact request. Pass it only after the user approves that preview in a later message, with the same arguments (leave out validate_only, and add any confirmation flag the preview names). Single-use, expires in 30 minutes; changed arguments need a fresh preview.

Safeguards

A change in two steps. The first call previews and changes nothing; Claude shows you the preview and applies it only after you approve, within 30 minutes and with the same arguments. Every applied change goes to the audit log. How changes are approved.

Policy

Associate ONLY the authorizing client's own records, reflecting a real relationship for that client's consented purpose. NEVER link records across clients/unaffiliated accounts or to enriched/external entities, and never use associations to assemble a cross-account graph.

Reminder

Idempotent -- re-adding the same default association is a no-op. Both records are read at preview in the connected portal; show them to the user before linking.

Errors

Error classMeansWhat to doRetry
authInvalid or expired OAuth token / session (401 Unauthorized).Refresh the HubSpot OAuth token and retry; do not reuse the rejected token.no
permissionToken lacks a scope for one of the object types (403 Forbidden): read at preview, write at commit (e.g., crm.objects.contacts.write AND crm.objects.deals.write).Surface the missing scope(s). Reconnecting HubSpot grants only the scopes Scalix requests (contacts and deals, read and write).no
validationHubSpot 400: invalid object type, invalid associationTypeId for the type pair, or mismatched category. Surface HubSpot's exact message.Use a valid type pair / the default endpoint; correct the typeId (e.g., contact->deal 4, deal->contact 3) and retry.no
not_foundAt preview: from_object_id or to_object_id does not exist in the connected portal (404 Not Found); the message names which, and no preview_id is returned.Look the record up with hubspot_search_contacts or hubspot_search_deals (create or upsert it first if it does not exist), then call again for a new preview.no
rate_limitHubSpot 429 Too Many Requests (TEN_SECONDLY_ROLLING or daily policy).Honor Retry-After/X-HubSpot-RateLimit-*; back off with jitter; serialize association writes.yes
platformHubSpot server error (500/502/503).Retry with exponential backoff; if persistent, report HubSpot unavailability.yes
invalid_argumentHubSpot API 2026-09 enforces this portal's validation rules on every write (conditionally required properties, properties required at creation, the Edit Associations permission). A violation is a 400 VALIDATION_ERROR: when errors[].code is MISSING_* the tool returns invalid_argument naming the rule and the property; any other invalid value returns invalid_argument with HubSpot's own message.Supply the property the rule names, or fix the value HubSpot's message names (HubSpot internal property names), then re-preview. For "Missing 'Edit Associations' permission." no argument change helps: a HubSpot admin must give the user who connected Scalix the Edit Associations permission (Settings > Users & Teams), then re-preview.no

Edge cases

  • Idempotent: PUT-ing the same default association twice is a safe no-op (no duplicate edge).
  • Direction matters: the type id differs by direction (contact->deal 4 vs deal->contact 3); the default endpoint avoids needing the id.
  • Both records must exist first -- contacts batch/upsert created the contact but no association, so this is the required second step.
  • Labeled (USER_DEFINED) associations require the label to be pre-configured in the portal; an unknown typeId 400s.
  • Cross-object-type pairs HubSpot doesn't allow return 400 -- create notes with associations inline (hubspot_create_note) instead.
  • Scope check: both ids are read at preview in the connected portal, so an id from another portal, or one deleted or merged, is refused (not_found) and no preview_id is returned.