hubspot_forward_linkedin_lead
HubSpot write high risk
Part of the Lead Sync Agent.
What it does
Consent-gated bridge that writes a single LinkedIn Lead Gen Form response into HubSpot as a contact, mapping LinkedIn lead fields to HubSpot contact properties (defaults: emailAddress or email, firstName, lastName, company, jobTitle, phoneNumber; field_mapping adds or overrides entries) and optionally logging the originating ad campaign as a touchpoint note and/or associating to a deal. Lead fields without a mapping (campaign/creative/lead-form ids, submittedAt, custom-question answers) are not written to the contact. It is idempotent by email (a batch upsert keyed on the lowercased email). It writes the LinkedIn ids into one touchpoint note when log_touchpoint=true (dated lead.submittedAt, which is then required); a re-run finds that note and does not create a second one (once HubSpot search has indexed it, which can take a few moments). This is the core of the LinkedIn->HubSpot forwarding flow: it forwards ONLY the client's OWN leads, ONLY with the member's consent, and NEVER appends/verifies against external data or pools leads across clients. Returns the standard envelope {success:true,data} where data is {applied, result}; result is the contact (id, created, properties), deal_linked (the associate_deal_id the contact is now linked to, or null when none was given) and note: 'created', 'already logged' or null. HubSpot's association and note counts (such as hs_num_associated_open_deals and num_notes) are left out of properties: HubSpot recalculates them after the write, so its answer would show the count from before the link. 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 the deal being associated (read when the preview is made; a nonexistent deal is refused). If a step after the upsert fails (the deal association or the touchpoint note), the tool returns partially_applied naming the contact and the step, and the audit log records it. Where consent_confirmed exists it must be true at preview and at commit. [POLICY] LinkedIn lead/member data may be used ONLY for the authorizing client and ONLY for consented purposes; NEVER enrich/append/verify profiles, build a cross-account or unaffiliated lead database, do prospecting, or commingle across clients. Forward only the client's own leads, with consent. Honor deletion-on-request. Respect retention: member profile data <=24h and social activity <=48h in caches; do not persist member-derived fields beyond what HubSpot storage of the consented lead requires. Hash PII where the destination supports it. [REMINDER] Verify member consent and client ownership before forwarding; idempotent by email -- safe to re-run. [WHEN TO USE] Use to forward a consented LinkedIn Lead Gen Form response for the authorizing client into HubSpot; do NOT use for non-consented leads, scraped/inferred profiles, or any cross-client/prospecting load.
When to use it
Use to forward a consented LinkedIn Lead Gen Form response for the authorizing client into HubSpot; do NOT use for non-consented leads, scraped/inferred profiles, or any cross-client/prospecting load.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
lead | object | yes | The LinkedIn Lead Gen Form response: {leadResponseUrn, firstName, lastName, emailAddress, company, jobTitle, phoneNumber, customAnswers:[{question,answer}], campaignUrn, creativeUrn, leadFormUrn, submittedAt}. |
field_mapping | object | no | Override map of LinkedIn field -> HubSpot contact property, merged over the defaults: emailAddress->email, email->email, firstName->firstname, lastName->lastname, company->company, jobTitle->jobtitle, phoneNumber->phone. Lead fields with no mapping are not written to the contact. A JSON-object string is accepted. |
consent_confirmed | boolean | yes | Must be true: caller attests the member consented (via the Lead Gen Form) and the lead is the authorizing client's own. False BLOCKS forwarding. |
log_touchpoint | boolean | no | If true, also create one Note on the contact listing the lead's LinkedIn ids (leadResponseUrn, campaign/creative/lead-form URNs or ids, submittedAt), dated lead.submittedAt (required when true: epoch milliseconds, an integer or a digit string such as 1790589600000; any other value is refused before the preview); a re-run skips a note already logged for this lead. |
associate_deal_id | string | no | Optional deal id to associate the resulting contact with (contact<->deal). At preview Scalix reads the deal and shows its name; a nonexistent id is refused. |
preview_id | string | no | Omit 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
LinkedIn lead/member data may be used ONLY for the authorizing client and ONLY for consented purposes. NEVER enrich/append/verify profiles, build a cross-account or unaffiliated lead database, do prospecting, or commingle data across clients. Forward only the client's OWN leads, with consent. Honor deletion-on-request. Respect retention (member profile <=24h, social activity <=48h caches); do not persist member-derived fields beyond the consented lead's required storage. Hash PII where the destination supports it.
Reminder
Verify member consent and client ownership before forwarding; idempotent by email -- safe to re-run without duplicates.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
auth | HubSpot OAuth token invalid/expired, or the LinkedIn Lead Sync token/session is invalid (401 Unauthorized). | Refresh the relevant token (HubSpot or LinkedIn r_marketing_leadgen_automation) and retry; do not reuse the rejected token. | no |
permission | Token lacks crm.objects.contacts.write (HubSpot) or the LinkedIn Lead Sync scope/approval (403 Forbidden). | Grant HubSpot contact write and ensure LinkedIn Lead Sync approval/scope; surface the exact missing grant. | no |
validation | HubSpot 400: missing/blank email (cannot key the upsert), invalid mapped property, or malformed value; OR field_mapping references an unknown HubSpot property. Surface HubSpot's exact message. | Ensure the lead has a valid email and the mapping targets real properties; re-preview the field map, then retry. If no email, route to a manual/no-email handling path rather than failing silently. | no |
rate_limit | HubSpot 429 Too Many Requests during nightly bulk forwarding (TEN_SECONDLY_ROLLING or daily). | Throttle/serialize the forwarding queue, honor Retry-After/X-HubSpot-RateLimit-*, exponential backoff with jitter; resume from the last processed lead. | yes |
not_found | Referenced deal id for association does not exist (404), or the LinkedIn leadFormResponse urn is no longer retrievable (expired/deleted). | Verify the deal id exists; if the LinkedIn lead is gone (past retention or deleted), skip and log -- do not fabricate. | no |
platform | HubSpot or LinkedIn server error (500/502/503) mid-forward. | Retry with exponential backoff; ensure the lead is re-queued (not dropped) so no consented lead is lost silently. | yes |
invalid_argument | HubSpot 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
- Consent gate: if consent_confirmed is false, BLOCK and explain -- the lead must not be written.
- Idempotent upsert by email: re-forwarding the same lead updates the existing contact, never duplicates the contact.
- No-email leads: HubSpot upsert keys on email -- if the LinkedIn lead lacks an email, surface a clear validation path (manual handling), do not silently drop.
- PII hashing: where a downstream destination supports hashing, hash before send; do not store raw member identifiers beyond the consented contact.
- Retention: member profile-derived enrichment fields must not be persisted past 24h; only the consented lead's submitted fields belong in HubSpot.
- Partial batch (nightly sync): on a multi-lead run, a single lead's validation failure must not abort the batch -- HubSpot batch returns 207 multi-status; collect per-lead results and report successes/failures.
- Deletion-on-request: a member deletion request must propagate to remove/forget the forwarded contact data.
- Strict client isolation: never forward into a portal/account other than the authorizing client's, and never pool leads across clients.