Black Friday: add funds and get 2x credit, up to $50 free ($25 → $50, $50 → $100). Use it for anything: domains, hosting, email. Code: BLACKFRIDAY2026 Get 2x credit →

Developers → Email

Email API

Manage the mail of your domains from code: send transactional email, mailboxes on paid email hosting, free forwarding for domains registered at NameOcean, and incoming mail posted to your app as JSON.

Before you start

Create an API key with email:read, and email:write to change things. Every endpoint is in the API reference and the OpenAPI file. Buying, upgrading and renewing a mail plan spends account credit and is done in the dashboard.

Mailboxes

A mail domain's plan has a storage size that its mailboxes share. Create a mailbox without a password and one is generated; the answer is the only time the API returns it.

curl
$ curl -X POST https://nameocean.net/api/v1/email/domains/example.com/mailboxes \
    -H "Authorization: Bearer $NAMEOCEAN_API_KEY" -H "Content-Type: application/json" \
    -d '{"username": "info", "full_name": "Info", "quota_gb": 2}'

{"address": "info@example.com", "username": "info", "full_name": "Info", "quota_gb": 2,
 "used_gb": "0.00", "aliases": [], "password": "Qm7…"}
GET /email/domains/{domain}Mailboxes, aliases, lists and the IMAP/SMTP settings
PATCH /email/domains/{domain}/mailboxes/{username}Change the name or quota
POST /email/domains/{domain}/mailboxes/{username}/passwordSet a password, or generate one
POST /email/domains/{domain}/aliasesDeliver another address to a mailbox
POST /email/domains/{domain}/listsA mailing list of the domain's mailboxes
GET /email/domains/{domain}/dns-checkNS, MX, SPF, DKIM and DMARC, live, with the expected values

Sending email

Send order confirmations, password resets and alerts from any address of a sending domain (no email hosting needed), or from a mailbox or alias of your mail domain, signed with its DKIM key. The key needs the email:send scope, and the domain must publish the SPF and DKIM records shown for it. Every account sends 1,000 emails a month free, each recipient counted once; API and sending-domain SMTP count together, mail your team sends from mailboxes with mail apps does not. Past that, turn on pay as you go in the dashboard: from $0.30 per thousand, less at volume, charged after the month.

add a sending domain
$ curl -X POST https://nameocean.net/api/v1/email/sending-domains \
    -H "Authorization: Bearer $NAMEOCEAN_API_KEY" -d '{"domain": "example.com"}'

{"domain": "example.com", "status": "pending", "nameocean_dns": true,
 "smtp": {"host": "mail.nameocean.net", "ports": [{"port": 465, "security": "TLS"}, {"port": 587, "security": "STARTTLS"}],
          "username": "smtp@example.com", "password": "…shown once…"}}

On NameOcean DNS the SPF, DKIM and DMARC records are written for you; elsewhere GET /email/sending-domains/{domain} lists them, and POST …/verify checks them. The domain's MX records are not touched. For SMTP use the username and password above on mail.nameocean.net (465 TLS or 587 STARTTLS) with any From address of the domain.

curl
$ curl -X POST https://nameocean.net/api/v1/email/send \
    -H "Authorization: Bearer $NAMEOCEAN_API_KEY" -H "Content-Type: application/json" \
    -H "Idempotency-Key: order-1042-shipped" \
    -d '{"from": "Shop <info@example.com>", "to": ["alice@example.org"],
         "subject": "Order 1042 shipped", "text": "Your order is on its way.",
         "html": "<p>Your order is on its way.</p>", "metadata": {"order": "1042"}}'

{"message_id": "<kVTha0Q…@example.com>", "from": "info@example.com", "subject": "Order 1042 shipped",
 "recipients": [{"id": "6f1c2a4e-…", "to": "alice@example.org", "kind": "to", "status": "queued"}]}

Attachments go in attachments as base64 (content_id makes one inline for cid: images), extra headers such as List-Unsubscribe in headers, and send_at schedules the message up to 7 days ahead. A message has at most 50 recipients and 10 MB. Retry with the same Idempotency-Key and it is sent once.

