fastify-xhubspot
engagement.createTask
Create a task engagement linked to a HubSpot contact.
engagement.createTask
Create a task engagement and associate it with a HubSpot contact.
Signature
fastify.engagement.createTask(
contactId: string,
taskData: {
body?: string;
title?: string;
subject?: string;
status?: string;
priority?: string;
dueDate?: string;
ownerId?: string;
}
): Promise<{ id: string; properties: Record<string, string>; createdAt: string }>
Params
| Name | Type | Required | Description |
|---|---|---|---|
contactId | string | Yes | HubSpot contact ID. |
taskData.body | string | No | Task description or notes. |
taskData.title | string | No | Task subject line (alias: subject). |
taskData.status | string | No | HubSpot task status. Default: "NOT_STARTED". |
taskData.priority | string | No | Task priority: "HIGH", "MEDIUM", "LOW". Default: "MEDIUM". |
taskData.dueDate | string | No | Due date/time ISO string for task reminder. |
taskData.ownerId | string | No | HubSpot owner ID to assign the task to. |
Returns
{ id, properties, createdAt }.
Throws
[xHubspot] engagement.createTask requires a contactId[xHubspot] engagement.createTask requires a taskData object- Re-throws HubSpot API errors.
Examples
Basic follow-up task
await fastify.engagement.createTask("12345", {
title: "Follow up on proposal",
priority: "HIGH",
dueDate: "2025-05-15T09:00:00.000Z",
});
After a trial sign-up
fastify.post("/trials", async (request) => {
const contact = await fastify.contacts.create(request.body);
await fastify.engagement.createTask(contact.id, {
title: "Trial check-in call",
body: "New trial started. Schedule 15-min check-in.",
priority: "HIGH",
dueDate: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000).toISOString(),
ownerId: request.body.assignedOwnerId,
});
return { contactId: contact.id };
});
See also
- engagement.createNote — log a note instead of a task
- engagement.getTasks — list tasks for a contact
AI Context
package: "@xenterprises/fastify-xhubspot"
method: fastify.engagement.createTask(taskData)
use-when: Create a task linked to a HubSpot contact
params: { subject, status, dueDate, contactId, ownerId?, notes? }
returns: { id, properties }
