Recycle bin

Last Update: 3/6/2017

api-version = 3.0-preview

The recycle bin contains all work items that have been deleted. They can be restored or permanently destroyed.

If you haven't already, look at the information on getting started with these APIs.

Get list of ids for all deleted items in the recycle bin

GET https://{instance}/DefaultCollection/{project}_apis/wit/recycleBin?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string Team project of the deleted work items
Query
api-version string Version of the API to use.

Sample request

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/Fabrikam-Fiber-Git/_apis/wit/recyclebin?api-version=3.0-preview

Sample response

Status code: 200
[
  {
    "id": "92",
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/recycleBin/92"
  },
  {
    "id": "93",
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/recycleBin/93"
  },
  {
    "id": "102",
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/recycleBin/102"
  }
]

Sample code

Get list of ids for all deleted items in the recycle bin.

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

...

public void GetDeletedItems()
{
   string _personalAccessToken = "your personal access token";
   string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));
  string _project = "Fabrikam-Fiber-Git";

   //use the httpclient
   using (var client = new HttpClient())
   {
       //set our headers
       client.BaseAddress = new Uri("https://accountname.visualstudio.com/");
       client.DefaultRequestHeaders.Accept.Clear();
       client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
       client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);

       //send the request and content
       HttpResponseMessage response = client.GetAsync(_project + "/_apis/wit/recyclebin?api-version=3.0-preview").Result;

       if (response.IsSuccessStatusCode)
       {
           var result = response.Content.ReadAsStringAsync().Result;
       }
   }
}
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;

...

public void GetDeletedItems()
{
   //create uri and VssBasicCredential variables
   Uri _uri = new Uri("https://accountname.visualstudio.com");
   string _personalAccessToken = "your personal access token";
   VssBasicCredential _credentials = new VssBasicCredential("", _personalAccessToken);
  string _project = "Fabrikam-Fiber-Git";

  using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(_uri, _credentials))
  {
      List<WorkItemDeleteReference> result = workItemTrackingHttpClient.GetDeletedWorkItemsAsync(_project).Result;
  }
}

Get a deleted item in the recycle bin

GET https://{instance}/DefaultCollection/{project}/_apis/wit/recyclebin/{id}?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string Team project of the deleted work items
id int ID of the deleted item
Query
api-version string Version of the API to use.

Sample request

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/recyclebin/72?api-version=1.0

Sample response

Status code: 200
{
  "id": "72",
  "type": "WorkItem",
  "Name": "72:First Workitem",
  "Project": "Fabrikam-Fiber-Git",
  "DeletedDate": "2015-01-07T18:13:01.807Z",
  "DeletedBy": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
  "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/recycleBin/72?api-version=1.0",
  "resource": {
    "id": 72,
    "rev": 1,
    "fields": {
      "System.AreaPath": "Fabrikam-Fiber-Git",
      "System.TeamProject": "Fabrikam-Fiber-Git",
      "System.IterationPath": "Fabrikam-Fiber-Git",
      "System.WorkItemType": "Product Backlog Item",
      "System.State": "New",
      "System.Reason": "New backlog item",
      "System.CreatedDate": "2015-01-07T18:13:01.807Z",
      "System.CreatedBy": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
      "System.ChangedDate": "2015-01-07T18:13:01.807Z",
      "System.ChangedBy": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
      "System.Title": "First Workitem",
      "Microsoft.VSTS.Scheduling.Effort": 8,
      "WEF_6CB513B6E70E43499D9FC94E5BBFB784_Kanban.Column": "New",
      "System.Description": "Our authorization logic needs to allow for users with Microsoft accounts (formerly Live Ids) - http://msdn.microsoft.com/en-us/library/live/hh826547.aspx"
    },
    "_links": {
      "self": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/72"
      },
      "workItemUpdates": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/72/updates"
      },
      "workItemRevisions": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/72/revisions"
      },
      "workItemHistory": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/72/history"
      },
      "html": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/web/wi.aspx?pcguid=d81542e4-cdfa-4333-b082-1ae2d6c3ad16&id=72"
      },
      "workItemType": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/_apis/wit/workItemTypes/Product%20Backlog%20Item"
      },
      "fields": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/fields"
      }
    },
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/72"
  }
}

