AI Scoring API: Delete File

The scoring deletefile API deletes the file that was submitted using scoring sendfile API. File can be deleted only when its status is Complete.

POST /V2/SCORING/DELETEFILE

API URL: https://bulkapi.zerobounce.net/v2/scoring/deletefile

URL Parameters

  • Parameter
    Required/Optional
    Description
  • api_key
    Required
    Your API Key, found in your account
  • file_id
    Required
    The returned file ID when calling scoring sendfile API

Delete File Code Samples

  • Visual Basic
  • C#
  • PHP
  • Java
  • Python
  • Swift
  • Objective C
      
' Delete File Sample in VB.net

Public Class ResponseResult
   Public Property success As Boolean
   Public Property message As String
   Public Property file_id As String
   Public Property file_name As String
End Class

Private Shared Sub DeleteFileAPITest()
   Dim apiKey As String = "replace with your api key here"
   Dim fileID As String = "replace with the returned file ID when calling sendfile API"

   Try
       Dim responseResult As ResponseResult = DeleteFileAsync(apiKey, fileID).Result
       Console.Write(JsonConvert.SerializeObject(responseResult, Formatting.Indented))
   Catch ex As Exception
       Console.Write(ex.InnerException.Message)
   End Try

   Console.ReadKey()
End Sub

Public Shared Async Function DeleteFileAsync(ByVal apiKey As String, ByVal fileID As String) As Task(Of ResponseResult)
   If String.IsNullOrEmpty(apiKey) Then Throw New Exception("Error: apiKey is required")
   If String.IsNullOrEmpty(fileID) Then Throw New Exception("Error: fileID is required")
   Dim uri As Uri = New Uri($"https://bulkapi.zerobounce.net/v2/scoring/deletefile?api_key={apiKey}&file_id={fileID}")

   Using client = New HttpClient()

       Using request = New HttpRequestMessage(HttpMethod.[Get], uri)

           Using response = Await client.SendAsync(request).ConfigureAwait(False)
               Dim content = Await response.Content.ReadAsStringAsync()

               If response.IsSuccessStatusCode = False Then
                   Dim [error] = $"StatusCode = {CInt(response.StatusCode)}, Content = {content}"
                   Throw New Exception([error])
               End If

               Return JsonConvert.DeserializeObject(Of ResponseResult)(content)
           End Using
       End Using
   End Using
End Function
   

// Delete File Sample in C#

public class ResponseResult
{
   public bool success { get; set; }
   public string message { get; set; }
   public string file_id { get; set; }
   public string file_name { get; set; }
}

private static void DeleteFileAPITest()
{
   string apiKey = "replace with your api key here";
   string fileID = "replace with the returned file ID when calling sendfile API";

   try
   {
       ResponseResult responseResult = DeleteFileAsync(apiKey, fileID).Result;
       Console.Write(JsonConvert.SerializeObject(responseResult, Formatting.Indented));
   }
   catch (Exception ex)
   {
       Console.Write(ex.InnerException.Message);
   }
   Console.ReadKey();
}

public static async Task<ResponseResult> DeleteFileAsync(string apiKey, string fileID)
{
   if (string.IsNullOrEmpty(apiKey))
       throw new Exception("Error: apiKey is required");
   if (string.IsNullOrEmpty(fileID))
       throw new Exception("Error: fileID is required");

   Uri uri = new Uri($"https://bulkapi.zerobounce.net/v2/scoring/deletefile?api_key={apiKey}&file_id={fileID}");

   using (var client = new HttpClient())
   using (var request = new HttpRequestMessage(HttpMethod.Get, uri))
   using (var response = await client.SendAsync(request).ConfigureAwait(false))
   {
       var content = await response.Content.ReadAsStringAsync();

       if (response.IsSuccessStatusCode == false)
       {
           var error = $"StatusCode = {(int)response.StatusCode}, Content = {content}";
           throw new Exception(error);
       }

       return JsonConvert.DeserializeObject<ResponseResult>(content);
   }
}
   

 <?php

 $curl = curl_init();
 
 curl_setopt_array($curl, array(
   CURLOPT_URL => "https://bulkapi.zerobounce.net/v2/scoring/deletefile?api_key=replacewithyours&file_id=replacewithyours",
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_ENCODING => "",
   CURLOPT_MAXREDIRS => 10,
   CURLOPT_TIMEOUT => 30,
   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
   CURLOPT_CUSTOMREQUEST => "GET",
   CURLOPT_POSTFIELDS => "",
   CURLOPT_HTTPHEADER => array(
     "Postman-Token: 91504cea-f92f-46b0-97a4-338167072887",
     "cache-control: no-cache"
   ),
 ));
 
 $response = curl_exec($curl);
 $err = curl_error($curl);
 
 curl_close($curl);
 
 if ($err) {
   echo "cURL Error #:" . $err;
 } else {
   echo $response;
 }
 ?>
   

OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
 .url("https://bulkapi.zerobounce.net/v2/scoring/deletefile?api_key=replacewithyours&file_id=replacewithyours")
 .get()
 .addHeader("cache-control", "no-cache")
 .addHeader("Postman-Token", "7fffd7a4-b2fd-4e8b-ac85-4099411f27ce")
 .build();

Response response = client.newCall(request).execute();
   

import http.client

conn = http.client.HTTPConnection("bulkapi,zerobounce,net")

payload = ""

headers = {
   'cache-control': "no-cache",
   'Postman-Token': "caa917fe-45ce-45ae-9456-2b039b999dcb"
   }

conn.request("GET", "v2,deletefile", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
   
   

// Please select VB or C# language for File Status Sampleimport Foundation

let headers = [
 "cache-control": "no-cache",
 "Postman-Token": "4f1b92e2-034f-4fa0-94d9-b097d768668a"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://bulkapi.zerobounce.net/v2/scoring/deletefile?api_key=replacewithyours&file_id=replacewithyours")! as URL,
                                       cachePolicy: .useProtocolCachePolicy,
                                   timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
 if (error != nil) {
   print(error)
 } else {
   let httpResponse = response as? HTTPURLResponse
   print(httpResponse)
 }
})

dataTask.resume()
   

#import <Foundation/Foundation.h>

NSDictionary *headers = @{ @"cache-control": @"no-cache",
                           @"Postman-Token": @"5e9c24ae-b577-4e33-8748-83f14e151ae9" };

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://bulkapi.zerobounce.net/v2/scoring/deletefile?api_key=replacewithyours&file_id=replacewithyours"]
                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                   timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
       completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
           if (error) {
               NSLog(@"%@", error);
           } else {
               NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
               NSLog(@"%@", httpResponse);
           }
       }];
[dataTask resume];
   

Endpoint Response

Successful Response

      
 {
   "success": true,
   "message": "File Deleted",
   "file_name": "test2",
   "file_id": "b222a0fd-90d5-416c-8f1a-9cc3851fc823"
 }
   

Error Response

      
{
 "success": false,
 "message": "File cannot be found."
}