# How can I recreate a custom object after delete?

**URL:** <https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197>\
**Category:** APIs & Integrations\
**Tags:** cms-content, professional, contacts\
**Created:** [February 23, 2021, 9:45pm UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197 "2021-02-23T21:45:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![JZhao](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jzhao/32/98997_2.png) [@JZhao](https://community.hubspot.com/u/JZhao)\
**Post date:** [February 23, 2021, 9:45pm UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/1 "2021-02-23T21:45:53Z")

</div>

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”

}

```

---

<div class="post-metadata">

**Author:** ![RMones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rmones/32/82797_2.png) [@RMones](https://community.hubspot.com/u/RMones)\
**Post date:** [February 24, 2021, 7:47am UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/2 "2021-02-24T07:47:10Z")

</div>

Hi @JZhao ,

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

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

Greets,

Ronald

---

<div class="post-metadata">

**Author:** ![JZhao](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jzhao/32/98997_2.png) [@JZhao](https://community.hubspot.com/u/JZhao)\
**Post date:** [February 24, 2021, 8:53am UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/3 "2021-02-24T08:53:31Z")

</div>

@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”

}

---

<div class="post-metadata">

**Author:** ![eliot\_martin](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/eliot_martin/32/62260_2.png) [@eliot\_martin](https://community.hubspot.com/u/eliot_martin)\
**Post date:** [August 18, 2022, 1:30pm UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/4 "2022-08-18T13:30:55Z")

</div>

Did you ever sort this out? I am getting the same response trying to purge a deleted object.

---

<div class="post-metadata">

**Author:** ![mathew\_murphy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mathew_murphy/32/73754_2.png) [@mathew\_murphy](https://community.hubspot.com/u/mathew_murphy)\
**Post date:** [April 11, 2023, 10:49pm UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/5 "2023-04-11T22:49:08Z")

</div>

I had the same problem, and after some hints from support and some searching and experimenting I managed to work out an answer.

You need to perform

DELETE [https://api.hubspot.com/crm/v3/schemas/[objectTypeId]/purge](https://api.hubspot.com/crm/v3/schemas/%5BobjectTypeId%5D/purge)

The documentation is (currently) wrong, you can’t use the objectType as the parameter for purge. Instead, you need the objectTypeId, which is a value given to you as a property in the JSON data returned when you create the custom schema. It looks like 2-12345678.

There seems to be no way to find out what the objectTypeId is once you’ve deleted the custom schema. The error when you try to create a new schema with the same name as the deleted one doesn’t tell you what the objectTypeId is either, which is a bit of a problem.

---

<div class="post-metadata">

**Author:** ![mathew\_murphy](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mathew_murphy/32/73754_2.png) [@mathew\_murphy](https://community.hubspot.com/u/mathew_murphy)\
**Post date:** [April 11, 2023, 10:56pm UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/6 "2023-04-11T22:56:30Z")

</div>

Correction: There _is_ a way to do it without the customObjectId, [found here](https://community.hubspot.com/t5/APIs-Integrations/Delete-Custom-Object-Error/m-p/422651/highlight/true#M41970)! Phew!

`https://api.hubapi.com/crm/v3/schemas/{objectType}?archived=true`

Apparently the purge endpoint is deprecated.

---

<div class="post-metadata">