Sample code

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

...

public void GetDeletedItem()
{
   string _personalAccessToken = "your personal access token";
   string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));
   string _project = "Fabrikam-Fiber-Git";
   string _id = "72";

   //use the httpclient
   using (var client = new HttpClient())
   {
       //set our headers
       client.BaseAddress = new Uri("https://accountname.visualstudio.com/");
       client.DefaultRequestHeaders.Accept.Clear();
       client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
       client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);

       //send the request and content
       HttpResponseMessage response = client.GetAsync(_project + "/_apis/wit/recyclebin/" + _id + "?api-version=3.0-preview").Result;

       if (response.IsSuccessStatusCode)
       {
           var result = response.Content.ReadAsStringAsync().Result;
       }
   }
}
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;

...

public void GetDeletedItem()
{
   //create uri and VssBasicCredential variables
   Uri _uri = new Uri("https://accountname.visualstudio.com");
   string _personalAccessToken = "your personal access token";
   VssBasicCredential _credentials = new VssBasicCredential("", _personalAccessToken);
   int _id = 72;

  using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(_uri, _credentials))
  {
      WorkItemDelete result = workItemTrackingHttpClient.GetDeletedWorkItemAsync(_id).Result;
  }
}

Get multiple deleted items in the recycle bin

GET https://{instance}/DefaultCollection/{project}/_apis/wit/recyclebin?ids={ids}&api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string Team project of the deleted work items
ids string A comma-separated list of up to 200 IDs of the deleted work items to get.
Query
api-version string Version of the API to use.

Sample request

GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/Fabrikam-Fiber-Git/_apis/wit/recyclebin?ids=92,93,102&api-version=3.0-preview

Sample response

Status code: 200
[
  {
    "id": "92",
    "code": 200,
    "type": "Bug",
    "name": "Bug 92",
    "project": "My Project",
    "deletedDate": "1/31/2017 9:21:14 PM",
    "deletedBy": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/recycleBin/92"
  },
  {
    "id": "93",
    "code": 200,
    "type": "User Story",
    "name": "User Story 93",
    "project": "My Project",
    "deletedDate": "1/31/2017 9:31:00 PM",
    "deletedBy": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/recycleBin/93"
  },
  {
    "id": "102",
    "code": 200,
    "type": "Bug",
    "name": "Bug 102",
    "project": "My Project",
    "deletedDate": "12/30/2016 8:25:15 PM",
    "deletedBy": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/recycleBin/102"
  }
]

Sample code

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

...

public void GetDeletedItems()
{
   string _personalAccessToken = "your personal access token";
   string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));
   string _project = "Fabrikam-Fiber-Git";
   string _ids = "72, 73, 81";

   //use the httpclient
   using (var client = new HttpClient())
   {
       //set our headers
       client.BaseAddress = new Uri("https://accountname.visualstudio.com/");
       client.DefaultRequestHeaders.Accept.Clear();
       client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
       client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);

       //send the request and content
       HttpResponseMessage response = client.GetAsync(_project + "/_apis/wit/recyclebin/?ids=" + _ids + "&api-version=3.0-preview").Result;

       if (response.IsSuccessStatusCode)
       {
           var result = response.Content.ReadAsStringAsync().Result;
       }
   }
}
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;

...

public void GetDeletedItems()
{
   //create uri and VssBasicCredential variables
   Uri _uri = new Uri("https://accountname.visualstudio.com");
   string _personalAccessToken = "your personal access token";
   VssBasicCredential _credentials = new VssBasicCredential("", _personalAccessToken);
   int[] _ids = { 72, 73, 81 };

  using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(_uri, _credentials))
  {
      WorkItemDelete result = workItemTrackingHttpClient.GetDeletedWorkItemAsync(_ids).Result;
  }
}

Restore a work item

