# Delete files

## Delete files from your IM Cloud Storage

<mark style="color:green;">`POST`</mark> `https://api.imagemash.io/v1/storage/deleteFiles`

#### Headers

| Name                                     | Type | Description  |
| ---------------------------------------- | ---- | ------------ |
| apikey<mark style="color:red;">\*</mark> |      | Your API Key |

#### Request Body

| Name                                        | Type  | Description                                             |
| ------------------------------------------- | ----- | ------------------------------------------------------- |
| filePaths<mark style="color:red;">\*</mark> | Array | Array of filePaths. Eg. `/jeep.png` or `/cars/jeep.png` |

{% tabs %}
{% tab title="200: OK Object contains info about result" %}

```json
{
    "deletedCount": 2,
    "erroredCount": 0,
    "deletedFiles": [ 
        "/Asset 1.png",
        "/Asset 2.png"
    ],
    "erroredFiles": []
}
```

{% endtab %}

{% tab title="400: Bad Request Error" %}

```javascript
{
    msg: "error details"
    details: "..."
}   // Explanation of error
```

{% endtab %}

{% tab title="401: Unauthorized Unauthorized. Check your API Key" %}

```html
Unauthorized
```

{% endtab %}

{% tab title="500: Internal Server Error Server Error" %}

```javascript
{
    // Please contact support if you are getting this error constantly.
}
```

{% endtab %}
{% endtabs %}

#### Example Codes

{% tabs %}
{% tab title="cURL" %}

```sh
curl --location 'https://api.imagemash.io/v1/storage/deleteFiles' \
--header 'apikey: your_api_key' \
--header 'Content-Type: application/json' \
--data '{
    "filePaths":[
        "/Asset 1.png",
        "/Asset 2.png"
    ]
}'
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using RestSharp;
using System.Threading;
using System.Threading.Tasks;
namespace HelloWorldApplication {
  class HelloWorld {
    static async Task Main(string[] args) {
      var options = new RestClientOptions("https://api.imagemash.io")
      {
        MaxTimeout = -1,
      };
      var client = new RestClient(options);
      var request = new RestRequest("/v1/storage/deleteFiles", Method.Post);
      request.AddHeader("apikey", "your_api_key");
      request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
      request.AddParameter("filePaths", "/Asset 1.png");
      request.AddParameter("filePaths", "/Asset 2.png");
      RestResponse response = await client.ExecuteAsync(request);
      Console.WriteLine(response.Content);
    }
  }
}

```

{% endtab %}

{% tab title="Java" %}

```java
import java.io.*;
import okhttp3.*;
public class main {
  public static void main(String []args) throws IOException{
    OkHttpClient client = new OkHttpClient().newBuilder()
      .build();
    MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
    RequestBody body = RequestBody.create(mediaType, "filePaths=/Asset 1.png&filePaths=/Asset 2.png");
    Request request = new Request.Builder()
      .url("https://api.imagemash.io/v1/storage/deleteFiles")
      .method("POST", body)
      .addHeader("apikey", "your_api_key")
      .addHeader("Content-Type", "application/x-www-form-urlencoded")
      .build();
    Response response = client.newCall(request).execute();
    System.out.println(response.body().string());
  }
}

```

{% endtab %}

{% tab title="Node.js" %}

```javascript
var axios = require('axios');
var data = JSON.stringify({
  "filePaths": [
    "/Asset 1.png",
    "/Asset 2.png"
  ]
});

var config = {
  method: 'post',
maxBodyLength: Infinity,
  url: 'https://api.imagemash.io/v1/storage/deleteFiles',
  headers: { 
    'apikey': 'your_api_key', 
    'Content-Type': 'application/json'
  },
  maxRedirects: 0,
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.imagemash.io/v1/storage/deleteFiles"

payload='filePaths=%2FAsset%201.png&filePaths=%2FAsset%202.png'
headers = {
  'apikey': 'your_api_key',
  'Content-Type': 'application/x-www-form-urlencoded'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "uri"
require "net/http"

url = URI("https://api.imagemash.io/v1/storage/deleteFiles")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["apikey"] = "your_api_key"
request["Content-Type"] = "application/x-www-form-urlencoded"
request.body = "filePaths=%2FAsset%201.png&filePaths=%2FAsset%202.png"

response = https.request(request)
puts response.read_body

```

{% endtab %}
{% endtabs %}
