hubspot_create_deal
HubSpot write medium risk
Part of the HubSpot Agent.
What it does
Create a new HubSpot deal. Requires dealname, pipeline and dealstage, with pipeline and dealstage as the portal's INTERNAL ids (resolve labels with hubspot_list_pipelines / hubspot_list_deal_stages): HubSpot API 2026-09 rejects a deal without pipeline or dealstage, so a call missing any of the three is refused before the preview. Optional properties include amount, closedate, dealtype, plus any custom fields (e.g., a LinkedIn-attribution field). Optionally pass associations to link the deal to existing contacts at creation time (the app requests no company scopes). Returns the standard envelope {success:true,data} where data is {applied, result}; result is HubSpot's created deal (id, properties, createdAt, updatedAt, archived) plus associations_created: the associations sent with the create. HubSpot applies them with the create, all or nothing (an invalid one fails the whole create), so a success confirms every link - no hubspot_associate_objects call is needed. HubSpot's association and note counts (such as num_associated_contacts and num_notes) are left out of result: HubSpot recalculates them after the write, so its answer would show 0 beside a link just made. Use to open a pipeline opportunity from a qualified, client-owned LinkedIn lead and tie it to that lead's contact. Two-phase (ADR-028/029, the same gate as Google and LinkedIn writes): the first call (no preview_id) builds the request locally and returns a preview_id - nothing is sent to 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). Where consent_confirmed exists it must be true at preview and at commit. [POLICY] A deal may represent ONLY the authorizing client's own business/leads; never create deals that embed or rely on enriched/appended/cross-client member data, and only with consent for the contact data referenced. [REMINDER] Resolve pipeline/stage to internal ids first; preview the full deal payload before creating. [WHEN TO USE] Use to open an approved opportunity for the authorizing client from a consented lead; do NOT create speculative or prospecting deals from non-client data.
When to use it
Use to open an approved opportunity for the authorizing client from a consented lead; do NOT create speculative or prospecting deals from non-client or appended data.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
properties | object | yes | Deal property map. Must include dealname, pipeline and dealstage (pipeline and dealstage as INTERNAL ids from hubspot_list_pipelines / hubspot_list_deal_stages; a call missing any of the three is refused before the preview); optional amount, closedate (epoch ms or ISO-8601), dealtype, custom fields. |
associations | array | no | Optional associations created with the deal, e.g. [{to:{id:"<contactId>"}, types:[{associationCategory:"HUBSPOT_DEFINED", associationTypeId:3}]}] (3 = deal->contact). Applied with the create, all or nothing; a successful result lists them as associations_created. |
consent_confirmed | boolean | yes | Must be true: caller attests this opportunity and any referenced contact are the client's own, consented data. |
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
A deal may represent ONLY the authorizing client's own business/leads, with consent for any referenced contact data. NEVER embed or rely on enriched/appended/cross-client or member-derived data, and never use deals to seed prospecting across unaffiliated accounts.
Reminder
Use INTERNAL pipeline/stage ids (resolve via hubspot_list_pipelines/list_deal_stages); preview the full payload before create.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
auth | Invalid or expired OAuth token / session (401 Unauthorized). | Refresh the HubSpot OAuth token and retry; do not reuse the rejected token. | no |
permission | Token lacks crm.objects.deals.write scope (or the write scope of an associated object) (403 Forbidden). | Grant crm.objects.deals.write (and crm.objects.contacts.write if associating) and reconnect; surface the missing scope. | no |
validation | HubSpot 400: missing dealname, invalid dealstage/pipeline internal id (label used instead of id), or malformed amount/closedate. Surface HubSpot's exact message. | Resolve pipeline/stage to internal ids via list tools, fix required/typed fields, re-preview, then retry. | no |
not_found | An association target id does not exist (404) when associating to a missing contact. | Verify the associated record id exists (create/upsert the contact first); then retry. | no |
rate_limit | HubSpot 429 Too Many Requests (TEN_SECONDLY_ROLLING or daily policy). | Honor Retry-After/X-HubSpot-RateLimit-*; back off with jitter. | yes |
platform | HubSpot server error (500/502/503). | Retry with exponential backoff; if persistent, report HubSpot unavailability. If a create may have partially succeeded after a timeout, dedupe via hubspot_search_deals before retrying. | 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
- Deal stage and pipeline MUST be internal ids, not display labels -- labels yield 400.
- pipeline and dealstage are required with dealname: HubSpot API 2026-09 rejects a deal without them ('required properties were missing'), so Scalix refuses such a call before the preview.
- Create is NOT idempotent -- repeated calls create duplicate deals; dedupe by searching first (hubspot_search_deals) when retrying after a timeout.
- Associations at creation use deal->contact typeId 3 (HUBSPOT_DEFINED); a missing target id 404s the whole create.
- closedate accepts epoch milliseconds or ISO-8601; mismatched format is a 400.
- Consent gate: block if consent_confirmed is false or the underlying lead is non-client/member-derived beyond retention.