AI Scoring API: Send File

The scoring sendfile API allows a user to send a file for bulk email scoring. The content type needs to be multipart/form-data. Please refer to the C# example for details.

POST /V2/SCORING/SENDFILE

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

URL Parameters

  • Parameter
    Required/Optional
    Description
  • file
    Required
    The csv or txt file. Byte array contents for the submitted file. The content's header is type of "text/csv"
  • api_key
    Required
    Your API Key, found in your account
  • email_address_column
    Required
    The column index of the email address in the file. Index starts at 1
  • return_url
    Optional
    The URL will be used as a callback when the scoring service is completed
  • has_header_row
    Optional
    If the first row from the submitted file is a header row. True or False

If a return_url was specified in the Multipart Form Data during the send file request, we will POST the following data to the URL when the validation process is complete.

{file_id": "aaaaaaaa-zzzz-xxxx-yyyy-5003727fffff","file_name":"Your file name.csv","upload_date":"10/20/2018 4:35:58 PM"}

Send File Code Samples

  • Visual Basic
  • C#
  • PHP
  • Java
  • Python
  • Swift
  • Objective C
  • Android Java
' Send File Sample in VB.netPublicClassSendFileStatus PublicPropertysuccess AsBooleanPublicPropertymessage AsStringPublicPropertyfile_name AsStringPublicPropertyfile_id AsStringEndClassPrivateSharedSubSendFileAPITest()DimfileFullPath AsString=$"full file path of a csv or txt file"' requiredDimapiKey AsString="replace with your api key here"' requiredDimemailAddressColumn AsInteger=2' requiredDimipAddressColumn AsInteger? =11' optionalDimhasHeaderRow AsBoolean? =True' optionalDimreturnUrl AsString=Nothing' optionalTryDimsendFileStatus AsSendFileStatus =SendFile(fileFullPath,apiKey,emailAddressColumn,ipAddressColumn,hasHeaderRow,returnUrl).Result Console.Write(JsonConvert.SerializeObject(sendFileStatus,Formatting.Indented))Catchex AsException Console.Write(ex.InnerException.Message)EndTryConsole.ReadKey()EndSubPublicSharedAsync FunctionSendFile(ByValfileFullPath AsString,ByValapiKey AsString,ByValemailAddressColumn AsInteger,ByValOptionalipAddressColumn AsInteger? =Nothing,ByValOptionalhasHeaderRow AsBoolean? =Nothing,ByValOptionalreturnUrl AsString=Nothing)AsTask(OfSendFileStatus)IfString.IsNullOrEmpty(fileFullPath)ThenThrowNewException("Error: fileFullPath is required")IfString.IsNullOrEmpty(apiKey)ThenThrowNewException("Error: apiKey is required")Dimfi =NewFileInfo(fileFullPath)DimfileContents =File.ReadAllBytes(fi.FullName)DimfileName =fi.NameDimuri AsUri =NewUri("https://bulkapi.zerobounce.net/v2/scoring/sendfile")Usingclient =NewHttpClient()Usingrequest =NewHttpRequestMessage(HttpMethod.Post,uri)DimmultiPartContent AsMultipartFormDataContent =NewMultipartFormDataContent()DimbyteArrayContent AsByteArrayContent =NewByteArrayContent(fileContents)byteArrayContent.Headers.Add("Content-Type","text/csv")multiPartContent.Add(byteArrayContent,"file",fileName)multiPartContent.Add(NewStringContent(apiKey),"api_key")multiPartContent.Add(NewStringContent(emailAddressColumn.ToString()),"email_address_column")IfipAddressColumn IsNotNothingThenmultiPartContent.Add(NewStringContent(ipAddressColumn.ToString()),"ip_address_column")IfhasHeaderRow IsNotNothingThenmultiPartContent.Add(NewStringContent(If((hasHeaderRow =True),"true","false")),"has_header_row")IfreturnUrl IsNotNothingThenmultiPartContent.Add(NewStringContent(returnUrl.ToString()),"return_url")request.Content =multiPartContent Usingresponse =Await client.SendAsync(request,HttpCompletionOption.ResponseContentRead,CancellationToken.None).ConfigureAwait(False)Dimcontent =Await response.Content.ReadAsStringAsync()Ifresponse.IsSuccessStatusCode =FalseThenDimerrorAsString=$"StatusCode ={CInt(response.StatusCode)},Content ={content}" ThrowNewException(error)EndIfReturnJsonConvert.DeserializeObject(OfSendFileStatus)(content)EndUsingEndUsingEndUsingEndFunction
// Send File Sample in C#publicclassSendFileStatus{publicboolsuccess {get;set;}publicstringmessage {get;set;}publicstringfile_name {get;set;}publicstringfile_id {get;set;}}privatestaticvoidSendFileAPITest(){stringfileFullPath =$"full file path of a csv or txt file";//requiredstringapiKey ="replace with your api key here";//required intemailAddressColumn =2;//requiredint?ipAddressColumn =11;//optionalbool?hasHeaderRow =true;//optionalstringreturnUrl =null;//optionaltry{SendFileStatussendFileStatus =SendFile(fileFullPath,apiKey,emailAddressColumn,ipAddressColumn,hasHeaderRow,returnUrl).Result;Console.Write(JsonConvert.SerializeObject(sendFileStatus,Formatting.Indented));}catch(Exceptionex){Console.Write(ex.InnerException.Message);}Console.ReadKey();}publicstaticasyncTask<SendFileStatus>SendFile(stringfileFullPath,stringapiKey,intemailAddressColumn,int?ipAddressColumn =null,bool?hasHeaderRow =null,stringreturnUrl =null){if(string.IsNullOrEmpty(fileFullPath))thrownewException("Error: fileFullPath is required");if(string.IsNullOrEmpty(apiKey))thrownewException("Error: apiKey is required");varfi =newFileInfo(fileFullPath);varfileContents =File.ReadAllBytes(fi.FullName);varfileName =fi.Name;Uriuri =newUri(@"https://bulkapi.zerobounce.net/v2/scoring/sendfile");using(varclient =newHttpClient())using(varrequest =newHttpRequestMessage(HttpMethod.Post,uri)){MultipartFormDataContentmultiPartContent =newMultipartFormDataContent();ByteArrayContentbyteArrayContent =newByteArrayContent(fileContents);byteArrayContent.Headers.Add("Content-Type","text/csv");multiPartContent.Add(byteArrayContent,"file",fileName);multiPartContent.Add(newStringContent(apiKey),"api_key");multiPartContent.Add(newStringContent(emailAddressColumn.ToString()),"email_address_column");if(ipAddressColumn !=null)multiPartContent.Add(newStringContent(ipAddressColumn.ToString()),"ip_address_column");if(hasHeaderRow !=null)multiPartContent.Add(newStringContent((hasHeaderRow ==true)?"true":"false"),"has_header_row");if(returnUrl !=null)multiPartContent.Add(newStringContent(returnUrl.ToString()),"return_url");request.Content =multiPartContent;using(varresponse =awaitclient.SendAsync(request,HttpCompletionOption.ResponseContentRead,CancellationToken.None).ConfigureAwait(false)){varcontent =awaitresponse.Content.ReadAsStringAsync();if(response.IsSuccessStatusCode ==false){varerror =$"StatusCode={(int)response.StatusCode}, Content={content}";thrownewException(error);}returnJsonConvert.DeserializeObject<SendFileStatus>(content);}}}
<?php$curl=curl_init();curl_setopt_array($curl,array(CURLOPT_URL=>"https://bulkapi.zerobounce.net/v2/scoring/sendfile",CURLOPT_RETURNTRANSFER=>true,CURLOPT_ENCODING=>"",CURLOPT_MAXREDIRS=>10,CURLOPT_TIMEOUT=>30,CURLOPT_HTTP_VERSION=>CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST=>"POST",CURLOPT_POSTFIELDS=>"------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="api_key" replacewithyours
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="email_address_column" replacewithyours
------WebKitFormBoundary7MA4YWxkTrZu0gW--",CURLOPT_HTTPHEADER=>array("Postman-Token: fae6714d-dc09-4e08-b50d-c97030603b61","cache-control: no-cache","content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"),));$response=curl_exec($curl);$err=curl_error($curl);curl_close($curl);if($err){echo"cURL Error #:".$err;}else{echo$response;}?>
OkHttpClientclient =newOkHttpClient();MediaTypemediaType =MediaType.parse("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");RequestBodybody =RequestBody.create(mediaType,"------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition:form-data;name="api_key"replacewithyours
------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition:form-data;name="email_address_column"replacewithyours
------WebKitFormBoundary7MA4YWxkTrZu0gW--");Requestrequest =newRequest.Builder().url("https://bulkapi.zerobounce.net/v2/scoring/sendfile").post(body).addHeader("content-type","multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW").addHeader("cache-control","no-cache").addHeader("Postman-Token","25d608ba-6cb5-4c8c-88d7-d47276c67d8e").build();Responseresponse =client.newCall(request).execute();
importhttp.client conn =http.client.HTTPConnection("bulkapi,zerobounce,net")payload ="------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition:form-data;name="api_key"replacewithyours
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition:form-data;name="email_address_column"replacewithyours
------WebKitFormBoundary7MA4YWxkTrZu0gW--" headers ={'content-type':"multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",'cache-control':"no-cache",'Postman-Token':"bc455eda-9884-417e-b16f-3a5fef3f7540"}conn.request("POST","v2,sendfile",payload,headers)res =conn.getresponse()data =res.read()print(data.decode("utf-8"))
importFoundationletheaders =["content-type":"multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW","cache-control":"no-cache","Postman-Token":"2f68fcc3-d9b6-458b-b613-56f6a03e6617"]letparameters =[["name":"api_key","value":"replacewithyours"],["name":"email_address_column","value":"replacewithyours"]]letboundary ="----WebKitFormBoundary7MA4YWxkTrZu0gW"varbody =""varerror:NSError?=nilforparam inparameters {letparamName =param["name"]!body +="--(boundary)" body +="Content-Disposition:form-data; name="(paramName)""ifletfilename =param["fileName"]{letcontentType =param["content-type"]!letfileContent =String(contentsOfFile:filename,encoding:String.Encoding.utf8)if(error !=nil){print(error)}body +="; filename="(filename)"
" body +="Content-Type:(contentType)" body +=fileContent }elseifletparamValue =param["value"]{body +=" (paramValue)" }}letrequest =NSMutableURLRequest(url:NSURL(string:"https://bulkapi.zerobounce.net/v2/scoring/sendfile")!asURL,cachePolicy:.useProtocolCachePolicy,timeoutInterval:10.0)request.httpMethod ="POST"request.allHTTPHeaderFields =headers request.httpBody =postData asDataletsession =URLSession.shared letdataTask =session.dataTask(with:request asURLRequest,completionHandler:{(data,response,error)->Voidinif(error !=nil){print(error)}else{lethttpResponse =response as?HTTPURLResponseprint(httpResponse)}})dataTask.resume()
// Please select VB or C# language for Send File Sample#import <Foundation/Foundation.h>NSDictionary *headers =@{@"content-type":@"multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",@"cache-control":@"no-cache",@"Postman-Token":@"92c5b06e-624f-44e5-bd86-f537bc6cef67"};NSArray *parameters =@[@{@"name":@"api_key",@"value":@"replacewithyours"},@{@"name":@"email_address_column",@"value":@"replacewithyours"}];NSString *boundary =@"----WebKitFormBoundary7MA4YWxkTrZu0gW";NSError *error;NSMutableString *body =[NSMutableString string];for(NSDictionary *param inparameters){[body appendFormat:@"--%@",boundary];if(param[@"fileName"]){[body appendFormat:@"Content-Disposition:form-data; name="%@"; filename="%@"
", param[@"name"], param[@"fileName"]];[body appendFormat:@"Content-Type:%@", param[@"contentType"]];[body appendFormat:@"%@",[NSString stringWithContentsOfFile:param[@"fileName"]encoding:NSUTF8StringEncoding error:&error]];if(error){NSLog(@"%@",error);}}else{[body appendFormat:@"Content-Disposition:form-data; name="%@" ", param[@"name"]];[body appendFormat:@"%@",param[@"value"]];}}[body appendFormat:@"
--%@--",boundary];NSData *postData =[body dataUsingEncoding:NSUTF8StringEncoding];NSMutableURLRequest *request =[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://bulkapi.zerobounce.net/v2/scoring/sendfile"]cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];[request setHTTPMethod:@"POST"];[request setAllHTTPHeaderFields:headers];[request setHTTPBody:postData];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];
//N/A

Endpoint Response

Successful Response

{"success":true,"message":"File Accepted","file_name":"Your file name.csv","file_id":"aaaaaaaa-zzzz-xxxx-yyyy-5003727fffff"}

Error Response

{"success":false,"message":["Error messages"]}