Prompt
How do I send receipt emails through an API?
Latest observation
Oct 17, 2026
OpenAI APIWeb search: off
To send receipt emails through an API, you typically do one of these:
-
Use an email service API (most common)
- Examples: SendGrid, Mailgun, Amazon SES, Postmark, SparkPost
- Your app generates the receipt data and sends it to the email provider’s API, which delivers the email.
-
Use your own backend + SMTP
- Your API endpoint receives the payment/receipt info
- Your server formats the receipt and sends it through an SMTP server
Typical flow
- Customer completes a purchase
- Your payment system confirms success
- Your backend creates a receipt email
- Your backend calls an email API with:
- recipient email
- subject
- HTML/text body
- receipt details
- Email provider sends it
Example using a generic REST email API
curl https://api.emailservice.com/send \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "customer@example.com",
"subject": "Your Receipt",
"html": "<h1>Thanks for your purchase</h1><p>Order #12345</p><p>Total: $29.99</p>"
}'
Example in Node.js
import fetch from "node-fetch";
async function sendReceiptEmail() {
const res = await fetch("https://api.emailservice.com/send", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.EMAIL_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
to: "customer@example.com",
subject: "Your Receipt",
html: "<h1>Thanks for your purchase</h1><p>Order #12345</p><p>Total: $29.99</p>"
})
});
const data = await res.json();
console.log(data);
}
Best practices
- Send from your backend, not directly from frontend code
- Use templates for consistent receipts
- Include order ID, items, amount, date, payment method
- Set up retries and logging
- Verify payment success before sending
- Send plain-text and HTML versions
- Authenticate with API keys stored securely
If you want a ready-made option
If you’re already using a provider like:
- Stripe: you can send custom receipt emails via your own email provider, or use Stripe’s built-in receipt emails for some payment flows
- PayPal: often has built-in receipt/payment notification features
- Square: supports receipt emailing in its APIs
If you tell me which platform/language you’re using (e.g. Stripe + Node, Python + SendGrid, etc.), I can give you a working example.