Send an email from one of the domain's addresses
const url = 'https://api.nsin.ir/domains/example.com/email-routing/send';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"from_local":"example","from_name":"example","to":["hello@example.com"],"subject":"example","text":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.nsin.ir/domains/example.com/email-routing/send \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "from_local": "example", "from_name": "example", "to": [ "hello@example.com" ], "subject": "example", "text": "example" }'Queues a plain-text message FROM an address that exists and is switched
on on this domain, TO up to sending.max_recipients recipients. A mail
host delivers it a few seconds later, signed with the domain’s DKIM
key, so SPF, DKIM and DMARC pass for the domain. Replies go to the
sender address and are forwarded like any other mail.
The answer is 202 with one queued row per recipient; read the
outcome from the sent list. A soft failure is retried up to five times
over about ninety minutes. Each recipient counts once against the
plan’s max_email_sends_per_day (UTC day), delivered or not.
Refused when the plan does not include sending (403, code: plan),
Email Routing is off (409, conflict: not_enabled), the domain is
suspended (403, code: suspended), the daily limit is reached
(429, code: daily_cap), the domain is sending too fast (429,
code: rate) or too many of today’s messages were refused by the
receiving servers (429, code: bounces). No HTML and no attachments.
Requires records.edit.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”The domain name (for example example.com) — not a numeric id.
Example
example.comRequest Body required
Section titled “Request Body required ”object
The part before @ of the sender. Must be an existing, switched-on address on the domain.
Optional display name shown next to the sender address.
Recipients. Duplicates are sent once.
The message as plain UTF-8 text.
Example generated
{ "from_local": "example", "from_name": "example", "to": [ "hello@example.com" ], "subject": "example", "text": "example"}Responses
Section titled “ Responses ”Queued; one row per recipient and the updated sending allowance.
object
One recipient of one sent message.
object
Shared by the recipients of one send.
The sender address.
This row’s recipient.
queued with attempts above 0 is a soft failure waiting for its next try.
Delivery attempts so far.
The receiving server’s last reply code. 0 before the first attempt.
The receiving server’s last reply text.
TLS version of the last delivery connection
When a soft failure is tried again.
Whether this domain may send mail right now, and how much of today’s allowance is used.
object
The plan includes sending (email_sending_enabled).
A send would be accepted now (limits aside).
Why not, when allowed is false: platform_off, plan, not_enabled or suspended. Empty otherwise.
Recipients the plan lets this domain send to per UTC day. null means unlimited.
Recipients queued so far today (UTC)
Recipients allowed in one message.
Largest message text
Longest subject
Example
{ "messages": [ { "status": "queued" } ]}A field is invalid; field is one of from_local, from_name, to, subject, text.
object
Human-readable description of what went wrong.
Machine-readable reason (hosts_not_ready, kek_unset, loop, no_mx, unverified).
The offending body field, when one applies.
Example
{ "error": "read-only API key"}Missing, malformed, revoked or expired API key. (A valid key whose
account has been deactivated gets 403 account is inactive instead.)
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Examples
{ "error": "invalid API key"}The domain has no active plan. The body carries upgrade_url.
object
Human-readable description of what went wrong.
Examples
{ "error": "This domain does not have an active plan. Purchase a plan for this domain before adding email addresses.", "upgrade_url": "/plans"}The plan does not include sending (code: plan), or email on the domain is suspended (code: suspended).
object
Human-readable description of what went wrong.
Machine-readable reason (hosts_not_ready, kek_unset, loop, no_mx, unverified).
The offending body field, when one applies.
Example
{ "error": "read-only API key"}No such domain, or it is not visible to this account. Domains you cannot access are reported as not found rather than forbidden.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}Email Routing is not enabled on the domain (conflict: not_enabled).
object
Human-readable description of what went wrong.
What conflicts (mx, spf, spf_multiple, external_dns, domain_status, not_enabled, local_part, destination).
For mx / spf_multiple — the rows in the way.
object
For spf — the existing SPF row.
For spf — its current value.
For spf — what it becomes with our include merged in.
For destination — the existing row.
object
Whether the address was confirmed through the emailed link.
When it was confirmed.
When the last verification mail went out.
Seconds until another verification mail may be sent; 0 when allowed now.
Rules and catch-alls pointing at it.
The receiving server’s last refusal, when forwards to it are bouncing.
When last_failure was recorded.
Example
{ "error": "read-only API key"}The text is over sending.max_text_kb.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}The daily limit (code: daily_cap), the per-minute limit (code: rate) or today’s refusals (code: bounces).
object
Human-readable description of what went wrong.
Machine-readable reason (hosts_not_ready, kek_unset, loop, no_mx, unverified).
The offending body field, when one applies.
Example
{ "error": "read-only API key"}Sending is switched off on the platform (code: platform_off) or no mail host is ready (code: hosts_not_ready).
object
Human-readable description of what went wrong.
Machine-readable reason (hosts_not_ready, kek_unset, loop, no_mx, unverified).
The offending body field, when one applies.
Example
{ "error": "read-only API key"}