X Enterprises
fastify-xhubspot

contacts.batchCreate / contacts.batchUpdate

Create or update multiple HubSpot contacts in a single API call.

contacts.batchCreate / contacts.batchUpdate

Create or update multiple HubSpot contacts in a single API call. Useful for bulk imports or syncing changes from an external system.

Signatures

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

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

Params

batchCreate

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

batchUpdate

NameTypeRequiredDescription
contactsArray<{ id, properties }>YesNon-empty array of { id, properties } objects. id is the HubSpot contact ID.

Returns

Both methods return an array of { id, properties } for each processed contact.

Throws

  • [xHubspot] contacts.batchCreate requires a non-empty array — if input is empty or not an array.
  • [xHubspot] contacts.batchUpdate requires a non-empty array — if input is empty or not an array.
  • Re-throws the HubSpot API error on failure.

Examples

batchCreate — import contacts from a CSV

const newContacts = csvRows.map(row => ({
  email: row.email,
  firstname: row.first,
  lastname: row.last,
  company: row.company,
}));

const created = await fastify.contacts.batchCreate(newContacts);
console.log(`Created ${created.length} contacts`);

batchUpdate — sync opt-in status

const updates = optedInIds.map(id => ({
  id,
  properties: { hs_email_optout: "false" },
}));

await fastify.contacts.batchUpdate(updates);

See also

AI Context

package: "@xenterprises/fastify-xhubspot"
methods: fastify.contacts.batchCreate(contacts) | fastify.contacts.batchUpdate(contacts)
use-when: Bulk create or update multiple HubSpot contacts in one API call
returns: { results (array of created/updated contact objects) }
Copyright © 2026