Foundation: Undeleting Hub Resources

Sometimes when users are going through deleting items in hub the may mistakenly remove and item that wasn't supposed to be deleted. Thankfully, through the Hub API it is possible to reverse this action. This post will provide the necessary steps to achieve this. This example will go over restoring a deleted location, but do know this can be done for other Hub resources such as vocabularies.

The first step is to run and API call to get the details of the delete hub item. By running the following GET https:///foundation/hub/api/v1/locations/?show=\$deleted this should return all locations including the one that has been deleted. The next step is to identify the location you want to restore.
Once found there are three fields you need to note "id", "deleted", and "name".

From here you can now use this POST call:

https:///foundation/hub/api/v1/locations/\$synchronize?matchOn=id&mode=noDelete&\$show=deleted


Make sure you provide the following in the body of the call:

[

{

    "id": "Location id",

    "deleted": false,

    "name": "Name"

}

]

With these three fields provided and by changing the deleted field to false this should restore the location.

Important Notes:

After you run https:///foundation/hub/api/v1/locations/?show=\$deleted, you can copy the JSON contents and past them into the body of the https:///foundation/hub/api/v1/locations/\$synchronize?matchOn=id&mode=noDelete&\$show=deleted call. If you do this, change the deleted field to false and send the call. Doing it this way can be easier if you want to bring back more than one item or have child locations. 

It is possible that different resources will likely have different and/or additional field that may need to be provided.