Send File (v2)

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

There is no restriction on file size, number of emails, or number of files you can submit using this endpoint, as long as you have the credits in your account to cover the number of emails in submitted in the file, it will be accepted.

POST /v2/sendfile

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

URL Parameters

  • Parameter
    Description
  • file
    csv or txt file. Byte array contents for the submitted file. The content's header is type of "text/csv".
  • api_key
    Your API Key, found in your account. (Required)
  • return_url
    The URL will be used to call back when the validation is completed. (Optional)
  • email_address_column
    The column index of the email address in the file. Index starts from 1. (Required)
  • first_name_column
    The column index of the first name column. (Optional)
  • last_name_column
    The column index of the last name column. (Optional)
  • gender_column
    The column index of the gender column. (Optional)
  • ip_address_column
    The IP Address the email signed up from. (Optional)
  • has_header_row
    If the first row from the submitted file is a header row. true or false (Optional)

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
' Complete API Libraries and Wrappers can be found here: ' https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__dot_net' 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' requiredDimfirstNameColumn AsInteger? =5' optionalDimlastNameColumn AsInteger? =6' optionalDimgenderColumn AsInteger? =Nothing' optionalDimipAddressColumn AsInteger? =11' optionalDimhasHeaderRow AsBoolean? =True' optionalDimreturnUrl AsString=Nothing' optionalTryDimsendFileStatus AsSendFileStatus =SendFile(fileFullPath,apiKey,emailAddressColumn,firstNameColumn,lastNameColumn,genderColumn,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,ByValOptionalfirstNameColumn AsInteger? =Nothing,ByValOptionallastNameColumn AsInteger? =Nothing,ByValOptionalgenderColumn AsInteger? =Nothing,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/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")IffirstNameColumn IsNotNothingThenmultiPartContent.Add(NewStringContent(firstNameColumn.ToString()),"first_name_column")IflastNameColumn IsNotNothingThenmultiPartContent.Add(NewStringContent(lastNameColumn.ToString()),"last_name_column")IfgenderColumn IsNotNothingThenmultiPartContent.Add(NewStringContent(genderColumn.ToString()),"gender_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
// Complete API Libraries and Wrappers can be found here: // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__dot_net// https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__c-sharp// 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?firstNameColumn =5;//optionalint?lastNameColumn =6;//optionalint?genderColumn =null;//optionalint?ipAddressColumn =11;//optionalbool?hasHeaderRow =true;//optionalstringreturnUrl =null;//optionaltry{SendFileStatussendFileStatus =SendFile(fileFullPath,apiKey,emailAddressColumn,firstNameColumn,lastNameColumn,genderColumn,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?firstNameColumn =null,int?lastNameColumn =null,int?genderColumn =null,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/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(firstNameColumn !=null)multiPartContent.Add(newStringContent(firstNameColumn.ToString()),"first_name_column");if(lastNameColumn !=null)multiPartContent.Add(newStringContent(lastNameColumn.ToString()),"last_name_column");if(genderColumn !=null)multiPartContent.Add(newStringContent(genderColumn.ToString()),"gender_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// Complete API Libraries and Wrappers can be found here: // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__php$curl=curl_init();curl_setopt_array($curl,array(CURLOPT_URL=>"https://bulkapi.zerobounce.net/v2/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=>"------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name="api_key"replacewithyours------WebKitFormBoundary7MA4YWxkTrZu0gWContent-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;}?>
//Complete API Libraries and Wrappers can be found here: //https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__javaOkHttpClientclient =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/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();
# Complete API Libraries and Wrappers can be found here: # https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__pythonimporthttp.client conn =http.client.HTTPConnection("bulkapi,zerobounce,net")payload ="------WebKitFormBoundary7MA4YWxkTrZu0gWContent-Disposition: form-data; name="api_key"replacewithyours------WebKitFormBoundary7MA4YWxkTrZu0gWContent-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"))
// Complete API Libraries and Wrappers can be found here: // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__IOSimportFoundationletheaders =["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/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()
// Complete API Libraries and Wrappers can be found here: // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__IOS// 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/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];
// Complete API Libraries and Wrappers can be found here: // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__android//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"]}