Send Email
Send a transactional or marketing email to one or multiple recipients. Supports HTML bodies, attachments, reply-to, and marketing headers.
https://mail.sendcorex.com/v3.0/sendNeed to send to multiple recipients at once? Pass to as an array — see Send Batch Emails.
Body parameters
tostring | string[]requiredRecipient email address or array of up to 50 addresses.
e.g.
"user@example.com" or ["a@x.com", "b@x.com"]fromstringrequiredSender email address. Must belong to a verified domain in your account.
senderNamestringrequiredDisplay name shown in the recipient's inbox.
subjectstringrequiredEmail subject line. HTML is not supported here.
bodystringrequiredHTML content of the email body.
replyTostringoptionalReply-to address. Defaults to the sender address if omitted.
transactionalbooleanoptionalSet true to mark as transactional. Defaults to false.
attachmentsobject[]optionalArray of attachment objects. See Send Attachments for full details.
retryRateLimitedintegeroptionalHow many 30-minute cycles to keep trying when the provider rate limits you (0–24, default 25). See Delivery options for full details.
retryUnavailableintegeroptionalHow many times to try again after a temporary error (0–30). Use with retryUnavailableSeconds (10–3600). See Delivery options for full details.
ignoreHardBouncebooleanoptionalSend even if the address hard bounced in the last 90 days. Defaults to false. See Delivery options for full details.
Retrying? Use an idempotency key so the email is never sent twice. Idempotency →
Quick start
import axios from 'axios';
const response = await axios.post(
'https://mail.sendcorex.com/v3.0/send',
{
to: 'user@example.com',
from: 'noreply@yourdomain.com',
senderName: 'My App',
subject: 'Welcome aboard!',
body: '<h1>Welcome!</h1><p>Thanks for signing up.</p>',
replyTo: 'support@yourdomain.com',
},
{
headers: { Authorization: process.env.SENDCOREX_API_KEY },
}
);
const { id, ids, recipients } = response.data;Response
{
"success": true,
"message": "Email queued successfully",
"code": "EMAIL_QUEUED_SUCCESS",
"id": "3f2a1b4c-8e9d-4f7a-b2c3-1a2b3c4d5e6f",
"ids": [
{ "id": "3f2a1b4c-8e9d-4f7a-b2c3-1a2b3c4d5e6f", "recipient": "user@example.com" }
],
"recipients": 1,
"scheduledAt": null
}Idempotent requests
Send an Idempotency-Key header with any unique value (we recommend a UUID v4) to safely retry POST /v3.0/send. If the connection drops or you get a timeout, retry with the same key and the same body: we return the original response (same email id) and the email is not sent twice.
POST /v3.0/send
Authorization: Bearer <api_key>
Idempotency-Key: 3f1c9a52-6b1e-4f0e-9c2a-8d7e5b4a1f00
Content-Type: application/jsonKeys are valid for 24 hours and are scoped to your account.
Allowed characters: letters, numbers,
_ - : .(1–255 chars).A replayed response has the header
Idempotent-Replayed: true.Use a new key for every new email. Reusing a key with a different body returns
422 IDEMPOTENCY_KEY_REUSED.If the first request is still being processed, you get
409 IDEMPOTENCY_IN_PROGRESSwithRetry-After: 1. Wait and retry with the same key.A key outside these rules returns
400 INVALID_IDEMPOTENCY_KEY.Server errors (
5xx) and rate limits (429) are not stored: retrying with the same key sends normally.Without the header, the endpoint works as before.
Recommended retry: on network error, timeout, 409, 429 or 5xx, retry with the same key using exponential backoff (1 s, 2 s, 4 s…, up to 5 tries).
Example: UUID key + retry with backoff
import { randomUUID } from 'node:crypto';
const RETRY_STATUS = new Set([409, 429, 500, 502, 503, 504]);
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function sendEmail(email) {
const key = randomUUID(); // one key per email, reused on every retry
const body = JSON.stringify(email); // same body on every retry
for (let attempt = 1; attempt <= 5; attempt++) {
try {
const res = await fetch('https://mail.sendcorex.com/v3.0/send', {
method: 'POST',
headers: {
Authorization: process.env.SENDCOREX_API_KEY,
'Idempotency-Key': key,
'Content-Type': 'application/json',
},
body,
signal: AbortSignal.timeout(15_000),
});
if (!RETRY_STATUS.has(res.status)) {
const data = await res.json();
if (!res.ok) throw new Error(data.code || 'SEND_FAILED');
// Idempotent-Replayed: true → this is the original response (not sent twice)
return { ...data, replayed: res.headers.get('Idempotent-Replayed') === 'true' };
}
if (attempt === 5) throw new Error('HTTP ' + res.status);
const retryAfter = Number(res.headers.get('Retry-After')) * 1000;
await sleep(retryAfter || 1000 * 2 ** (attempt - 1));
} catch (err) {
// network error or timeout: retry with the same key
if (err.message?.startsWith('HTTP ') || attempt === 5 || (err.name !== 'TypeError' && err.name !== 'TimeoutError')) throw err;
await sleep(1000 * 2 ** (attempt - 1));
}
}
}
const result = await sendEmail({
to: 'user@example.com',
from: 'noreply@yourdomain.com',
senderName: 'My App',
subject: 'Your receipt',
body: '<p>Thanks for your order.</p>',
});
console.log(result.id, result.replayed);My messages are flagged as spam
Every message goes through our anti-spam filter. When one is flagged, the request returns 403 with the code SPAM_DETECTED and the email is held in quarantine.
Flagged as spam
{
"error": "Email content flagged as spam.",
"code": "SPAM_DETECTED",
"detectionId": "9c1e5a7d-2b4f-4e8a-a6d3-0f1b2c3d4e5f",
"quarantine_id": "qtn_3f2a1b4c8e9d4f7a",
"release_instructions": "POST /v3.0/quarantine/release with { quarantine_id }",
"expires_in": "3 hours"
}codeAlways SPAM_DETECTED for this response.
detectionIdIdentifier of this detection. Include it when contacting support.
quarantine_idPass this to /quarantine/release to send the email after review.
release_instructionsHow to release the email.
expires_inHow long the quarantine record is kept before it expires.
A quarantined email is not delivered. Use /quarantine/release to send it after review. The quarantine record expires after 3 hours.
If quarantine_id, release_instructions and expires_in come back as null, the email was blocked without a quarantine record. It cannot be released: fix the content and send it again.
Errors
All error codes →Errors return a JSON object with error, code and responseTime.
- 401
MISSING_AUTH_HEADERNo Authorization header present.
- 401
INVALID_API_KEYThe API key is invalid or revoked.
- 401
ACCOUNT_BLOCKEDAccount has been blocked.
- 401
NO_CREDITS_LEFTNot enough email credits for every recipient. Each to, cc and bcc address uses 1 credit.
- 401
DOMAIN_NOT_VALIDATEDSender domain not verified.
- 401
LISTED_SPAM_HAUSSender domain is listed on Spamhaus.
- 401
ISP_DOMAIN_BLOCKEDSending from well-known domains (gmail.com, outlook.com, etc) is not allowed.
- 401
FROM_HEADER_DOMAIN_MISMATCHFrom header domain not authorized for this sender.
- 401
USER_NOT_FOUNDUser not found.
- 401
MISSING_USER_PRIVILEGESMissing user privileges.
- 401
EMAIL_CREDITS_NOT_FOUNDError fetching email credits.
- 401
EMAIL_NOT_VALIDATEDAccount email address has not been verified yet.
- 429
CREDENTIAL_TEMPORARILY_BLOCKEDAPI key temporarily blocked due to repeated policy violations.
- 429
IP_TEMPORARILY_BLOCKEDRequesting IP temporarily blocked due to repeated policy violations.
- 429
TOO_MANY_CONCURRENT_CONNECTIONSToo many concurrent requests from this IP. Try again shortly.
- 400
INVALID_JSONThe request body is not valid JSON.
- 400
MISSING_FROMThe from field is missing or empty.
- 400
INVALID_FROM_FORMATThe from field must be a valid email address.
- 400
MISSING_SENDERNAMEThe senderName field is missing or empty.
- 400
INVALID_SENDERNAME_FORMATThe senderName field contains invalid characters.
- 400
MISSING_SUBJECTThe subject field is missing or empty.
- 400
MISSING_BODYThe body field is missing or empty.
- 400
MISSING_TOADDRESSThe to field is missing or empty.
- 400
MISSING_TOThe to field is missing or empty.
- 400
INVALID_TOADDRESSOne or more recipient addresses are malformed.
- 400
TOADDRESS_LIMIT_EXCEEDEDMore than 50 recipients in the to array.
- 400
INVALID_CCADDRESSOne or more cc addresses are malformed.
- 400
INVALID_BCCADDRESSOne or more bcc addresses are malformed.
- 400
RECIPIENT_LIMIT_EXCEEDEDto, cc and bcc together have more than 50 unique recipients.
- 400
INVALID_SCHEDULED_ATscheduled_at is not a valid date or is in the past.
- 400
INVALID_SENDER_FORMATThe sender email format is invalid.
- 400
HEADER_NOT_ALLOWEDCustom header key is not on the allowed list (List-Unsubscribe, List-Id, X-*, etc).
- 400
INVALID_HEADER_VALUEHeader value contains invalid characters (CR/LF not allowed).
- 400
DANGEROUS_ATTACHMENTOne or more attachments were blocked for security reasons.
- 400
INVALID_ATTACHMENTAn attachment content is not valid base64.
- 400
MISSING_UNSUBSCRIBE_PLACEHOLDERunsubscribe is true but the body has no unsubscribe placeholder ([unsubscribe_url], [unsubscribe], [unsub_url] or [opt_out_url]).
- 403
ACCOUNT_RESTRICTEDAccount is temporarily restricted.
- 403
DAILY_LIMITDaily email sending limit reached.
- 403
MARKETING_LIMIT_REACHEDFree plan daily marketing limit reached: 30 marketing or cold outreach emails per day, counted per recipient over a rolling 24-hour window. The response includes limit, used, recipients and upgradeUrl. Transactional emails still go out; nothing is queued.
- 403
FORBIDDEN_HTML_CONTENTThe HTML contains active content not allowed in emails (script, iframe, form, input, button, embed, object, svg, on* handlers, javascript: links, meta refresh…). The response lists the findings. Use a styled <a> instead of buttons or forms.
- 403
SPAM_DETECTEDEmail content flagged as spam. Response includes quarantine_id and release instructions.
- 403
SENDER_NAME_MISMATCHMultiple sender names detected for same address.
- 403
FOLLOWUP_PATTERN_DETECTEDEmail content flagged as repeated suspicious follow-up pattern.
- 403
SCAM_PATTERN_DETECTEDEmail content flagged as scam pattern.
- 403
ACCOUNT_SUSPENDED_SPOOFINGAccount suspended due to repeated From header spoofing attempts.
- 400
INVALID_IDEMPOTENCY_KEYThe Idempotency-Key header is invalid. Use 1–255 characters: letters, numbers, _ - : .
- 409
IDEMPOTENCY_IN_PROGRESSA request with the same Idempotency-Key is still being processed. Wait (Retry-After: 1) and retry with the same key.
- 422
RECIPIENT_UNSUBSCRIBEDSent with unsubscribe enabled (unsubscribe: true) to someone who already unsubscribed through the Sendcorex link. The whole request is refused and the unsubscribed array lists them. This person unsubscribed from you: remove them and send again, and do not send to them again.
- 422
IDEMPOTENCY_KEY_REUSEDThis Idempotency-Key was already used with a different body. Use a new key for every new email.
- 500
INTERNAL_SERVER_ERRORUnexpected server error. Try again.
- 500
PARSE_ERRORFailed to process email content (MIME parse failure).
- 500
PERSIST_FAILEDFailed to queue email (database persistence failure).
- 503
AUTH_UNAVAILABLECould not validate the API key right now. Try again.
- 503
UNSUBSCRIBE_UNAVAILABLEUnsubscribe link service temporarily unavailable. Try again later.