Skip to main content
POST
/
v1
/
api
/
cleanemail
/
Clean Email List
curl --request POST \
  --url https://base.sanitizeemail.com/v1/api/cleanemail/ \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --data '{
  "file_id": 739,
  "list_name": "Customer List - Cleaned",
  "options": {
    "validate_syntax": true,
    "check_dmarc": true,
    "validate_smtp": true,
    "validate_mx": true
  }
}'
{
  "job_id": "<string>",
  "status": "queued",
  "list_name": "<string>",
  "file_id": 123,
  "estimated_completion_time": "2023-11-07T05:31:56Z",
  "options_applied": {
    "validate_syntax": true,
    "check_dmarc": true,
    "validate_smtp": true,
    "validate_mx": true
  },
  "total_emails": 123,
  "credits_required": 123
}
This endpoint processes and cleans an uploaded email list file with comprehensive validation options. It requires a previously uploaded file from the File Upload endpoint.

How it Works

1

Upload File First

Use the File Upload endpoint to upload your CSV or XLSX file and obtain the file_id and file URL
2

Configure Cleaning Options

Set your desired validation options (syntax, DMARC, SMTP, MX records)
3

Submit Cleaning Job

Send the cleaning request with the file reference and options
4

Monitor Progress

Use the returned job_id to track the cleaning progress

Prerequisites

File Upload Required: You must first upload a file using the /v1/api/filesupload/ endpoint to obtain the required file_id and file URL parameters.

Validation Options

The cleaning process supports multiple validation levels:
  • validate_syntax: Checks email format and structure
  • check_dmarc: Validates DMARC policy records
  • validate_smtp: Performs SMTP server validation
  • validate_mx: Checks MX record existence
Comprehensive Cleaning: Enable all validation options for the most thorough email list cleaning, though this will consume more credits and take longer to process.

Example Workflow

// 1. First upload a file
POST /v1/api/filesupload/
// Response includes: { "id": 739, "file": "https://s3.../file.csv" }

// 2. Then clean the uploaded file
POST /v1/api/cleanemail/
{
  "file_id": 739,
  "file": "https://s3.us-east-1.amazonaws.com/sanitizeemail/email_validation_files/Book_Sheet1_e5FL41X.csv",
  "user": 100,
  "list_name": "Customer List - Cleaned",
  "options": {
    "validate_syntax": true,
    "check_dmarc": true,
    "validate_smtp": true,
    "validate_mx": true
  }
}
Credits Consumption: The cleaning process consumes credits based on the number of emails and validation options selected. More comprehensive validation uses more credits.

Authorizations

X-API-KEY
string
header
required

API key for authentication

Body

application/json

Email list cleaning request payload

file_id
integer
required

ID of the uploaded file (obtained from file upload response)

Example:

739

list_name
string
required

Name for the cleaned email list

Example:

"Customer List - Cleaned"

options
object

Validation and cleaning options

Response

Email cleaning job initiated successfully

job_id
string

Unique identifier for the cleaning job

status
enum<string>

Current status of the cleaning job

Available options:
queued,
processing,
completed,
failed
list_name
string

Name of the email list being cleaned

file_id
integer

ID of the source file

estimated_completion_time
string<date-time>

Estimated completion time for the cleaning job

options_applied
object

Validation options that will be applied

total_emails
integer

Total number of emails to be processed

credits_required
integer

Number of credits required for this cleaning job