hubspot-get-association-definitions
Retrieve valid association types between HubSpot objects to ensure correct relationship creation or troubleshoot errors. Returns detailed definitions, including type IDs, labels, and categories.
Instructions
π― Purpose:
1. Retrieves valid association types between specific HubSpot object types.
π¦ Returns:
1. Array of valid association definitions with type IDs, labels, and categories.
π§ Usage Guidance:
1. Always use before creating associations to ensure valid relationship types or to help troubleshoot association creation errors.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fromObjectType | Yes | The type of HubSpot object to get association from. 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. | |
| toObjectType | Yes | The type of HubSpot object to get association to. 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": {
"fromObjectType": {
"description": "The type of HubSpot object to get association from. 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"
},
"toObjectType": {
"description": "The type of HubSpot object to get association to. 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": [
"fromObjectType",
"toObjectType"
],
"type": "object"
}
Implementation Reference
- The main handler function that fetches association definitions from HubSpot CRM API using the provided fromObjectType and toObjectType.async process(args) { try { const response = await this.client.get(`/crm/v4/associations/${args.fromObjectType}/${args.toObjectType}/labels`); return { content: [ { type: 'text', text: JSON.stringify(response, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error retrieving HubSpot association schema definitions: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
- Zod schema defining the input parameters: fromObjectType and toObjectType with detailed descriptions.const AssociationSchemaDefinitionSchema = z.object({ fromObjectType: z .string() .describe(`The type of HubSpot object to get association from. Valid values include: ${HUBSPOT_OBJECT_TYPES.join(', ')}. For custom objects, use the hubspot-get-schemas tool to get the objectType.`), toObjectType: z .string() .describe(`The type of HubSpot object to get association to. Valid values include: ${HUBSPOT_OBJECT_TYPES.join(', ')}. For custom objects, use the hubspot-get-schemas tool to get the objectType.`), });
- Tool definition including name, description, input schema reference, and annotations passed to BaseTool.const ToolDefinition = { name: 'hubspot-get-association-definitions', description: ` π― Purpose: 1. Retrieves valid association types between specific HubSpot object types. π¦ Returns: 1. Array of valid association definitions with type IDs, labels, and categories. π§ Usage Guidance: 1. Always use before creating associations to ensure valid relationship types or to help troubleshoot association creation errors. `, inputSchema: zodToJsonSchema(AssociationSchemaDefinitionSchema), annotations: { title: 'Get CRM Association Types', readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, };
- dist/tools/toolsRegistry.js:31-31 (registration)Instantiation and registration of the AssociationSchemaDefinitionTool in the central tools registry.registerTool(new AssociationSchemaDefinitionTool());