Simplifyd Cloud
SmailAPI ReferenceEmailsSend Email

Send Email

Send a single transactional or marketing email.

POST /api/v1/emails

Sends a single email. The from address must belong to a verified domain on the account. Authenticate with an X-API-Key header.

Headers

HeaderRequiredDescription
X-API-KeyYesAPI key for the developer account
Idempotency-KeyNoDeduplicates successful retries for 24 hours. Reusing the same key with a different request returns 409 Conflict. Maximum 256 characters.

Request body

FieldTypeRequiredDescription
fromstringYesSender address (must be on a verified domain)
tostring[]YesRecipient addresses
subjectstringYesEmail subject line
htmlstringNoHTML body
textstringNoPlain-text body
templateobjectNoPublished template reference and variables. When provided, omit html and text
ccstring[]NoCarbon copy recipients
bccstring[]NoBlind carbon copy recipients
reply_tostringNoReply-to address
tagsstring[]NoLabels for filtering in the dashboard
attachmentsobject[]NoFiles to attach. Maximum 10 files, 10 MB per file, 20 MB total
scheduled_atstringNoRFC3339 timestamp for future delivery. Omit to send immediately
typestringNo"transactional" (default) or "marketing"

At least one of html or text is required.

When using template, either the request or the template must provide from and subject.

Template object

FieldTypeRequiredDescription
idstringNoTemplate ID. Required if alias is omitted
aliasstringNoTemplate alias. Required if id is omitted
variablesobjectNoValues used to render {{{KEY}}} placeholders

Attachment object

FieldTypeRequiredDescription
filenamestringYesFile name shown to the recipient
contentstringYesBase64-encoded file bytes
content_typestringNoMIME type. If omitted, Smail guesses from the filename extension or uses application/octet-stream

Response

Returns 200 OK with an email object:

FieldTypeDescription
idstringUnique email ID
statusstring"queued", "sent", "failed", or "suppressed"
fromstringSender address
tostringPrimary recipient address
subjectstringSubject line
created_atstringISO 8601 timestamp
scheduled_atstringScheduled delivery timestamp, when provided
{
  "email": {
    "id": "em_01hx...",
    "status": "queued",
    "from": "noreply@yourdomain.com",
    "to": "user@example.com",
    "subject": "Your order has shipped",
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Code examples

curl https://api.smail.dev/api/v1/emails \
  -H "X-API-Key: sk_live_..." \
  -H "Idempotency-Key: order-1234-shipped" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "noreply@yourdomain.com",
    "to": ["user@example.com"],
    "subject": "Your order has shipped",
    "html": "<p>Your order #1234 is on its way!</p>",
    "text": "Your order #1234 is on its way!",
    "scheduled_at": "2026-05-14T15:30:00Z",
    "attachments": [
      {
        "filename": "invoice.txt",
        "content_type": "text/plain",
        "content": "SW52b2ljZSAjMTIzNA=="
      }
    ]
  }'
const { email } = await smail.emails.send({
  from: "noreply@yourdomain.com",
  to: ["user@example.com"],
  subject: "Your order has shipped",
  html: "<p>Your order #1234 is on its way!</p>",
  text: "Your order #1234 is on its way!",
  scheduled_at: "2026-05-14T15:30:00Z",
  attachments: [
    {
      filename: "invoice.txt",
      content_type: "text/plain",
      content: "SW52b2ljZSAjMTIzNA==",
    },
  ],
}, {
  idempotencyKey: "order-1234-shipped",
});
request := smail.SendEmailRequest{
    From:    "noreply@yourdomain.com",
    To:      []string{"user@example.com"},
    Subject: "Your order has shipped",
    HTML:    "<p>Your order #1234 is on its way!</p>",
    Text:    "Your order #1234 is on its way!",
    ScheduledAt: "2026-05-14T15:30:00Z",
    Attachments: []smail.EmailAttachment{
        {
            Filename:    "invoice.txt",
            ContentType: "text/plain",
            Content:     "SW52b2ljZSAjMTIzNA==",
        },
    },
}

email, err := client.Emails.SendWithOptions(ctx, request, smail.SendOptions{
    IdempotencyKey: "order-1234-shipped",
})

Error responses

StatusErrorDescription
401unauthorizedMissing or invalid API key
400from domain not verifiedThe from address domain is not verified
400invalid requestMissing required fields