**Author:** ![RMones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rmones/32/82797_2.png) [@RMones](https://community.hubspot.com/u/RMones)\
**Post date:** [February 24, 2021, 9:08am UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/7 "2021-02-24T09:08:10Z")

</div>

Hi @JZhao

> **[Accounts Dashboard | HubSpot](https://app.hubspot.com/myaccounts?next=developerdocs&redirect=%2Fapi-reference%2Fcrm-custom-objects-v3%2Fguide)**

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}](https://api.hubapi.com/crm/v3/schemas/%7BobjectType%7D). 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](https://api.hubapi.com/crm/v3/schemas/%7BobjectType%7D?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

---

<div class="post-metadata">

**Author:** ![JZhao](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jzhao/32/98997_2.png) [@JZhao](https://community.hubspot.com/u/JZhao)\
**Post date:** [February 25, 2021, 3:20am UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/8 "2021-02-25T03:20:43Z")

</div>

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”

}

---

<div class="post-metadata">

**Author:** ![RMones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rmones/32/82797_2.png) [@RMones](https://community.hubspot.com/u/RMones)\
**Post date:** [February 25, 2021, 8:09am UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/9 "2021-02-25T08:09:07Z")

</div>

The ObjectTypeId is returned with the call when you create a custom object.

Checkout the docmentation:

> **[Accounts Dashboard | HubSpot](https://app.hubspot.com/myaccounts?next=developerdocs&redirect=%2Fapi-reference%2Fcrm-custom-objects-v3%2Fguide)**

and search for Fetching Object Schema.

---

<div class="post-metadata">

**Author:** ![JZhao](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jzhao/32/98997_2.png) [@JZhao](https://community.hubspot.com/u/JZhao)\
**Post date:** [February 26, 2021, 9:59am UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/10 "2021-02-26T09:59:22Z")

</div>

Could you give me some guidence on this? My project is completed blocked since I am not able to create a custom object and I am not able to delete the object either, so that I am not able to create the object.

when I create a object, I get this error:

{

“status”: “error”,

“message”: “p8013920\_device already exists”,

“correlationId”: “03487491-b106-4044-b72c-279e84fbfd29”,

“context”: {

“name”: [

“p8013920\_device”

]

},

“category”: “OBJECT\_ALREADY\_EXISTS”,

“subCategory”: “InboundDbObjectTypeError.OBJECT\_TYPE\_ALREADY\_EXIST”

}

when I purge the deleted object, I got this error:

{

“status”: “error”,

“message”: “Couldn’t find soft-deleted object type(s) for: ObjectTypeId{metaTypeId=2, innerId=1435617}”,

“correlationId”: “cb539a7b-3a7a-4cc1-b9df-3057948421f5”,

“category”: “VALIDATION\_ERROR”

}

when I delete the with “archived=true” parameter, I get this error.

{

“status”: “error”,

“message”: “Invalid object or event type id: 2-1435617”,

“correlationId”: “f8ccc31f-48b0-4854-abdb-3006c575b3d8”

}

---

<div class="post-metadata">

**Author:** ![RMones](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rmones/32/82797_2.png) [@RMones](https://community.hubspot.com/u/RMones)\
**Post date:** [February 26, 2021, 10:02am UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/11 "2021-02-26T10:02:54Z")

</div>

How do you get the ObjectId? Had you saved it? It looks you are using the wrong objectId

---

<div class="post-metadata">

**Author:** ![JZhao](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jzhao/32/98997_2.png) [@JZhao](https://community.hubspot.com/u/JZhao)\
**Post date:** [February 26, 2021, 10:06am UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/12 "2021-02-26T10:06:32Z")

</div>

I got the ID when I run get schema with archived=true. Then I tried to delete/purge it but both failed. After that I can’t get the ID from `get` anymore. So the question now is how to get and delete the old object?

---

<div class="post-metadata">

**Author:** ![JZhao](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jzhao/32/98997_2.png) [@JZhao](https://community.hubspot.com/u/JZhao)\
**Post date:** [February 25, 2021, 9:23am UTC](https://community.hubspot.com/t/how-can-i-recreate-a-custom-object-after-delete/32197/13 "2021-02-25T09:23:37Z")

</div>

I didn’t save the object id when I delete the custom object. What I can get is when I recreate the object, I see this output:

{

“status”: “error”,

“message”: “p8013920\_device already exists”,

“correlationId”: “90cbbd01-3715-4424-9b98-5b196c525470”,

“context”: {

“name”: [

“p8013920\_device”

]

},

“category”: “OBJECT\_ALREADY\_EXISTS”,

“subCategory”: “InboundDbObjectTypeError.OBJECT\_TYPE\_ALREADY\_EXIST”

}

Is `p8013920_device` the object type id? If not, how can I get the object type id?
