fastify-xhubspot
engagement.getEngagements
Retrieve a summary of all engagement IDs and types associated with a HubSpot contact.
engagement.getEngagements
Returns a summary of all engagement IDs and their association type labels for a given HubSpot contact via the associations API.
Signature
fastify.engagement.getEngagements(
contactId: string
): Promise<{ engagements: Array<{ id: string; type: string }>; total: number }>
Params
| Name | Type | Required | Description |
|---|---|---|---|
contactId | string | Yes | HubSpot contact ID. Queries the associations API for all engagement types. |
Returns
| Field | Type | Description |
|---|---|---|
engagements | Array<{ id, type }> | All engagement IDs and their association type labels. |
total | number | Total count of associated engagements. |
Throws
[xHubspot] engagement.getEngagements requires a contactId- Re-throws HubSpot API errors on network failure after logging via
fastify.log.error.
Examples
Basic
const { engagements, total } = await fastify.engagement.getEngagements("12345");
console.log(`${total} total engagements`);
// [{ id: "9001", type: "CONTACT_TO_NOTE" }, { id: "9002", type: "CONTACT_TO_TASK" }]
Realistic
fastify.get("/contacts/:id/engagements", async (request, reply) => {
const { engagements, total } = await fastify.engagement.getEngagements(request.params.id);
return reply.send({ engagements, total });
});
See also
- engagement.getNotes — list notes for a contact
- engagement.getTasks — list tasks for a contact
- engagement.getCalls — list calls for a contact
- engagement.getEmails — list emails for a contact
- engagement.createNote — log a note against a contact
AI Context
package: "@xenterprises/fastify-xhubspot"
method: fastify.engagement.getEngagements(contactId)
use-when: List all engagement IDs and types associated with a HubSpot contact via the associations API
returns: { engagements: Array<{ id, type }>, total }