PATCH https://{instance}/DefaultCollection/_apis/wit/recyclebin/{id}?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
id int ID of the deleted item
Query
api-version string Version of the API to use.
Body
IsDeleted boolean Value of the IsDeleted field (should be set to false for restoring work items.

Sample request

PATCH https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/recyclebin/403?api-version=3.0-preview
Content-Type: application/json
{
  "IsDeleted": false
}

Sample response

Status code: 200
{
  "id": 403,
  "code": 200,
  "type": "Bug",
  "name": "Test bug to be deleted and then restored",
  "project": "Fabrikam-Fiber-Git",
  "deletedDate": "1/11/2017 11:18:16 PM",
  "deletedBy": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
  "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/403",
  "resource": {
    "id": 403,
    "rev": 3,
    "fields": {
      "System.AreaPath": "Fabrikam-Fiber-Git",
      "System.TeamProject": "Fabrikam-Fiber-Git",
      "System.IterationPath": "Fabrikam-Fiber-Git\\Release 1\\Sprint 2",
      "System.WorkItemType": "Bug",
      "System.State": "New",
      "System.Reason": "New defect reported",
      "System.CreatedDate": "2017-01-11T23:14:16.37Z",
      "System.CreatedBy": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
      "System.ChangedDate": "2017-01-11T23:18:16.03Z",
      "System.ChangedBy": "Jamal Hartnett <fabrikamfiber4@hotmail.com>",
      "System.Title": "Test bug to be deleted and then restored",
      "System.BoardColumn": "New",
      "System.BoardColumnDone": false,
      "Microsoft.VSTS.Common.StateChangeDate": "2017-01-11T23:14:16.37Z",
      "Microsoft.VSTS.Common.Priority": 2,
      "Microsoft.VSTS.Common.Severity": "3 - Medium",
      "WEF_6CB513B6E70E43499D9FC94E5BBFB784_Kanban.Column": "New",
      "WEF_6CB513B6E70E43499D9FC94E5BBFB784_Kanban.Column.Done": false,
      "Microsoft.VSTS.Common.ValueArea": "Business"
    },
    "_links": {
      "self": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/403"
      },
      "workItemUpdates": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/403/updates"
      },
      "workItemRevisions": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/403/revisions"
      },
      "workItemHistory": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/403/history"
      },
      "html": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/web/wi.aspx?pcguid=d81542e4-cdfa-4333-b082-1ae2d6c3ad16&id=403"
      },
      "workItemType": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c/_apis/wit/workItemTypes/Bug"
      },
      "fields": {
        "href": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/fields"
      }
    },
    "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/403"
  }
}

Sample code

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

...

public void RestoreItem()
{
   string _personalAccessToken = "your personal access token";
   string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));
   string _id = "72";

   var patchDocument = new {
      IsDeleted = false
   };

   //use the httpclient
   using (var client = new HttpClient())
   {
      client.DefaultRequestHeaders.Accept.Clear();
      client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
      client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);

      var patchValue = new StringContent(JsonConvert.SerializeObject(patchDocument), Encoding.UTF8, "application/json");

      var method = new HttpMethod("PATCH");
      var request = new HttpRequestMessage(method, "https://accountname.visualstudio.com/_apis/wit/recyclebin/" + _id + "?api-version=3.0-preview") { Content = patchValue };
      var response = client.SendAsync(request).Result;

      if (response.IsSuccessStatusCode)
      {
          var result = response.Content.ReadAsStringAsync().Result;
      }
   }
}
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;

...

public void RestoreItem()
{
   //create uri and VssBasicCredential variables
   Uri _uri = new Uri("https://accountname.visualstudio.com");
   string _personalAccessToken = "your personal access token";
   VssBasicCredential _credentials = new VssBasicCredential("", _personalAccessToken);
  int _id = 72;

  using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(_uri, _credentials))
  {
      WorkItemDeleteUpdate payload = new WorkItemDeleteUpdate() {
          IsDeleted = false
      };

      WorkItemDelete result = workItemTrackingHttpClient.RestoreWorkItemAsync(payload, _id).Result;
  }
}

