Prompt

How do I send transactional emails from an API?

Technology / API Platforms5 observationsLast seen Sep 22, 2026

Latest observation

Sep 22, 2026MistralWeb search: on

To send transactional emails from an API, follow this step-by-step process using a developer-focused email API (e.g., Notify, Resend, Postmark, or Mailgun). These services handle delivery, authentication, and logging, so you don’t need to manage SMTP or custom infrastructure.



Step 1: Choose a Transactional Email API

Pick a provider that fits your needs. Here are the best options for developers:

ProviderAPI TypeFree TierKey FeaturesBest For
NotifyREST1,000 emails/monthMinimal setup, delivery logs, webhooksSimplest solution
ResendREST3,000 emails/monthModern API, React Email, webhooksDeveloper experience
PostmarkREST100 emails/monthFast delivery, detailed logs, webhooksSpeed & deliverability
MailgunREST100 emails/dayInbound/outbound APIs, webhooksGranular control
MailtrapRESTFree tierHigh deliverability, webhooksAnalytics & infrastructure


Step 2: Sign Up and Verify Your Domain

  1. Create an Account: Sign up for your chosen provider (e.g., Notify, Resend, Postmark).
  2. Add a Sending Domain:
    • In the provider’s dashboard, add your domain (e.g., yourdomain.com or mail.yourdomain.com).
    • The provider will generate DNS records (SPF, DKIM, DMARC) for you to add to your domain’s DNS settings.
  3. Verify the Domain:
    • Add the DNS records to your domain registrar (e.g., Cloudflare, AWS Route 53, GoDaddy).
    • Wait for verification (usually 24–48 hours due to DNS propagation).
    • Once verified, you can send emails from addresses like noreply@yourdomain.com.


Step 3: Generate an API Key

  • In your provider’s dashboard, generate an API key (or use an existing one).
  • Keep this key secure—never expose it in client-side code or public repositories.


Step 4: Send an Email via API

Use the provider’s REST API to send an email. Here’s how to do it with cURL and JavaScript (Node.js) for popular providers:


Example 1: Notify

cURL:

curl -X POST https://notify.cx/api/email/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "from": "noreply@yourdomain.com",
    "subject": "Your Password Reset Link",
    "body": "Click here to reset your password: https://yourapp.com/reset?token=UNIQUE_TOKEN"
  }'

Node.js (Axios):

const axios = require('axios');

