We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Jun 13, 2022 4:47 AM
Im preparing a migration to Hubspot in a sandbox. There are a lot of trial and errors so I would sometime like to wipe all objects via code. Either by specifying an object type to "truncate" or by resetting the sandbox via API.
Is this even possible? So far I only saw some button in the GUI, and the batch archive endpoint.
Jun 13, 2022 5:44 PM
Hey, @ajinvise 👋 To confirm, you are not missing an option for using the API to delete or archive Company and other Objects.
We can use either of these endpoints to delete Companies, either one at a time or in bulk:
DELETE /crm/v3/objects/companies/{companyId}
Recycling Bin Knowledge Base Article — Delete a CRM Object
In both cases, the deleted records move to a portal's recycling bin and can either be restored, if needed, or they will auto-delete after 90 days.
For the Contact object specifically, you can preform full GDPR deletion which will take effect immediately, but this doesn't apply to other objects such as Deals or Companies — Perform a GDPR delete in HubSpot
Have a wonderful rest of your day! — Jaycee
Jun 14, 2022 3:43 AM - edited Jun 14, 2022 3:44 AM
Hi Jaycee!
Yes! Currently Im doing it like below. Which kind of solve the problem
async nukeCompanies() {
let { results } = await hubspot().crm.companies.basicApi.getPage(50)
const inputs = results.map(r => {
return {id: r.id}
})
await hubspot().crm.companies.batchApi.archive({ inputs });
if(results.length > 0) this.nukeCompanies();
}