Delete ALL Custom Objects with 1 call

Hi!

I want delete all Custom Objects in a single api call, because I need to insert data after. So, it would be easier do delete everything and the re/insert new data.

Checking documentation I found this POST url /crm/v3/objects/{objectType}/batch/archive that could potentially do what I need. However, this endpoint requires an ID on its body.

I also saw this thread https://community.hubspot.com/t5/APIs-Integrations/Delete-all-the-Custom-Object-records-in-single-shot/td-p/686055 which one needed the same thing as I do and the suggestion was to use the same endpoint.

However it doesn’t make sense to me… If I will need the Object ID, then first I will need to select the Custom Object record, get its ID and then use it in the batch archive endpoint… it doesn’t seem a delete all call for me. It seems a delete one by one call actually and then I will have to call the endpoint many times.

What am I missing her?
Thanks!

Hi @AndreMiranda,

To my knowledge there is no way to delete all custom objects in a single call. The best I can think of would be to delete them in batches of 100 at a time with 2 API calls per batch.

First start with the List endpoint “GET /crm/v3/objects/{objectType}” with a limit of 100 to get 100 object IDs. Then use the batch delete “POST /crm/v3/objects/{objectType}/batch/archive” to delete those 100 objects. Then repeat this until the objects are all deleted.

The docs for those endpoints can be found here: Accounts Dashboard | HubSpot

Best,

Hi @JBeatty ,
Yeah, I even started doing just like the way you described… getting and deleting after. I’ll do that!

Many thanks!