|
| 1 | +declare namespace ZeroBounceSDK { |
| 2 | +interface EmailBatchItem { |
| 3 | + email_address: string; |
| 4 | +} |
| 5 | + |
| 6 | +interface SendFilePayload { |
| 7 | + /** csv or txt file. Byte array contents for the submitted file. The content's header is type of "text/csv". */ |
| 8 | + file: File | Blob; |
| 9 | + |
| 10 | + /** The column index of the email address in the file. Index starts from 1 */ |
| 11 | + email_address_column: number; |
| 12 | + |
| 13 | + /** The URL will be used to call back when the validation is completed */ |
| 14 | + return_url?: string; |
| 15 | + |
| 16 | + /** The column index of the first name column */ |
| 17 | + first_name_column?: number; |
| 18 | + |
| 19 | + /** The column index of the last name column */ |
| 20 | + last_name_column?: number; |
| 21 | + |
| 22 | + /** The column index of the gender column */ |
| 23 | + gender_column?: number; |
| 24 | + |
| 25 | + /** The column index of the IP address the email signed up from */ |
| 26 | + ip_address_column?: number; |
| 27 | + |
| 28 | + /** Whether the first row from the submitted file is a header row */ |
| 29 | + has_header_row?: boolean; |
| 30 | + |
| 31 | + /** Whether to remove duplicate emails (default: true). Returns 400 error if >50% duplicates removed */ |
| 32 | + remove_duplicate?: boolean; |
| 33 | +} |
| 34 | + |
| 35 | +interface FileErrorResponse { |
| 36 | + /** Indicates the file upload failed */ |
| 37 | + success: false; |
| 38 | + /** Error message describing the failure */ |
| 39 | + error_message: string; |
| 40 | +} |
| 41 | + |
| 42 | +type SendFileResponse = |
| 43 | + | { |
| 44 | + /** Indicates the file was successfully accepted */ |
| 45 | + success: true; |
| 46 | + /** Success message */ |
| 47 | + message: string; |
| 48 | + /** Name of the uploaded file */ |
| 49 | + file_name: string; |
| 50 | + /** Unique identifier for the uploaded file */ |
| 51 | + file_id: string; |
| 52 | + } |
| 53 | + | FileErrorResponse; |
| 54 | + |
| 55 | +type FileStatusResponse = |
| 56 | + | { |
| 57 | + /** Indicates the request was successful */ |
| 58 | + success: true; |
| 59 | + /** Unique identifier for the file */ |
| 60 | + file_id: string; |
| 61 | + /** Name of the file */ |
| 62 | + file_name: string; |
| 63 | + /** Upload date in ISO 8601 format */ |
| 64 | + upload_date: string; |
| 65 | + /** Current status of the file processing */ |
| 66 | + file_status: string; |
| 67 | + /** Percentage of file processing completed */ |
| 68 | + complete_percentage: string; |
| 69 | + /** Return URL provided when calling sendfile API, if any */ |
| 70 | + return_url?: string; |
| 71 | + } |
| 72 | + | FileErrorResponse; |
| 73 | + |
| 74 | +interface GuessFormatPayload { |
| 75 | + domain: string; |
| 76 | + first_name?: string; |
| 77 | + middle_name?: string; |
| 78 | + last_name?: string; |
| 79 | +} |
| 80 | + |
| 81 | +type GetFileResponse = Blob; |
| 82 | + |
| 83 | +/** |
| 84 | + * Response from the delete file endpoint |
| 85 | + */ |
| 86 | +type DeleteFileResponse = |
| 87 | + | { |
| 88 | + /** Indicates the file was successfully deleted */ |
| 89 | + success: true; |
| 90 | + /** Success message */ |
| 91 | + message: string; |
| 92 | + /** Name of the deleted file */ |
| 93 | + file_name: string; |
| 94 | + /** Unique identifier of the deleted file */ |
| 95 | + file_id: string; |
| 96 | + } |
| 97 | + | FileErrorResponse; |
| 98 | + |
| 99 | +/** |
| 100 | + * Response from the ZeroBounce email validation API |
| 101 | + */ |
| 102 | +interface ValidateEmailResponse { |
| 103 | + /** The email address being validated */ |
| 104 | + address: string; |
| 105 | + |
| 106 | + /** Validation status: valid, invalid, catch-all, unknown, spamtrap, abuse, or do_not_mail */ |
| 107 | + status: |
| 108 | + | "valid" |
| 109 | + | "invalid" |
| 110 | + | "catch-all" |
| 111 | + | "unknown" |
| 112 | + | "spamtrap" |
| 113 | + | "abuse" |
| 114 | + | "do_not_mail"; |
| 115 | + |
| 116 | + /** Detailed sub-status providing additional context about the validation result */ |
| 117 | + sub_status: |
| 118 | + | "alternate" |
| 119 | + | "antispam_system" |
| 120 | + | "greylisted" |
| 121 | + | "mail_server_temporary_error" |
| 122 | + | "forcible_disconnect" |
| 123 | + | "mail_server_did_not_respond" |
| 124 | + | "timeout_exceeded" |
| 125 | + | "failed_smtp_connection" |
| 126 | + | "mailbox_quota_exceeded" |
| 127 | + | "exception_occurred" |
| 128 | + | "possible_trap" |
| 129 | + | "role_based" |
| 130 | + | "global_suppression" |
| 131 | + | "mailbox_not_found" |
| 132 | + | "no_dns_entries" |
| 133 | + | "failed_syntax_check" |
| 134 | + | "possible_typo" |
| 135 | + | "unroutable_ip_address" |
| 136 | + | "leading_period_removed" |
| 137 | + | "does_not_accept_mail" |
| 138 | + | "alias_address" |
| 139 | + | "role_based_catch_all" |
| 140 | + | "disposable" |
| 141 | + | "toxic" |
| 142 | + | "accept_all"; |
| 143 | + |
| 144 | + /** The portion of the email address before the "@" symbol */ |
| 145 | + account: string; |
| 146 | + |
| 147 | + /** The portion of the email address after the "@" symbol */ |
| 148 | + domain: string; |
| 149 | + |
| 150 | + /** Suggested correction for an email typo, if detected */ |
| 151 | + did_you_mean: string | null; |
| 152 | + |
| 153 | + /** Age of the email domain in days, or null if unavailable */ |
| 154 | + domain_age_days: number | null; |
| 155 | + |
| 156 | + /** Last activity date bucket: 30, 60, 90, 180, 365, or 365+ days */ |
| 157 | + active_in_days: "30" | "60" | "90" | "180" | "365" | "365+" | null; |
| 158 | + |
| 159 | + /** Whether the email comes from a free provider */ |
| 160 | + free_email: boolean; |
| 161 | + |
| 162 | + /** Whether the domain has an MX record */ |
| 163 | + mx_found: boolean; |
| 164 | + |
| 165 | + /** The preferred MX record of the domain */ |
| 166 | + mx_record: string; |
| 167 | + |
| 168 | + /** The SMTP provider of the email (BETA feature) */ |
| 169 | + smtp_provider: string | null; |
| 170 | + |
| 171 | + /** First name of the email owner, if available */ |
| 172 | + firstname: string | null; |
| 173 | + |
| 174 | + /** Last name of the email owner, if available */ |
| 175 | + lastname: string | null; |
| 176 | + |
| 177 | + /** Gender of the email owner, if available */ |
| 178 | + gender: string | null; |
| 179 | + |
| 180 | + /** City associated with the IP address passed in */ |
| 181 | + city: string | null; |
| 182 | + |
| 183 | + /** Region/state associated with the IP address passed in */ |
| 184 | + region: string | null; |
| 185 | + |
| 186 | + /** Zipcode associated with the IP address passed in */ |
| 187 | + zipcode: string | null; |
| 188 | + |
| 189 | + /** Country associated with the IP address passed in */ |
| 190 | + country: string | null; |
| 191 | + |
| 192 | + /** UTC timestamp when the email was validated */ |
| 193 | + processed_at: string; |
| 194 | +} |
| 195 | + |
| 196 | +/** |
| 197 | + * Response from the ZeroBounce API usage endpoint |
| 198 | + */ |
| 199 | +interface ApiUsageResponse { |
| 200 | + /** Total number of times the API has been called */ |
| 201 | + total: number; |
| 202 | + |
| 203 | + /** Total valid email addresses returned by the API */ |
| 204 | + status_valid: number; |
| 205 | + |
| 206 | + /** Total invalid email addresses returned by the API */ |
| 207 | + status_invalid: number; |
| 208 | + |
| 209 | + /** Total catch-all email addresses returned by the API */ |
| 210 | + status_catch_all: number; |
| 211 | + |
| 212 | + /** Total do not mail email addresses returned by the API */ |
| 213 | + status_do_not_mail: number; |
| 214 | + |
| 215 | + /** Total spamtrap email addresses returned by the API */ |
| 216 | + status_spamtrap: number; |
| 217 | + |
| 218 | + /** Total unknown email addresses returned by the API */ |
| 219 | + status_unknown: number; |
| 220 | + |
| 221 | + /** Total number of times the API has a sub status of "toxic" */ |
| 222 | + sub_status_toxic: number; |
| 223 | + |
| 224 | + /** Total number of times the API has a sub status of "disposable" */ |
| 225 | + sub_status_disposable: number; |
| 226 | + |
| 227 | + /** Total number of times the API has a sub status of "role_based" */ |
| 228 | + sub_status_role_based: number; |
| 229 | + |
| 230 | + /** Total number of times the API has a sub status of "possible_trap" */ |
| 231 | + sub_status_possible_trap: number; |
| 232 | + |
| 233 | + /** Total number of times the API has a sub status of "global_suppression" */ |
| 234 | + sub_status_global_suppression: number; |
| 235 | + |
| 236 | + /** Total number of times the API has a sub status of "timeout_exceeded" */ |
| 237 | + sub_status_timeout_exceeded: number; |
| 238 | + |
| 239 | + /** Total number of times the API has a sub status of "mail_server_temporary_error" */ |
| 240 | + sub_status_mail_server_temporary_error: number; |
| 241 | + |
| 242 | + /** Total number of times the API has a sub status of "mail_server_did_not_respond" */ |
| 243 | + sub_status_mail_server_did_not_respond: number; |
| 244 | + |
| 245 | + /** Total number of times the API has a sub status of "greylisted" */ |
| 246 | + sub_status_greylisted: number; |
| 247 | + |
| 248 | + /** Total number of times the API has a sub status of "antispam_system" */ |
| 249 | + sub_status_antispam_system: number; |
| 250 | + |
| 251 | + /** Total number of times the API has a sub status of "does_not_accept_mail" */ |
| 252 | + sub_status_does_not_accept_mail: number; |
| 253 | + |
| 254 | + /** Total number of times the API has a sub status of "exception_occurred" */ |
| 255 | + sub_status_exception_occurred: number; |
| 256 | + |
| 257 | + /** Total number of times the API has a sub status of "failed_syntax_check" */ |
| 258 | + sub_status_failed_syntax_check: number; |
| 259 | + |
| 260 | + /** Total number of times the API has a sub status of "mailbox_not_found" */ |
| 261 | + sub_status_mailbox_not_found: number; |
| 262 | + |
| 263 | + /** Total number of times the API has a sub status of "unroutable_ip_address" */ |
| 264 | + sub_status_unroutable_ip_address: number; |
| 265 | + |
| 266 | + /** Total number of times the API has a sub status of "possible_typo" */ |
| 267 | + sub_status_possible_typo: number; |
| 268 | + |
| 269 | + /** Total number of times the API has a sub status of "no_dns_entries" */ |
| 270 | + sub_status_no_dns_entries: number; |
| 271 | + |
| 272 | + /** Total role based catch alls the API has a sub status of "role_based_catch_all" */ |
| 273 | + sub_status_role_based_catch_all: number; |
| 274 | + |
| 275 | + /** Total number of times the API has a sub status of "mailbox_quota_exceeded" */ |
| 276 | + sub_status_mailbox_quota_exceeded: number; |
| 277 | + |
| 278 | + /** Total forcible disconnects the API has a sub status of "forcible_disconnect" */ |
| 279 | + sub_status_forcible_disconnect: number; |
| 280 | + |
| 281 | + /** Total failed SMTP connections the API has a sub status of "failed_smtp_connection" */ |
| 282 | + sub_status_failed_smtp_connection: number; |
| 283 | + |
| 284 | + /** Total number times the API has a sub status "mx_forward" */ |
| 285 | + sub_status_mx_forward: number; |
| 286 | + |
| 287 | + /** Start date of query (format: yyyy/mm/dd) */ |
| 288 | + start_date: string; |
| 289 | + |
| 290 | + /** End date of query (format: yyyy/mm/dd) */ |
| 291 | + end_date: string; |
| 292 | +} |
| 293 | + |
| 294 | +interface EmailActivityResponse { |
| 295 | + found: boolean; |
| 296 | + active_in_days: string; |
| 297 | +} |
| 298 | + |
| 299 | +interface ValidateBatchResponse { |
| 300 | + email_batch: ReadonlyArray<ValidateEmailResponse>; |
| 301 | + errors: ReadonlyArray<{ error: string }>; |
| 302 | +} |
| 303 | + |
| 304 | +/** |
| 305 | + * Response from the guess format endpoint |
| 306 | + */ |
| 307 | +interface GuessFormatResponse { |
| 308 | + /** The guessed email address format */ |
| 309 | + email: string; |
| 310 | + |
| 311 | + /** Confidence level of the guessed email format */ |
| 312 | + email_confidence: "high" | "medium" | "low"; |
| 313 | + |
| 314 | + /** The domain used for the guess */ |
| 315 | + domain: string; |
| 316 | + |
| 317 | + /** Company name associated with the domain, if available */ |
| 318 | + company_name: string; |
| 319 | + |
| 320 | + /** Suggested correction if a typo was detected */ |
| 321 | + did_you_mean: string; |
| 322 | + |
| 323 | + /** Reason for failure if the guess was unsuccessful */ |
| 324 | + failure_reason: string; |
| 325 | +} |
| 326 | +} |
| 327 | + |
| 328 | +declare class ZeroBounceSDK { |
| 329 | + constructor(); |
| 330 | + init(apiKey: string): void; |
| 331 | + getCredits(): Promise<{ Credits: string }>; |
| 332 | + validateEmail( |
| 333 | + email: string, |
| 334 | + ipAddress?: string, |
| 335 | + ): Promise<ZeroBounceSDK.ValidateEmailResponse>; |
| 336 | + getApiUsage(startDate: string, endDate: string): Promise<ZeroBounceSDK.ApiUsageResponse>; |
| 337 | + validateBatch( |
| 338 | + emailBatch: ReadonlyArray<ZeroBounceSDK.EmailBatchItem>, |
| 339 | + ): Promise<ZeroBounceSDK.ValidateBatchResponse>; |
| 340 | + getEmailActivity(email: string): Promise<ZeroBounceSDK.EmailActivityResponse>; |
| 341 | + sendFile(payload: ZeroBounceSDK.SendFilePayload): Promise<ZeroBounceSDK.SendFileResponse>; |
| 342 | + sendScoringFile(payload: ZeroBounceSDK.SendFilePayload): Promise<ZeroBounceSDK.SendFileResponse>; |
| 343 | + getFileStatus(fileId: string): Promise<ZeroBounceSDK.FileStatusResponse>; |
| 344 | + getScoringFileStatus(fileId: string): Promise<ZeroBounceSDK.FileStatusResponse>; |
| 345 | + getFile(fileId: string): Promise<ZeroBounceSDK.GetFileResponse>; |
| 346 | + getScoringFile(fileId: string): Promise<ZeroBounceSDK.GetFileResponse>; |
| 347 | + deleteFile(fileId: string): Promise<ZeroBounceSDK.DeleteFileResponse>; |
| 348 | + deleteScoringFile(fileId: string): Promise<ZeroBounceSDK.DeleteFileResponse>; |
| 349 | + guessFormat(payload: ZeroBounceSDK.GuessFormatPayload): Promise<ZeroBounceSDK.GuessFormatResponse>; |
| 350 | +} |
| 351 | + |
| 352 | +export = ZeroBounceSDK; |
0 commit comments