Sending setup
Before you can send, prove you own the domain you are sending from. It is a one-time job: add the domain, publish three DNS records, and verify. Most of the time goes into waiting for DNS.
Related:Email sendingTransactional email
Checked against the API source on
Before you start
- An API key. For this page it needs the
domainsscope, and latersendto send. Create one on the API keys page. - Sending credits. Each email costs 1 sending credit, separate from validation credits. Top up in billing.
- Access to your domain's DNS settings at your DNS provider (Cloudflare, Route 53, GoDaddy, Namecheap and so on).
1. Add your domain
Add the domain that appears after the @ in your From address. A subdomain such as mail.yourcompany.com is a good idea: it keeps app and marketing mail away from the reputation of your main domain. Each domain is separate, so a verified yourcompany.com does not cover mail.yourcompany.com.
Add a sending domain
/send/domains/domainsRegisters a domain you want to send from and generates its DKIM key straight away, so the response already contains the key to publish. If the sending service is briefly unreachable the domain is still created and the key is generated on the next verify.
Body
| Name | Type | Required | Description |
|---|---|---|---|
| domain | string | Yes | The domain, for example yourcompany.com or mail.yourcompany.com. Stored lower-case. |
Request
curl -X POST "https://api.scrubimail.com/scrubimail/api/v1/send/domains/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"domain": "yourcompany.com"
}'const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/domains/", {
method: "POST",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"domain": "yourcompany.com"
}),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
payload = {
"domain": "yourcompany.com",
}
res = requests.post(
"https://api.scrubimail.com/scrubimail/api/v1/send/domains/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
json=payload,
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$payload = <<<'JSON'
{
"domain": "yourcompany.com"
}
JSON;
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/domains/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => $payload,
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
{
"id": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"domain": "yourcompany.com",
"verified": false,
"spf_verified": false,
"dkim_verified": false,
"dmarc_verified": false,
"verification_details": {},
"dkim_selector": "scrubimail",
"dkim_public_key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu3...",
"status": "pending",
"created_at": "2026-11-16T07:00:00Z",
"updated_at": "2026-11-16T07:00:00Z"
}Errors
| Status | Code | When |
|---|---|---|
| 400 | validation_error | A field is missing or invalid. error.details lists each one. |
| 400 | - | {"error": "Domain already exists"}: you already added it. |
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. The response carries a WWW-Authenticate header. |
| 403 | permission_denied | The key has scopes set and domains is not one of them. |
Keep the id (you pass it as sending_domain_id on every send) and the dkim_public_key from the response. You can fetch both again any time with GET /send/domains/.
2. Publish the DNS records
Add these three TXT records at your DNS provider. Replace yourcompany.com with the domain you added.
| Purpose | Type | Host | Value | Required |
|---|---|---|---|---|
| SPF | TXT | @ (the domain itself) | v=spf1 include:_spf.scrubimail.com ~all | Yes |
| DKIM | TXT | scrubimail._domainkey | v=DKIM1; k=rsa; p=<dkim_public_key> | Yes |
| DMARC | TXT | _dmarc | v=DMARC1; p=none; rua=mailto:[email protected] | For bulk sends |
- SPF tells receivers that ScrubiMail's servers may send for your domain. It passes when your record includes
_spf.scrubimail.com, directly or through another include. - DKIM lets receivers verify the signature we add to every message. The selector is
scrubimail, so the record lives atscrubimail._domainkey.yourcompany.com. Paste thedkim_public_keyfrom the domain afterp=. It is unique to your domain, so copy it exactly and do not let your DNS provider wrap or truncate it. - DMARC tells receivers what to do when SPF and DKIM fail. Start with
p=noneto monitor, then tighten toquarantineonce reports show your mail passing. Gmail and Yahoo expect it from bulk senders, and ScrubiMail requires it for bulk and campaign sends.
3. Verify the domain
When the records are live, ask ScrubiMail to check them. Run it again whenever you change a record. The domain is verified when SPF and DKIM both pass; that is what lets you send single emails and SMTP mail. DMARC is checked and reported but only blocks bulk sends and campaigns.
Verify a sending domain
/send/domains/{id}/verify/domainsLooks up your DNS and updates the domain. verified becomes true when SPF and DKIM both pass; DMARC is reported separately and is only required for bulk sends. verification_details tells you, per record, whether it passed and what to fix.
Path
| Name | Type | Required | Description |
|---|---|---|---|
| id | UUID | Yes | The domain's id. |
Request
curl -X POST "https://api.scrubimail.com/scrubimail/api/v1/send/domains/a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d/verify/" \
-H "X-API-Key: $SCRUBIMAIL_API_KEY"const res = await fetch("https://api.scrubimail.com/scrubimail/api/v1/send/domains/a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d/verify/", {
method: "POST",
headers: {
"X-API-Key": process.env.SCRUBIMAIL_API_KEY,
},
});
const data = await res.json();
if (!res.ok) throw new Error(data.error?.message ?? data.error ?? res.statusText);import os
import requests
res = requests.post(
"https://api.scrubimail.com/scrubimail/api/v1/send/domains/a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d/verify/",
headers={"X-API-Key": os.environ["SCRUBIMAIL_API_KEY"]},
timeout=30,
)
data = res.json()
res.raise_for_status()<?php
$ch = curl_init('https://api.scrubimail.com/scrubimail/api/v1/send/domains/a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d/verify/');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('SCRUBIMAIL_API_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);Response
{
"id": "a1b2c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"domain": "yourcompany.com",
"verified": true,
"spf_verified": true,
"dkim_verified": true,
"dmarc_verified": false,
"verification_details": {
"spf": {
"ok": true,
"reason": ""
},
"dkim": {
"ok": true,
"reason": ""
},
"dmarc": {
"ok": false,
"reason": "No DMARC record found at _dmarc.yourcompany.com. Publish a TXT record such as: v=DMARC1; p=none; rua=mailto:you@yourdomain"
},
"checked_at": "2026-11-16T07:20:00Z"
},
"dkim_selector": "scrubimail",
"dkim_public_key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu3...",
"status": "active",
"created_at": "2026-11-16T07:00:00Z",
"updated_at": "2026-11-16T07:00:00Z"
}Errors
| Status | Code | When |
|---|---|---|
| 404 | not_found | No domain with that id on your account. |
| 503 | - | code: "dkim_unavailable": the DKIM key could not be generated because the sending service is unreachable. The DNS checks still ran. Try again in a few minutes. |
| 401 | authentication_required | No API key was sent. The response carries a WWW-Authenticate header. |
| 401 | invalid_credentials | The key is unknown, inactive, expired, or the request IP is not on the key's allow-list. The response carries a WWW-Authenticate header. |
| 403 | permission_denied | The key has scopes set and domains is not one of them. |
| Check | Passes when | Common reason it fails |
|---|---|---|
| SPF | Your domain has exactly one SPF record and it authorises ScrubiMail by including _spf.scrubimail.com. | No SPF record yet, two SPF records, or an include that is negated or past the 10-lookup limit. |
| DKIM | The p= value published at scrubimail._domainkey matches the key ScrubiMail signs with. | The record is missing, was truncated when pasted, or holds an older or empty key. |
| DMARC | Exactly one record starting with v=DMARC1 is published at _dmarc. | No record, or more than one. |
Each check stores a plain-language reason in verification_details when it fails, so the response itself tells you what to fix. The status field is active once the domain is verified and pending until then. You can confirm a record yourself with dig TXT scrubimail._domainkey.yourcompany.com or nslookup -type=TXT yourcompany.com.
From address rules
| Channel | Rule |
|---|---|
| HTTP API, single send | The domain in sending_domain_id must be yours and verified. from_email must be on that domain: a From address on a different domain is rejected with 400. The message is signed with that domain's DKIM key. |
| HTTP API, bulk and campaigns | The same, including the 400 for a From address that is not on the sending domain, and the domain must also have a DMARC record. |
| SMTP relay | Enforced on every message. The From domain must be a verified domain on your account. If your app sets an envelope sender (MAIL FROM), its domain must be one of your verified domains too. Otherwise the message is refused with 550 5.7.1. |
You cannot send through a domain you have not verified. Recipients on your suppression list are skipped, and unsubscribes and hard bounces are added to it automatically. See the Sending API.
4. Send your first email
With a verified domain you can send. Use the Sending API from your code, or point an app at the SMTP relay. For a smooth start, send to a few of your own addresses first and look at the message source in your inbox: you want to see spf=pass, dkim=pass and dmarc=pass. A new domain should ramp volume up gradually, to engaged recipients first, and you should validate your lists with the Validation API before a campaign so hard bounces do not hurt your reputation.
Something missing or wrong? Email [email protected].