Restore multiple work items

The batch apis can be leveraged to restore multiple work items at once.

POST https://{instance}/DefaultCollection/_apis/wit/$batch

Sample request

POST https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/$batch?api-version=3.0-preview
Content-Type: application/json
[
  {
    "method": "PATCH",
    "uri": "/_apis/wit/recyclebin/403?api-version=3.0-preview",
    "headers": {
      "Content-Type": "application/json-patch+json"
    },
    "body": [
      {
        "op": "replace",
        "path": "/IsDeleted",
        "value": "false"
      }
    ]
  },
  {
    "method": "PATCH",
    "uri": "/_apis/wit/recyclebin/404?api-version=3.0-preview",
    "headers": {
      "Content-Type": "application/json-patch+json"
    },
    "body": [
      {
        "op": "replace",
        "path": "/IsDeleted",
        "value": "false"
      }
    ]
  }
]

Sample response

Status code: 200
{
  "count": 2,
  "value": [
    {
      "code": 200,
      "headers": {
        "Content-Type": "application/json; charset=utf-8"
      },
      "body": "{\"id\":403,\"code\":200,\"type\":\"Bug\",\"name\":\"Test bug to be deleted and then restored\",\"project\":\"Fabrikam-Fiber-Git\",\"deletedDate\":\"1/12/2017 1:18:19 AM\",\"deletedBy\":\"Jamal Hartnett <fabrikamfiber4@hotmail.com>\",\"url\":\"https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/403\"}"
    },
    {
      "code": 200,
      "headers": {
        "Content-Type": "application/json; charset=utf-8"
      },
      "body": "{\"id\":404,\"code\":200,\"type\":\"Bug\",\"name\":\"Second work item to be restored\",\"project\":\"Fabrikam-Fiber-Git\",\"deletedDate\":\"1/12/2017 1:18:19 AM\",\"deletedBy\":\"Jamal Hartnett <fabrikamfiber4@hotmail.com>\",\"url\":\"https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/workItems/404\"}"
    }
  ]
}

Sample code

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

...

public class BatchRequest
{
   public string method { get; set; }
   public Dictionary<string,string> headers { get; set; }
   public object[] body { get; set; }
   public string uri { get; set; }
}

public void RestoreMultipleItems()
{
   string _personalAccessToken = "your personal access token";
   string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));
   string[] _ids = new string[] { "72", "73", "74" };;

   WorkItemBatchPost.BatchRequest[] postDocument = new WorkItemBatchPost.BatchRequest[3];
   Dictionary<string, string> headers = new Dictionary<string, string>() {
      { "Content-Type", "application/json-patch+json" }
   };

   Object[] postBody = new Object[1];
   postBody[0] = new { op = "replace", path = "/IsDeleted", value = "false" };
   var i = 0;

   foreach(var id in ids)
   {
      postDocument[i] = new WorkItemBatchPost.BatchRequest
      {
          method = "PATCH",
          uri = "/_apis/wit/recyclebin/" + id + "?api-version=3.0-preview",
          headers = headers,
          body = postBody
      };

      i = i + 1;
   };

   //use the httpclient
   using (var client = new HttpClient())
   {
      client.DefaultRequestHeaders.Accept.Clear();
      client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
      client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);

      var postValue = new StringContent(JsonConvert.SerializeObject(postDocument), Encoding.UTF8, "application/json");

      var method = new HttpMethod("POST");
      var request = new HttpRequestMessage(method, "https://accountname.visualstudio.com/_apis/wit/$batch?api-version=3.0-preview") { Content = postValue };
      var response = client.SendAsync(request).Result;

      if (response.IsSuccessStatusCode)
      {
          var result = response.Content.ReadAsStringAsync().Result;
      }
   }
}
  Batch operations are not supported in the .NET Client Libraries

Permanently delete a work item

DELETE https://{instance}/DefaultCollection/{project}/_apis/wit/recycleBin/{id}?api-version={version}
Parameter Type Notes
URL
instance string VS Team Services account ({account}.visualstudio.com) or TFS server ({server:port}).
project string Team project of the deleted work items
id int ID of the deleted item
Query
api-version string Version of the API to use.