GET /email/sentEach recipient (API and SMTP) and what happened: queued, delivered, delayed, failed, suppressed, with the SMTP error. Kept 3 to 45 days by plan
GET /email/domains/{domain}/suppressionsAddresses no longer mailed after a hard bounce; POST adds one (an unsubscribe), DELETE removes it
GET /email/sendingThis month's emails used and free, pay as you go, amount so far, prices
PATCH /email/sendingTurn pay as you go on or off, set the monthly spend cap
GET|POST /email/sending-domainsSending domains; POST adds one and returns its SMTP password once
GET|DELETE /email/sending-domains/{domain}DNS records to publish and whether they are live; DELETE removes the domain
POST /email/sending-domains/{domain}/verifyCheck the DNS now
POST /email/sending-domains/{domain}/smtp-passwordNew SMTP password (returned once)

Delivery results arrive as webhook events: email.delivered, email.delayed, email.bounced (with the SMTP code; a hard bounce also suppresses the address) and email.suppressed. Each carries the id, the recipient and your metadata. For SMTP instead of HTTP, use the mailbox's address and password on mail.nameocean.net, port 465.

Free forwarding

Domains registered at NameOcean that use our nameservers can forward their mail for free. Turning it on writes the MX record; if the zone has another provider's MX records, send replace_mx: true to remove them.

curl
$ curl -X POST https://nameocean.net/api/v1/email/forwarding/example.com \
    -H "Authorization: Bearer $NAMEOCEAN_API_KEY"
$ curl -X POST https://nameocean.net/api/v1/email/forwarding/example.com/aliases \
    -H "Authorization: Bearer $NAMEOCEAN_API_KEY" -H "Content-Type: application/json" \
    -d '{"localpart": "hello", "to": "me@gmail.com"}'

A new target address gets a mail with a link and a 6-digit code, and mail is forwarded once its owner confirms (the link, or POST /email/forwarding/targets/{id}/verify with the code). * forwards every address without its own alias. GET /email/forwarding/{domain}/messages lists the last 30 days of mail with its status; held mail (spam, over the daily limit) can be forwarded with /release.

Incoming mail to webhook

Instead of forwarding, an address can post each mail it receives to your HTTPS endpoint as JSON: bodies, headers and attachments in base64. It is open after a short review of what you will use it for; ask on a domain's Email Forwarding page.

curl
$ curl -X POST https://nameocean.net/api/v1/email/forwarding/example.com/webhooks \
    -H "Authorization: Bearer $NAMEOCEAN_API_KEY" -H "Content-Type: application/json" \
    -d '{"localpart": "inbound", "url": "https://example.com/hooks/mail"}'
POST https://example.com/hooks/mail
X-NameOcean-Event: email.received
X-NameOcean-Signature: t=1794300000,v1=5f2b…

{
  "id": "6f1c2a4e-8b3d-4f5a-9c7e-1d2b3a4c5e6f",
  "event": "email.received",
  "envelope": {"from": "alice@example.org", "to": "inbound@example.com"},
  "from": "Alice <alice@example.org>",
  "subject": "Order 1042",
  "text": "Hi…",
  "html": "<p>Hi…</p>",
  "headers": [["From", "Alice <alice@example.org>"], …],
  "attachments": [{"filename": "invoice.pdf", "content_type": "application/pdf", "size": 48211,
                   "content_base64": "JVBERi0…"}],
  "spam_score": 0.4,
  "size": 66120
}

The signature works like the account webhooks: see verifying a signature.

Events

Account webhooks can subscribe to email.*: email.delivered, email.delayed, email.bounced and email.suppressed for mail you send, email.mailbox.created, email.mailbox.deleted, email.forwarding.enabled and email.forwarding.disabled (also sent when a domain stops qualifying for free forwarding, with the reason).

From the terminal

nameocean
$ nameocean email send --from info@example.com --to alice@example.org \
    --subject "Order 1042 shipped" --text "Your order is on its way." --attach invoice.pdf
$ nameocean email sent ls --status failed
$ nameocean email mailboxes add example.com info --name "Info"
$ nameocean email aliases add example.com sales info
$ nameocean email check example.com
$ nameocean email forwards on example.com
$ nameocean email forwards add example.com hello me@gmail.com
$ nameocean email inbound add example.com support https://example.com/hooks/mail

Every command takes --json. Install and all commands: CLI.

From your AI

Over MCP an assistant can list your mail domains, check their DNS, create mailboxes and aliases, turn forwarding on, and send an email after showing it to you. Mailbox passwords are never sent to the AI: you read them in the dashboard.