fastify-xhubspot
customObjects.update
Update properties on an existing HubSpot custom object record.
customObjects.update
Update one or more properties on an existing record for a given HubSpot custom object type.
Signature
fastify.customObjects.update(
objectType: string,
objectId: string,
properties: Record<string, string>
): Promise<{ id: string; properties: Record<string, string> }>
Params
| Name | Type | Required | Description |
|---|---|---|---|
objectType | string | Yes | The custom object type name or ID (e.g., "subscriptions", "2-12345"). |
objectId | string | Yes | HubSpot internal record ID to update. |
properties | object | Yes | Map of property names to new values. Only provided properties are changed; others are left as-is. |
Returns
| Field | Type | Description |
|---|---|---|
id | string | HubSpot record ID. |
properties | object | All stored properties after the update. |
Throws
[xHubspot] customObjects.update requires an objectType— ifobjectTypeis missing.[xHubspot] customObjects.update requires an objectId— ifobjectIdis missing.[xHubspot] customObjects.update requires a properties object— ifpropertiesis missing or not an object.- Re-throws the HubSpot API error on network failure after logging via
fastify.log.error.
Examples
Basic — change a subscription status
const updated = await fastify.customObjects.update(
"subscriptions",
"1001",
{ status: "cancelled" }
);
console.log(updated.properties.status); // "cancelled"
Realistic — sync plan changes from a billing webhook
fastify.post("/billing/webhook", async (request, reply) => {
const { hubspotRecordId, newPlan, billingCycle } = request.body;
await fastify.customObjects.update("subscriptions", hubspotRecordId, {
plan_name: newPlan,
billing_cycle: billingCycle,
});
return reply.send({ synced: true });
});
See also
- customObjects.getById — fetch a record before updating
- customObjects.delete — permanently remove a record
- customObjects.batchCreate — create multiple records at once
AI Context
package: "@xenterprises/fastify-xhubspot"
method: fastify.customObjects.update(objectTypeId, recordId, updateData)
use-when: Update properties on an existing custom object record
returns: { id, properties }
