---
title: "4. Delete Data"
canonical: "https://help.winbooks.be/space/DEV/3211299/4.%20Delete%20Data"
format: markdown
---
We have 5 ways for deleting data in API :

- Delete by single Code
- Delete By ID
- Delete by List of Code
- Delete By Criteria
- Delete all data objects

## A. Delete By Single Code

This function is used to delete a single object by giving its code.

### a. Using HTTP

|  |
| --- |
| `URL : { REST API Host } / app / { Winbooks OM } / { Code } / Folder/ { FolderCode } `  
`Method : DELETE`  
`Header :`  
`   ` `Authorization : Bearer {access_token}` |

If the object is deleted successfully, a response with success status 200 code will be returned

The example below will delete  <span style="color: #000000">a customer with code "</span> VLADIMIR <span style="color: #000000">" in folder "</span> PARFIWEB_DEMO <span style="color: #000000">"</span>

<span style="color: #000000">URL</span><span style="color: #003366">: </span> <span style="color: #0000ff">[https://rapi.winbooksonweb.be](https://rapi.winbooksonweb.be/)</span><span style="color: #0000ff">/app/Customer/VLADIMIR/Folder/PARFIWEB_DEMO</span>

<span style="color: #000000">Method : </span><span style="color: #800080"> </span><span style="color: #0000ff">DELETE</span>

<span style="color: #000000">Header </span><span style="color: #003366">: </span>

<span style="color: #000000"> </span> <span style="color: #ff6600">              Authorization</span><span style="color: #800080"> :</span><span style="color: #0000ff"> Bearer</span><span style="color: #800080"> gAAAAEg9vKjrggECqOrp6bekZ0KO6_86-URgC5D1xYxXqexQyaOu_St</span><span style="color: #0000ff"> ....</span>

### <span style="color: #000000">b. Using Winbooks.Apis.Services</span><span style="color: #000000">** **</span>

  
**Delete Customer By Code**

|  |
| --- |
| `//SERVICES WITH RESTAPIDEMO FOLDER`  
`EntitiesServices folderRESTAPIDEMO = new` `EntitiesServices(userCredential, "PARFIWEB_DEMO"` `);`  
`//DELETE CUSTOMER`  
`folderRESTAPIDEMO.DeleteByCode<Customer>(` `"VLADIMIR"` `);` |

## B. Delete By ID

### a. Using HTTP

The same as Delete By Single Code, just replay Code by ID

### b. Using Winbooks.Apis.Services** **

   
**Delete by Id**

|  |  |
| --- | --- |
|  | `//DELETE A CUSTOMER BY ID`  
`folderPARFIWEB.DeleteById<Customer>(` `"79A2E56E-2BE7-4216-BA75-9F9400FB45BD"` `);` |

## <span style="color: #000000">C. Delete By List of Codes</span>

<span style="color: #000000">This function is used to delete a list of objects by giving a list of codes.</span>

### <span style="color: #000000">a. Using HTTP</span>

|  |
| --- |
| `URL : { REST API Host } / app / { Winbooks OMS } / Folder / { FolderCode } ? code = {list of code seperate by ','` `}`  
`Method : DELETE`  
`Header :`  
`   ` `Authorization : Bearer {access_token}`  
`   ` `Accept : application/json {` `this` `will return` `the result in json format}` |

If the object is deleted successfully, a response with success status 200 code will be returned and contains the list of objects deleted successfully and failed

<span style="color: #000000">The example below will delete a list of customer with code "VLADIMIR,TITAN,JIMMY,JORDAN,SPARKLES" in folder "PARFIWEB_DEMO"</span>

<span style="color: #000000">URL</span> <span style="color: #000000"> </span> <span style="color: #000000">: </span><span style="color: #0000ff">[https://rapi.winbooksonweb.be](https://rapi.winbooksonweb.be/)</span><span style="color: #0000ff">/app/Customers/Folder/PARFIWEB_DEMO?code=VLADIMIR,TITAN,JIMMY,JORDAN,SPARKLES</span>

<span style="color: #000000">Method : </span><span style="color: #800080"> </span><span style="color: #0000ff">DELETE</span>

<span style="color: #000000">Header : </span>

<span style="color: #ff6600">               Authorization : </span><span style="color: #0000ff">Bearer gAAAAEg9vKjrggECqOrp6bekZ0KO6_86-URgC5D1xYxXqexQyaOu_St ....</span>

### <span style="color: #000000">b. Using Winbooks.Apis.Services </span>

|  |
| --- |
| `object[] arrayCustomerCode = new` `string[] { "ADAM"` `, "MIRANDA"` `, "Jordin"` `, "SPARKS"` `};`  
` ` `ICriteria filterDelete = new` `CustomerDAO().CreateCriteria();`  
` ` `filterDelete.Add(Condition.In(Customer.Names.Code, arrayCustomerCode));`  
` ` `folderPARFIWEB.DeleteFilter<Customer>(filterDelete);` |

## <span style="color: #000000">D. Delete By Criteria</span>

<span style="color: #000000">This function is used to delete a list of objects by giving a condition. </span>

### <span style="color: #000000">a. Using HTTP</span>

|  |
| --- |
| `URL :{ REST API Host } / app / { Winbooks OMS } / Folder / { FolderCode }/DeleteByCriteria`  
`Method : POST`  
`Header :`  
`   ` `Authorization : Bearer {access_token}`  
`Content : application/json`  
`Accept : application/json`  
`Body content : {Criteria in json format}` |

<span style="color: #000000">** for getting criteria in json format, please take a look at function "Get By Criteria"</span>

<span style="color: #000000">The example below will delete all Customers whose country code is "GB "</span>

<span style="color: #000000">URL : </span><span style="color: #0000ff">[https://rapi.winbooksonweb.be](https://rapi.winbooksonweb.be/)</span><span style="color: #0000ff">/app/Customers/Folder/PARFIWEB_DEMO/DeleteByCriteria</span>

<span style="color: #000000">Method </span> <span style="color: #0000ff">: POST</span>

<span style="color: #000000">Header </span><span style="color: #0000ff">:</span>

<span style="color: #0000ff">        </span><span style="color: #ff6600">Authorization </span><span style="color: #000000">: </span><span style="color: #0000ff">Bearer gAAAAEg9vKjrggECqOrp6bekZ0KO6_86-URgC5D1xYxXqexQyaOu_St ....</span>

<span style="color: #ff6600">        Content </span><span style="color: #000000">: </span><span style="color: #0000ff">application/json</span>

<span style="color: #ff6600">        Accept </span><span style="color: #000000">: </span><span style="color: #0000ff">application/json</span>

<span style="color: #ff6600"> Body content </span><span style="color: #0000ff">: {"Alias":"this","Association":{"t":{"OwnerAlias":null,"AliasName":"t","Type":"Winbooks.TORM.OM.Third, Winbooks.TORM.OM, Version=1.66.3.0, Culture=neutral, PublicKeyToken=null","JoinType":1,"Properties":    ["Id","Third_Id"],"Condition":null},"c":{"OwnerAlias":null,"AliasName":"c","Type":"Winbooks.TORM.OM.Country, Winbooks.TORM.OM, Version=1.66.3.0, Culture=neutral, PublicKeyToken=null","JoinType":1,"Properties":    ["Id","t.VatCountry_Id"],"Condition":null}},"Conditions":[{"Operator":0,"PropertyName":"c.Code","OtherPropertyName":"","Values":["GB"]}],"ProjectionsList":[],"Orders":{},"Params":{},"FirstResult":-1,"MaxResult":-1}</span>

### <span style="color: #000000">b. Using Winbooks.Apis.Services</span>

  
**Delete By Criteria**

|  |
| --- |
| `// DELETE BY CRITERIA           `  
`ICriteria criteria = new` `CustomerDAO().CreateCriteria();`  
`criteria.Add(Condition.Eq(Customer.Names.IsLocked, false` `));`  
`criteria.Add(Condition.Eq(Customer.Names.IsHidden, false` `));`  
`EntitiesServices folderRESTAPIDEMO = new` `EntitiesServices(userCredential, "PARIWEBDEMO"` `);`  
`folderPARFIWEB.DeleteFilter<Customer>(criteria);` |

## <span style="color: #000000">E. Delete All Data Objects</span><span style="color: #000000">** **</span>

<span style="color: #000000">This function is used to clear all data objects.</span>

### <span style="color: #000000">a. Using HTTP</span>

|  |
| --- |
| `URL : { REST API Host } / app / { Winbooks OMS } / Folder / { FolderCode }`  
`Method : DELETE`  
`Header : `  
`   ` `Authorization : Bearer { access_token}`  
`   ` `Accept : application/json` |

### <span style="color: #000000">b. Using Winbooks.Apis.Service</span><span style="color: #000000">**  **</span>

  
**Delete All Customer**

|  |
| --- |
| `EntitiesServices folderRESTAPIDEMO = new` `EntitiesServices(userCredential, "PARIWEB_DEMO"` `);`  
`folderRESTAPIDEMO.DeleteAll<Customer>();` |