Docs/Email API

Email API

Send transactional and marketing emails with industry-leading deliverability. Track opens, clicks, and bounces in real-time.

99.9% Deliverability

Enterprise-grade infrastructure with automatic IP warming.

Real-time Analytics

Track opens, clicks, bounces, and complaints instantly.

DKIM & SPF

Automatic email authentication with guided DNS setup.

Quick Start

Send your first email in seconds. Canary handles all the complexity of email deliverability so you can focus on your product.

POST/v1/email
curl -X POST https://api.canarymsg.dev/v1/email \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '
  {
    "from": "hello@yourcompany.com",
    "to": "user@example.com",
    "subject": "Welcome to our platform!",
    "html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>"
  }
'

Response

{
  "id": "email_abc123xyz",
  "from": "hello@yourcompany.com",
  "to": "user@example.com",
  "subject": "Welcome to our platform!",
  "status": "queued",
  "created_at": "2024-01-01T12:00:00Z"
}

Request Parameters

ParameterTypeRequiredDescription
fromstringSender email address (must be verified)
tostring | arrayRecipient email address(es)
subjectstringEmail subject line
htmlstring*HTML content of the email
textstring*Plain text content of the email
ccstring | arrayOptionalCC recipient email address(es)
bccstring | arrayOptionalBCC recipient email address(es)
reply_tostringOptionalReply-to email address
attachmentsarrayOptionalFile attachments (base64 encoded)
headersobjectOptionalCustom email headers
tagsarrayOptionalTags for categorization and analytics

* Either html or text is required

Email Templates

Create reusable email templates with dynamic variables. Templates support Handlebars syntax for personalization.

Create a Template

POST/v1/email/templates
{
  "name": "welcome_email",
  "subject": "Welcome to {{company_name}}, {{first_name}}!",
  "html": "<h1>Welcome, {{first_name}}!</h1><p>Thanks for joining {{company_name}}.</p>"
}

Send with Template

POST/v1/email
{
  "from": "hello@yourcompany.com",
  "to": "user@example.com",
  "template": "welcome_email",
  "variables": {
    "first_name": "Alice",
    "company_name": "Acme Inc"
  }
}

Domain Verification

Verify your domain to improve deliverability and enable custom sender addresses. Canary guides you through the DNS configuration process.

Add a Domain

POST/v1/email/domains
{
  "domain": "yourcompany.com"
}

DNS Records Response

{
  "domain": "yourcompany.com",
  "status": "pending",
  "dns_records": [
    {
      "type": "TXT",
      "name": "_dmarc.yourcompany.com",
      "value": "v=DMARC1; p=none; rua=mailto:dmarc@canarymsg.dev"
    },
    {
      "type": "TXT",
      "name": "canary._domainkey.yourcompany.com",
      "value": "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4..."
    },
    {
      "type": "TXT",
      "name": "yourcompany.com",
      "value": "v=spf1 include:_spf.canarymsg.dev ~all"
    }
  ]
}

Email Tracking

Track email engagement with open tracking, click tracking, and delivery status. All tracking is enabled by default but can be disabled per message.

Tracking Options

{
  "from": "hello@yourcompany.com",
  "to": "user@example.com",
  "subject": "Your weekly report",
  "html": "<p>Here's your report...</p>",
  "tracking": {
    "opens": true,
    "clicks": true,
    "unsubscribe": true
  }
}

Email Events

EventDescription
queuedEmail is queued for sending
sentEmail was sent to the receiving server
deliveredEmail was accepted by the receiving server
openedRecipient opened the email
clickedRecipient clicked a link in the email
bouncedEmail bounced (hard or soft)
complainedRecipient marked email as spam
unsubscribedRecipient clicked the unsubscribe link

SDK Examples

Node.js

import Canary from '@canary/node';

const canary = new Canary('YOUR_API_KEY');

const email = await canary.email.send({
  from: 'hello@yourcompany.com',
  to: 'user@example.com',
  subject: 'Welcome!',
  html: '<h1>Welcome to our platform!</h1>',
});

console.log('Email sent:', email.id);

Python

from canary import Canary

canary = Canary("YOUR_API_KEY")

email = canary.email.send(
    from_="hello@yourcompany.com",
    to="user@example.com",
    subject="Welcome!",
    html="<h1>Welcome to our platform!</h1>"
)

print(f"Email sent: {email.id}")

Next Steps