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

NameTypeRequiredDescription
objectTypestringYesThe custom object type name or ID (e.g., "subscriptions", "2-12345").
objectIdstringYesHubSpot internal record ID to delete.

Returns

true on successful deletion.

Throws

  • [xHubspot] customObjects.delete requires an objectType — if objectType is missing.
  • [xHubspot] customObjects.delete requires an objectId — if objectId is 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

AI Context

package: "@xenterprises/fastify-xhubspot"
method: fastify.customObjects.delete(objectTypeId, recordId)
use-when: Archive a custom object record
returns: void
Copyright © 2026