APIs & Integrations

ajinvise
参加者 | Elite Partner
参加者 | Elite Partner

Delete all company (or other object) with api?

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.

0 いいね!
2件の返信
Jaycee_Lewis
コミュニティーマネージャー
コミュニティーマネージャー

Delete all company (or other object) with api?

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:

v2 Delete a Company

v3 Batch Archive a Company

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

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

ajinvise
参加者 | Elite Partner
参加者 | Elite Partner

Delete all company (or other object) with api?

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();
}

 

 

0 いいね!