fastify-xhubspot
customObjects.delete
Permanently delete a HubSpot custom object record by its ID.
customObjects.delete
Permanently delete a record for a given HubSpot custom object type. This action is irreversible.
Signature
fastify.customObjects.delete(
objectType: string,
objectId: string
): Promise<true>
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 delete. |
Returns
true on successful deletion.
Throws
[xHubspot] customObjects.delete requires an objectType— ifobjectTypeis missing.[xHubspot] customObjects.delete requires an objectId— ifobjectIdis missing.- Re-throws the HubSpot API error on network failure after logging via
fastify.log.error.
Examples
Basic
const deleted = await fastify.customObjects.delete("subscriptions", "1001");
console.log(deleted); // true
Realistic — delete on account cancellation
fastify.delete("/accounts/:accountId", async (request, reply) => {
const { accountId } = request.params;
// Fetch the linked HubSpot subscription record ID from your DB
const { hubspotSubscriptionId } = await db.accounts.findById(accountId);
await fastify.customObjects.delete("subscriptions", hubspotSubscriptionId);
await db.accounts.remove(accountId);
return reply.code(204).send();
});
See also
- customObjects.getById — confirm a record exists before deleting
- customObjects.update — update a record instead of deleting
- customObjects.list — list all records to find IDs
AI Context
package: "@xenterprises/fastify-xhubspot"
method: fastify.customObjects.delete(objectTypeId, recordId)
use-when: Archive a custom object record
returns: void
