X Enterprises
fastify-xhubspot

companies.delete

Archive (soft-delete) a HubSpot company by ID.

companies.delete

Archive a HubSpot company. The company is soft-deleted and can be restored from the HubSpot UI.

Signature

fastify.companies.delete(companyId: string): Promise<true>

Params

NameTypeRequiredDescription
companyIdstringYesHubSpot internal company ID to archive.

Returns

true on success.

Throws

  • [xHubspot] companies.delete requires a companyId — if companyId is falsy.
  • Re-throws HubSpot API errors.

Examples

Basic

await fastify.companies.delete("98765");

With error handling

fastify.delete("/companies/:id", async (request, reply) => {
  try {
    await fastify.companies.delete(request.params.id);
    return reply.code(204).send();
  } catch (err) {
    if (err.code === 404) return reply.code(404).send({ error: "Not found" });
    throw err;
  }
});

See also

AI Context

package: "@xenterprises/fastify-xhubspot"
method: fastify.companies.delete(companyId)
use-when: Archive a HubSpot company record
returns: void
Copyright © 2026