axios.post('https://notify.cx/api/email/send', {
  to: 'user@example.com',
  from: 'noreply@yourdomain.com',
  subject: 'Your Password Reset Link',
  body: 'Click here to reset your password: https://yourapp.com/reset?token=UNIQUE_TOKEN'
}, {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

Example 2: Resend

cURL:

curl -X POST https://api.resend.com/emails \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "from": "noreply@yourdomain.com",
    "subject": "Your Receipt",
    "html": "<p>Here is your receipt: <strong>Order #12345</strong></p>"
  }'

Node.js (Axios):

const axios = require('axios');

axios.post('https://api.resend.com/emails', {
  to: 'user@example.com',
  from: 'noreply@yourdomain.com',
  subject: 'Your Receipt',
  html: '<p>Here is your receipt: <strong>Order #12345</strong></p>'
}, {
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

Example 3: Postmark

cURL:

curl -X POST https://api.postmarkapp.com/email \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "X-Postmark-Server-Token: YOUR_API_KEY" \
  -d '{
    "To": "user@example.com",
    "From": "noreply@yourdomain.com",
    "Subject": "Account Notification",
    "TextBody": "Your account has been updated.",
    "HtmlBody": "<p>Your account has been updated.</p>"
  }'

Node.js (Axios):

const axios = require('axios');

axios.post('https://api.postmarkapp.com/email', {
  To: 'user@example.com',
  From: 'noreply@yourdomain.com',
  Subject: 'Account Notification',
  TextBody: 'Your account has been updated.',
  HtmlBody: '<p>Your account has been updated.</p>'
}, {
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'X-Postmark-Server-Token': 'YOUR_API_KEY'
  }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

Example 4: Mailgun

cURL:

curl -s --user 'api:YOUR_API_KEY' \
  https://api.mailgun.net/v3/yourdomain.com/messages \
  -F from='noreply@yourdomain.com' \
  -F to='user@example.com' \
  -F subject='Password Reset' \
  -F text='Click here to reset your password: https://yourapp.com/reset?token=UNIQUE_TOKEN'

Node.js (Axios):

const axios = require('axios');
const FormData = require('form-data');

const form = new FormData();
form.append('from', 'noreply@yourdomain.com');
form.append('to', 'user@example.com');
form.append('subject', 'Password Reset');
form.append('text', 'Click here to reset your password: https://yourapp.com/reset?token=UNIQUE_TOKEN');

axios.post('https://api.mailgun.net/v3/yourdomain.com/messages', form, {
  headers: {
    ...form.getHeaders(),
    'Authorization': 'Basic ' + Buffer.from('api:YOUR_API_KEY').toString('base64')
  }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));


Step 5: Handle Responses and Errors

  • Success Response: Most APIs return a 200 OK or 202 Accepted status with a message ID (e.g., {"id": "msg_12345"}).
  • Error Handling: Check for errors (e.g., invalid API key, unverified domain, or rate limits). Example error response:
    {
      "error": "Invalid API key",
      "code": 401
    }
    


Step 6: Set Up Webhooks (Optional but Recommended)

Webhooks allow your app to automatically receive notifications for delivery events (e.g., bounces, opens, clicks). Here’s how to set them up:

  1. Configure Webhook URL:

    • In your provider’s dashboard, add a webhook endpoint (e.g., https://yourapp.com/webhooks/email).
    • Example (Notify):
      # Webhook payload for a bounce event
      {
        "event": "bounce",
        "email": "user@example.com",
        "reason": "mailbox_full",
        "timestamp": "2026-09-22T12:00:00Z"
      }
      
  2. Handle Webhook Events:

    • In your backend, parse the webhook payload and update your app’s logs or user records.
    • Example (Node.js with Express):
      const express = require('express');
      const app = express();
      
      app.post('/webhooks/email', (req, res) => {
        const event = req.body.event;
        const email = req.body.email;
      
        if (event === 'bounce') {
          console.log(`Email bounced for ${email}: ${req.body.reason}`);
          // Update your database or retry logic here
        }
      
        res.status(200).send('OK');
      });
      
      app.listen(3000, () => console.log('Webhook server running on port 3000'));
      


Step 7: Test Your Setup

  1. Send a Test Email:

    • Use the API to send a test email to your own address.
    • Verify it arrives in your inbox (not spam).
  2. Check Logs:

    • In your provider’s dashboard, confirm the email was sent and delivered.
    • Example: Notify and Postmark provide delivery logs for debugging.
  3. Test Webhooks:

    • Trigger a bounce (e.g., send to a non-existent email) and verify your webhook receives the event.


Best Practices

  1. Use a Verified Domain: Always send from a verified domain (e.g., noreply@yourdomain.com) to improve deliverability and avoid spam filters.
  2. Secure Your API Key: Store it in environment variables (e.g., .env file) and never expose it in client-side code.
  3. Handle Bounces: Use webhooks to automatically retry or log failed deliveries.
  4. Rate Limits: Monitor your provider’s rate limits to avoid throttling.
  5. Templates: For dynamic content (e.g., receipts), use HTML templates or a templating engine (e.g., Handlebars, React Email).


Recommended Providers for Specific Use Cases

Use CaseRecommended ProviderWhy?
Simplest setupNotifyMinimal API, no bloat, built-in logs
Modern developer experienceResendClean API, React Email, TypeScript SDK
Fast deliveryPostmarkSub-second delivery, detailed logs
Granular controlMailgunInbound/outbound APIs, suppression lists
High deliverabilityMailtrapSeparate streams, analytics
AWS-native teamsAmazon SESLow-cost, integrates with AWS

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (5 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.