How can I recreate a custom object after delete?

JZhao
Member

 I created a custom object but deleted it. After that I try to create it again with different associations, I got below error. It says "p8013920_device" already exists. I already deleted it and I can't find it in my dashboard. Why do I get this error message?

 

```

{
"status": "error",
"message": "p8013920_device already exists",
"correlationId": "aa470271-83ba-44c5-b41c-95e7189220f6",
"context": {
"name": [
"p8013920_device"
]
},
"category": "OBJECT_ALREADY_EXISTS",
"subCategory": "InboundDbObjectTypeError.OBJECT_TYPE_ALREADY_EXIST"
}
```
0 Upvotes
4 Replies 4
RMones
Participant

Hi @JZhao ,

 

After you delete, you will need to purge to fully remove the schema:

 

 

/crm-object-schemas/v3/schemas/{objectType}/purge

 

Greets,

 

Ronald

 

JZhao
Member

@RMones could you send me the link for this API doc? I tried but got an error not sure what I did wrong

 

{
"status": "error",
"message": "Unable to infer object type from: p8013920_device",
"correlationId": "a6b82746-f3a9-4167-b0cf-8d3c7de80e9c"
}
0 Upvotes
RMones
Participant

Hi @JZhao 

 

https://developers.hubspot.com/docs/api/crm/crm-custom-objects

You can only delete a custom object after all object instances of that type are deleted. To delete a custom object, use: 
DELETE https://api.hubapi.com/crm/v3/schemas/{objectType}.
 If you need to create a new custom object with the same name as the deleted object, you must hard delete the schema by DELETE https://api.hubapi.com/crm/v3/schemas/{objectType}?archived=true


There are two endpoints:

DELETE /crm/v3/schemas/{objectType}/purge
DELETE /crm/v3/schemas/{objectType}

 

I used the NodeJS library of Hubspot and there I have to use to different functions:

hubspotClient.crm.schemas.coreApi.archive(fullyQualifiedName) where fullyQualifiedName = p99688696_car in the Cars Examle in the documentation
hubspotClient.crm.schemas.defaultApi.purge(objectTypeId) where objectTypeId = 2-529881 in the Cars Examle in the documentation;

 

Greets Ronald

JZhao
Member

I tried to run purge API but it returns this error.  Is the object type mean object id? if not what object type I should put in the request?

 

 

{
"status": "error",
"message": "Unable to infer object type from: p8013920_device",
"correlationId": "e78713cc-ead4-4491-a33d-505deabbf1a0"
}
0 Upvotes