Skip to main content
Glama

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

NameRequiredDescriptionDefault
inputsYesArray of objects to create (maximum 100 per batch)
objectTypeYesThe 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.

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "inputs": { "description": "Array of objects to create (maximum 100 per batch)", "items": { "additionalProperties": false, "properties": { "associations": { "description": "Optional list of associations to create with this object", "items": { "additionalProperties": false, "properties": { "to": { "additionalProperties": false, "properties": { "id": { "description": "ID of the object to associate with", "type": "string" } }, "required": [ "id" ], "type": "object" }, "types": { "items": { "additionalProperties": false, "properties": { "associationCategory": { "enum": [ "HUBSPOT_DEFINED", "USER_DEFINED", "INTEGRATOR_DEFINED" ], "type": "string" }, "associationTypeId": { "exclusiveMinimum": 0, "type": "integer" } }, "required": [ "associationCategory", "associationTypeId" ], "type": "object" }, "minItems": 1, "type": "array" } }, "required": [ "types", "to" ], "type": "object" }, "type": "array" }, "objectWriteTraceId": { "description": "Optional trace ID for debugging purposes", "type": "string" }, "properties": { "additionalProperties": { "type": "string" }, "description": "Object properties as key-value pairs", "type": "object" } }, "required": [ "properties" ], "type": "object" }, "maxItems": 100, "minItems": 1, "type": "array" }, "objectType": { "description": "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.", "type": "string" } }, "required": [ "objectType", "inputs" ], "type": "object" }

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)'), });
  • Registers an instance of the BatchCreateObjectsTool in the tools registry.
    registerTool(new BatchCreateObjectsTool());
  • 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, }, };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ajaystream/hubspot-mcp-custom'

If you have feedback or need assistance with the MCP directory API, please join our Discord server