hubspot-batch-create-objects
Create multiple HubSpot objects of the same type in a single API call, optimizing for bulk operations to efficiently manage CRM data modifications.
Instructions
🛡️ Guardrails:
1. Data Modification Warning: This tool modifies HubSpot data. Only use when the user has explicitly requested to update their CRM.
🎯 Purpose:
1. Creates multiple HubSpot objects of the same objectType in a single API call, optimizing for bulk operations.
📋 Prerequisites:
1. Use the hubspot-get-user-details tool to get the OwnerId and UserId if you don't have that already.
2. Use the hubspot-list-objects tool to sample existing objects for the object type.
3. Use the hubspot-get-association-definitions tool to identify valid association types before creating associations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| inputs | Yes | Array of objects to create (maximum 100 per batch) | |
| objectType | Yes | The type of HubSpot object to create. Valid values include: appointments, companies, contacts, courses, deals, leads, line_items, listings, marketing_events, meetings, orders, postal_mail, products, quotes, services, subscriptions, tickets, users. For custom objects, use the hubspot-get-schemas tool to get the objectType. |
Implementation Reference
- The `process` method in `BatchCreateObjectsTool` class that handles the execution of the tool by making a POST request to HubSpot's batch create objects API endpoint.async process(args) { try { const response = await this.client.post(`/crm/v3/objects/${args.objectType}/batch/create`, { body: { inputs: args.inputs, }, }); return { content: [ { type: 'text', text: JSON.stringify({ status: response.status, results: response.results.map(result => ({ id: result.id, properties: result.properties, createdAt: result.createdAt, updatedAt: result.updatedAt, })), requestedAt: response.requestedAt, startedAt: response.startedAt, completedAt: response.completedAt, }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error batch creating HubSpot objects. : ${error instanceof Error ? error.message : String(error)} `, }, ], isError: true, }; } }
- Zod schema defining the input structure for the tool, including objectType and an array of up to 100 object inputs with properties and optional associations.const BatchCreateObjectsSchema = z.object({ objectType: z .string() .describe(`The type of HubSpot object to create. Valid values include: ${HUBSPOT_OBJECT_TYPES.join(', ')}. For custom objects, use the hubspot-get-schemas tool to get the objectType.`), inputs: z .array(ObjectInputSchema) .min(1) .max(100) .describe('Array of objects to create (maximum 100 per batch)'), });
- dist/tools/toolsRegistry.js:33-33 (registration)Registers an instance of the BatchCreateObjectsTool in the tools registry.registerTool(new BatchCreateObjectsTool());
- dist/tools/toolsRegistry.js:10-10 (registration)Imports the BatchCreateObjectsTool class for registration.import { BatchCreateObjectsTool } from './objects/batchCreateObjectsTool.js';
- ToolDefinition object containing the tool name, description, input schema, and annotations used for tool registration.const ToolDefinition = { name: 'hubspot-batch-create-objects', description: ` 🛡️ Guardrails: 1. Data Modification Warning: This tool modifies HubSpot data. Only use when the user has explicitly requested to update their CRM. 🎯 Purpose: 1. Creates multiple HubSpot objects of the same objectType in a single API call, optimizing for bulk operations. 📋 Prerequisites: 1. Use the hubspot-get-user-details tool to get the OwnerId and UserId if you don't have that already. 2. Use the hubspot-list-objects tool to sample existing objects for the object type. 3. Use the hubspot-get-association-definitions tool to identify valid association types before creating associations. `, inputSchema: zodToJsonSchema(BatchCreateObjectsSchema), annotations: { title: 'Create CRM Objects', readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true, }, };