X Enterprises
fastify-xhubspot

deals.batchCreate / deals.getAssociations

Create multiple HubSpot deals in bulk, or read associations on a deal.

deals.batchCreate / deals.getAssociations

Create multiple HubSpot deals in a single API call, or read all associations for a deal by association type.

Signatures

fastify.deals.batchCreate(
  deals: Array<Record<string, string>>
): Promise<Array<{ id: string; properties: Record<string, string> }>>

fastify.deals.getAssociations(
  dealId: string,
  associationType: string
): Promise<Array<{ id: string; type: string }>>

Params

batchCreate

NameTypeRequiredDescription
dealsArray<object>YesNon-empty array of property maps (same shape as deals.create).

getAssociations

NameTypeRequiredDescription
dealIdstringYesHubSpot internal deal ID.
associationTypestringYesAssociation type, e.g., "contacts", "companies".

Returns

batchCreate

Array of { id, properties } for each created deal.

getAssociations

Array of { id, type }.

Throws

  • [xHubspot] deals.batchCreate requires a non-empty array
  • [xHubspot] deals.getAssociations requires a dealId/associationType
  • Re-throws HubSpot API errors.

Examples

batchCreate — import deals from a CRM migration

const created = await fastify.deals.batchCreate(
  legacyDeals.map(d => ({
    dealname: d.name,
    amount: String(d.value),
    dealstage: "qualifiedtobuy",
    closedate: d.closeDate,
  }))
);

getAssociations — find contacts linked to a deal

const contacts = await fastify.deals.getAssociations("67890", "contacts");
// [{ id: "12345", type: "DEAL_TO_CONTACT" }]

See also

AI Context

package: "@xenterprises/fastify-xhubspot"
methods: fastify.deals.batchCreate(deals) | fastify.deals.getAssociations(dealId, toObjectType)
use-when: Bulk create deals or read deal associations
returns: batchCreate → { results } | getAssociations → { results }
Copyright © 2026