Sample request

DELETE https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/recyclebin/403?api-version=3.0-preview

Sample response

Status code: 204

Sample code

using System;
using System.Net.Http;
using System.Net.Http.Headers;

...

public void PermenentlyDeleteItem()
{
   string _personalAccessToken = "your personal access token";
   string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));
   string _id = "72";

   //use the httpclient
   using (var client = new HttpClient())
   {
      client.DefaultRequestHeaders.Accept.Clear();
      client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
      client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);

      var method = new HttpMethod("DELETE");
      var request = new HttpRequestMessage(method, ""https://accountname.visualstudio.com/_apis/wit/recyclebin/" + _id + "?api-version=3.0-preview");
      var response = client.SendAsync(request).Result;

      if (response.IsSuccessStatusCode)
      {
          var result = response.Content.ReadAsStringAsync().Result;
      }
   }
}
using Microsoft.TeamFoundation.Core.WebApi;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;

...

public void PermenentlyDeleteItem()
{
   //create uri and VssBasicCredential variables
   Uri _uri = new Uri("https://accountname.visualstudio.com");
   string _personalAccessToken = "your personal access token";
   VssBasicCredential _credentials = new VssBasicCredential("", _personalAccessToken);
  int _id = 72;

  using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(_uri, _credentials))
  {
      workItemTrackingHttpClient.DestroyWorkItemAsync(_id);
  }
}

Permanently delete multiple work items

The batch apis can be leveraged to restore multiple work items at once.

POST https://{instance}/DefaultCollection/_apis/wit/$batch

Sample request

POST https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/$batch?api-version=3.0-preview
Content-Type: application/json
[
  {
    "method": "DELETE",
    "uri": "/_apis/wit/recyclebin/405?api-version=3.0-preview",
    "headers": {
      "Content-Type": "application/json-patch+json"
    }
  },
  {
    "method": "DELETE",
    "uri": "/_apis/wit/recyclebin/406?api-version=3.0-preview",
    "headers": {
      "Content-Type": "application/json-patch+json"
    }
  }
]

Sample response

Status code: 200
{
  "count": 2,
  "value": [
    {
      "code": 204
    },
    {
      "code": 204
    }
  ]
}

Sample code

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

...

public class BatchRequest
{
   public string method { get; set; }
   public Dictionary<string,string> headers { get; set; }
   public object[] body { get; set; }
   public string uri { get; set; }
}

public void PeremenentlyDeleteMultipleItems()
{
   string _personalAccessToken = "your personal access token";
   string _credentials = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", _personalAccessToken)));
   string[] _ids = new string[] { "72", "73", "74" };;

   WorkItemBatchPost.BatchRequest[] postDocument = new WorkItemBatchPost.BatchRequest[3];
   Dictionary<string, string> headers = new Dictionary<string, string>() {
      { "Content-Type", "application/json-patch+json" }
   };

   var i = 0;

   foreach(var id in ids)
   {
      postDocument[i] = new WorkItemBatchPost.BatchRequest
      {
          method = "DELETE",
          uri = "/_apis/wit/recyclebin/" + id + "?api-version=3.0-preview",
          headers = headers
      };

      i = i + 1;
   };

   //use the httpclient
   using (var client = new HttpClient())
   {
      client.DefaultRequestHeaders.Accept.Clear();
      client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
      client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _credentials);

      var postValue = new StringContent(JsonConvert.SerializeObject(postDocument), Encoding.UTF8, "application/json");

      var method = new HttpMethod("POST");
      var request = new HttpRequestMessage(method, "https://accountname.visualstudio.com/_apis/wit/$batch?api-version=3.0-preview") { Content = postValue };
      var response = client.SendAsync(request).Result;

      if (response.IsSuccessStatusCode)
      {
          var result = response.Content.ReadAsStringAsync().Result;
      }
   }
}
  Batch operations are not supported in the .NET Client Libraries