fastify-xhubspot
contacts.update
Update properties on an existing HubSpot contact.
contacts.update
Update one or more properties on an existing HubSpot contact. Only the provided properties are changed — other properties are left untouched.
Signature
fastify.contacts.update(
contactId: string,
properties: Record<string, string>
): Promise<{ id: string; properties: Record<string, string>; updatedAt: string }>
Params
| Name | Type | Required | Description |
|---|---|---|---|
contactId | string | Yes | HubSpot internal contact ID. |
properties | object | Yes | Map of property names to new values. Only listed properties are updated. |
Returns
| Field | Type | Description |
|---|---|---|
id | string | HubSpot contact ID. |
properties | object | All stored properties after the update. |
updatedAt | string | ISO 8601 last-updated timestamp. |
Throws
[xHubspot] contacts.update requires a contactId— ifcontactIdis falsy.[xHubspot] contacts.update requires a properties object— ifpropertiesis missing or not an object.- Re-throws the HubSpot API error on failure.
Examples
Basic — update a single property
await fastify.contacts.update("12345", { phone: "+15559876543" });
Realistic — sync profile changes
fastify.put("/profile", async (request) => {
const { contactId } = request.user;
const { firstName, lastName, company } = request.body;
const updated = await fastify.contacts.update(contactId, {
firstname: firstName,
lastname: lastName,
company,
});
return { id: updated.id, updatedAt: updated.updatedAt };
});
See also
- contacts.getById — fetch the current state before updating
- contacts.batchUpdate — update multiple contacts at once
AI Context
package: "@xenterprises/fastify-xhubspot"
method: fastify.contacts.update(contactId, updateData)
use-when: Update properties on an existing HubSpot contact
returns: { id, properties }
