nsindocs Search the docs⌘K
  1. Docs
  2. API reference
  3. Email Routing

Send an email from one of the domain's addresses

posthttps://api.nsin.ir/domains/{domain}/email-routing/send

Auth: Authorization: Bearer nsin_… or X-Api-Key: nsin_… — see API keys.

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.

Path parameters

  • domainstringrequiredpath

    The domain name (for example example.com) — not a numeric id.

Request body

Content type: application/json · required

  • from_localstringrequired

    The part before @ of the sender. Must be an existing, switched-on address on the domain.

  • from_namestring

    Optional display name shown next to the sender address.

  • toarray of string (email)required

    Recipients. Duplicates are sent once.

  • subjectstringrequired
  • textstringrequired

    The message as plain UTF-8 text.

  • in_reply_tointeger

    Optional: the id of a mail in this domain's inbox being answered. The message then carries In-Reply-To / References with that mail's Message-ID.

Responses

202Queued; one row per recipient and the updated sending allowance.

Content type: application/json

  • messagesarray of EmailSentMessage
    Item fields
    • idinteger
    • group_idstring

      Shared by the recipients of one send.

    • fromstring

      The sender address.

    • from_namestring
    • tostring

      This row's recipient.

    • subjectstring
    • statusstring

      queued with attempts above 0 is a soft failure waiting for its next try.

      One of: "queued" "sending" "sent" "failed"
    • attemptsinteger

      Delivery attempts so far.

    • smtp_codeinteger

      The receiving server's last reply code. 0 before the first attempt.

    • responsestring

      The receiving server's last reply text.

    • tlsstring

      TLS version of the last delivery connection

    • created_atstring (date-time)
    • sent_atstring | null (date-time)
    • next_try_atstring | null (date-time)

      When a soft failure is tried again.

  • sendingEmailSendingStatus

    Whether this domain may send mail right now, and how much of today's allowance is used.

    Fields
    • plan_enabledboolean

      The plan includes sending (email_sending_enabled).

    • allowedboolean

      A send would be accepted now (limits aside).

    • reasonstring

      Why not, when allowed is false: platform_off, plan, not_enabled or suspended. Empty otherwise.

    • max_per_dayinteger | null

      Recipients the plan lets this domain send to per UTC day. null means unlimited.

    • sent_todayinteger

      Recipients queued so far today (UTC)

    • max_recipientsinteger

      Recipients allowed in one message.

    • max_text_kbinteger

      Largest message text

    • max_subjectinteger

      Longest subject

json
{
  "messages": [
    {
      "id": 0,
      "group_id": "string",
      "from": "string",
      "from_name": "string",
      "to": "string",
      "subject": "string",
      "status": "queued",
      "attempts": 0,
      "smtp_code": 0,
      "response": "string",
      "tls": "string",
      "created_at": "2026-01-01T00:00:00Z",
      "sent_at": "2026-01-01T00:00:00Z",
      "next_try_at": "2026-01-01T00:00:00Z"
    }
  ],
  "sending": {
    "plan_enabled": true,
    "allowed": true,
    "reason": "string",
    "max_per_day": 0,
    "sent_today": 0,
    "max_recipients": 0,
    "max_text_kb": 0,
    "max_subject": 0
  }
}
400A field is invalid; field is one of from_local, from_name, to, subject, text.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

  • codestring

    Machine-readable reason (hosts_not_ready, kek_unset, loop, no_mx, unverified).

  • fieldstring

    The offending body field, when one applies.

json
{
  "error": "string",
  "code": "string",
  "field": "string"
}
401Missing, malformed, revoked or expired API key. (A valid key whose account has been deactivated gets 403 account is inactive instead.)

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "invalid API key"
}
402The domain has no active plan. The body carries upgrade_url.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

  • max_rulesinteger | null
  • upgrade_urlstring
json
{
  "error": "This domain does not have an active plan. Purchase a plan for this domain before adding email addresses.",
  "upgrade_url": "/plans"
}
403The plan does not include sending (code: plan), or email on the domain is suspended (code: suspended).

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

  • codestring

    Machine-readable reason (hosts_not_ready, kek_unset, loop, no_mx, unverified).

  • fieldstring

    The offending body field, when one applies.

json
{
  "error": "string",
  "code": "string",
  "field": "string"
}
404No such domain, or it is not visible to this account. Domains you cannot access are reported as not found rather than forbidden.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
409Email Routing is not enabled on the domain (conflict: not_enabled).

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

  • conflictstring

    What conflicts (mx, spf, spf_multiple, external_dns, domain_status, not_enabled, local_part, destination).

  • recordsarray of EmailConflictRecord

    For mx / spf_multiple — the rows in the way.

    Item fields
    • idinteger
    • namestring
    • contentstring
    • priorityinteger
  • record_idinteger

    For spf — the existing SPF row.

  • contentstring

    For spf — its current value.

  • mergedstring

    For spf — what it becomes with our include merged in.

  • destinationEmailDestination
    Fields
    • idinteger
    • emailstring
    • verifiedboolean

      Whether the address was confirmed through the emailed link.

    • verified_atstring | null (date-time)

      When it was confirmed.

    • created_atstring (date-time)
    • last_sent_atstring | null (date-time)

      When the last verification mail went out.

    • resend_cooldown_secondsinteger

      Seconds until another verification mail may be sent; 0 when allowed now.

    • in_useinteger

      Rules and catch-alls pointing at it.

    • last_failurestring

      The receiving server's last refusal, when forwards to it are bouncing.

    • last_failure_atstring | null (date-time)

      When last_failure was recorded.

json
{
  "error": "string",
  "conflict": "string",
  "records": [
    {
      "id": 0,
      "name": "string",
      "content": "string",
      "priority": 0
    }
  ],
  "record_id": 0,
  "content": "string",
  "merged": "string",
  "destination": {
    "id": 0,
    "email": "string",
    "verified": true,
    "verified_at": "2026-01-01T00:00:00Z",
    "created_at": "2026-01-01T00:00:00Z",
    "last_sent_at": "2026-01-01T00:00:00Z",
    "resend_cooldown_seconds": 0,
    "in_use": 0,
    "last_failure": "string",
    "last_failure_at": "2026-01-01T00:00:00Z"
  }
}
413The text is over sending.max_text_kb.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
429The daily limit (code: daily_cap), the per-minute limit (code: rate) or today's refusals (code: bounces).

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

  • codestring

    Machine-readable reason (hosts_not_ready, kek_unset, loop, no_mx, unverified).

  • fieldstring

    The offending body field, when one applies.

json
{
  "error": "string",
  "code": "string",
  "field": "string"
}
503Sending is switched off on the platform (code: platform_off) or no mail host is ready (code: hosts_not_ready).

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

  • codestring

    Machine-readable reason (hosts_not_ready, kek_unset, loop, no_mx, unverified).

  • fieldstring

    The offending body field, when one applies.

json
{
  "error": "string",
  "code": "string",
  "field": "string"
}

Example request

bash
curl -X POST "https://api.nsin.ir/domains/example.com/email-routing/send" \
  -H "Authorization: Bearer $NSIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "from_local": "string",
  "from_name": "string",
  "to": [
    "string"
  ],
  "subject": "string",
  "text": "string",
  "in_reply_to": 0
}'
esc