fastify-xhubspot
contacts.delete
Archive (soft-delete) a HubSpot contact by ID.
contacts.delete
Archive a HubSpot contact. HubSpot uses soft-deletion — archived contacts can be restored from the HubSpot UI within 90 days.
Signature
fastify.contacts.delete(contactId: string): Promise<true>
Params
| Name | Type | Required | Description |
|---|---|---|---|
contactId | string | Yes | HubSpot internal contact ID to archive. |
Returns
true on success.
Throws
[xHubspot] contacts.delete requires a contactId— ifcontactIdis falsy.- Re-throws the HubSpot API error on failure (e.g., 404 if the contact doesn't exist).
Examples
Basic
await fastify.contacts.delete("12345");
With error handling
fastify.delete("/contacts/:id", async (request, reply) => {
try {
await fastify.contacts.delete(request.params.id);
return reply.code(204).send();
} catch (err) {
if (err.code === 404) {
return reply.code(404).send({ error: "Contact not found" });
}
throw err;
}
});
See also
- contacts.getById — verify the contact exists before deleting
- contacts.create — create a new contact
AI Context
package: "@xenterprises/fastify-xhubspot"
method: fastify.contacts.delete(contactId)
use-when: Archive (soft-delete) a HubSpot contact
returns: void
