X Enterprises
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

NameTypeRequiredDescription
contactIdstringYesHubSpot contact ID.
taskData.bodystringNoTask description or notes.
taskData.titlestringNoTask subject line (alias: subject).
taskData.statusstringNoHubSpot task status. Default: "NOT_STARTED".
taskData.prioritystringNoTask priority: "HIGH", "MEDIUM", "LOW". Default: "MEDIUM".
taskData.dueDatestringNoDue date/time ISO string for task reminder.
taskData.ownerIdstringNoHubSpot 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

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 }
Copyright © 2026