# VeriMails API Examples

Use `https://verimails.com` as the base URL and send `Authorization: Bearer YOUR_API_KEY` with API requests.

## JavaScript: Verify One Email

```js
const response = await fetch("https://verimails.com/api/verify/single", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.VERIMAILS_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ email: "person@example.com" })
});

const result = await response.json();
if (result.safe_to_send) {
  console.log("Use this address", result.email);
}
```

## Python: Verify One Email

```python
import os
import requests

response = requests.post(
    "https://verimails.com/api/verify/single",
    headers={"Authorization": f"Bearer {os.environ['VERIMAILS_API_KEY']}"},
    json={"email": "person@example.com"},
    timeout=30,
)
response.raise_for_status()
result = response.json()
print(result["status"], result["safe_to_send"])
```

## JavaScript: Upload a Bulk CSV

```js
import fs from "node:fs";

const form = new FormData();
form.append("file", new Blob([fs.readFileSync("leads.csv")]), "leads.csv");
form.append("email_column", "Email Address");

const response = await fetch("https://verimails.com/api/bulk", {
  method: "POST",
  headers: { "Authorization": `Bearer ${process.env.VERIMAILS_API_KEY}` },
  body: form
});

const job = await response.json();
console.log(job.job_id, job.status);
```

## Python: Poll and Download Bulk Results

```python
import os
import requests

api_key = os.environ["VERIMAILS_API_KEY"]
headers = {"Authorization": f"Bearer {api_key}"}
job_id = 123

status = requests.get(f"https://verimails.com/api/bulk/{job_id}", headers=headers, timeout=30)
status.raise_for_status()
print(status.json())

results = requests.get(f"https://verimails.com/api/bulk/{job_id}/download", headers=headers, timeout=120)
results.raise_for_status()
open("results.csv", "wb").write(results.content)
```

## JavaScript: Find a Verified Business Email

```js
const response = await fetch("https://verimails.com/api/find-email", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.VERIMAILS_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    first_name: "Jane",
    last_name: "Doe",
    domain: "example.com"
  })
});

const result = await response.json();
if (result.found) {
  console.log("Verified email:", result.email);
}
```

## Python: Find a Verified Business Email

```python
import os
import requests

response = requests.post(
    "https://verimails.com/api/find-email",
    headers={"Authorization": f"Bearer {os.environ['VERIMAILS_API_KEY']}"},
    json={"first_name": "Jane", "last_name": "Doe", "domain": "example.com"},
    timeout=60,
)
response.raise_for_status()
print(response.json())
```
