Getting started
Quickstart
Send your first email with Stack Emails in under five minutes.
1. Create an API key
Sign up, open API Keys in the dashboard and create a key. Keys start with se_live_ (or se_test_ for test mode). Store it as an environment variable. You'll only see it once.
export STACKEMAILS_API_KEY=se_live_xxxxxxxxxxxx
2. Verify a domain
Open Domains > Add domain, enter a domain you own (we recommend a subdomain such as mail.acme.com) and add the DNS records shown at your DNS provider. Verification usually takes a few minutes. See Domains for details.
Until your domain is verified you can only send from addresses on domains you have verified.
3. Send an email
curl -X POST https://stackemails.com/v1/emails \
-H "Authorization: Bearer $STACKEMAILS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Acme <hello@mail.acme.com>",
"to": "you@example.com",
"subject": "Hello from Stack Emails",
"html": "<p>It works!</p>"
}'
The response contains the email id:
{ "id": "msg_5b1f0c6c2a8e4e0f", "status": "queued", "scheduled_at": null }
4. Or use the SDK
npm install stackemails
import { StackEmails } from "stackemails";
const stack = new StackEmails(process.env.STACKEMAILS_API_KEY);
const { id } = await stack.emails.send({
from: "Acme <hello@mail.acme.com>",
to: "you@example.com",
subject: "Hello from Stack Emails",
html: "<p>It works!</p>",
});
Snippets for Python, PHP, Go, Ruby, Java, .NET, Rust and Elixir are in the dashboard under API Keys > Code.
Next steps
- Track what happens next with webhooks.
- Add idempotency keys so retries never send twice.
- Read the deliverability guide.