- limits-pricing, index, migrate-from-resend: Free 3,000/mo, Pro $20 then
$0.80/1k, Scale $90 for 150,000 then $0.60/1k (the live GET /billing/plans);
pay-as-you-go, auth-email allowance and Mail Studio grandfathering lines
removed (not implemented).
- sdk-typescript + quickstart: @scribase/mail is not on npm, marked {soon}.
- test-mode: SMTP submission marked {soon}; "open source (MIT)" and
"your own install" removed (the source is not published); local dev =
sk_test_ key against the hosted API.
- build.mjs default base URL -> https://scribase.com/mail/docs/ (published
there from the scribase www repo, commit 77f1469).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
110 lines
3.9 KiB
Markdown
110 lines
3.9 KiB
Markdown
---
|
|
title: Quickstart
|
|
nav: Quickstart
|
|
description: Send your first email with Scribase Mail in two minutes using curl or the TypeScript SDK. Resend-compatible API, built-in magic-link login, one bill with your Scribase database and auth.
|
|
---
|
|
|
|
Scribase Mail sends and receives email for your app. Add your domain, publish three DNS records, and send sign-in links, codes, receipts and alerts with one HTTP call. The API matches Resend's, so the `resend` SDK you already have works by changing the base URL. Sign-in emails (magic links and one-time codes with a verifiable JWT) are built in, and the bill is the same Scribase bill as your database and auth.
|
|
|
|
Who it is for: founders and small teams already running on Supabase, Neon or Resend who want one account for data, auth and email.
|
|
|
|
## 1. Get an API key
|
|
|
|
Sign in at [mail.scribase.com](https://mail.scribase.com/signup) (magic link, no password, no card), open **API keys**, create a key. Keys start with `sk_` and are shown once. A `full_access` key can manage domains, keys and webhooks; a `sending_access` key can only send (optionally from one domain). Use sending keys in app servers.
|
|
|
|
```sh
|
|
export SCRIBASE_MAIL_API_KEY=sk_...
|
|
```
|
|
|
|
## 2. Add your domain
|
|
|
|
```sh
|
|
curl -X POST https://mail-api.scribase.com/domains \
|
|
-H "Authorization: Bearer $SCRIBASE_MAIL_API_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{ "name": "yourapp.com" }'
|
|
```
|
|
|
|
The answer lists the DNS records to publish (`records[]`: DKIM TXT, SPF TXT on the `send` sub-domain, DMARC TXT). Add them at your DNS provider, then:
|
|
|
|
```sh
|
|
curl -X POST https://mail-api.scribase.com/domains/$DOMAIN_ID/verify \
|
|
-H "Authorization: Bearer $SCRIBASE_MAIL_API_KEY"
|
|
```
|
|
|
|
`GET /domains/$DOMAIN_ID` shows `status: "verified"` once DKIM and SPF resolve. Details on each record: [Domains and DNS](domains-dns/).
|
|
|
|
## 3. Send
|
|
|
|
### curl
|
|
|
|
```sh
|
|
curl -X POST https://mail-api.scribase.com/emails \
|
|
-H "Authorization: Bearer $SCRIBASE_MAIL_API_KEY" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"from": "Your App <hello@yourapp.com>",
|
|
"to": ["jane@example.com"],
|
|
"subject": "Welcome",
|
|
"html": "<p>Thanks for signing up.</p>",
|
|
"text": "Thanks for signing up."
|
|
}'
|
|
```
|
|
|
|
```json
|
|
{ "id": "7af8001f-54d6-4607-b951-ee1cc2ad60d5" }
|
|
```
|
|
|
|
### TypeScript {soon}
|
|
|
|
The `@scribase/mail` package is not on npm yet. Until it is, use the `resend` package with a new base URL (next section) or plain `fetch`.
|
|
|
|
```sh
|
|
npm install @scribase/mail # not published yet
|
|
```
|
|
|
|
```ts
|
|
import { ScribaseMail } from "@scribase/mail";
|
|
|
|
const mail = new ScribaseMail(process.env.SCRIBASE_MAIL_API_KEY);
|
|
|
|
const { data, error } = await mail.emails.send({
|
|
from: "Your App <hello@yourapp.com>",
|
|
to: ["jane@example.com"],
|
|
subject: "Welcome",
|
|
html: "<p>Thanks for signing up.</p>",
|
|
text: "Thanks for signing up.",
|
|
});
|
|
|
|
if (error) throw new Error(`${error.name}: ${error.message}`);
|
|
console.log(data.id);
|
|
```
|
|
|
|
Zero dependencies; runs on Node 18+, Bun, Deno and Cloudflare Workers. Every method returns `{ data, error }` like the Resend SDK, so switching is an import change. Full surface: [TypeScript SDK](sdk-typescript/).
|
|
|
|
### Already on the `resend` package?
|
|
|
|
```ts
|
|
const resend = new Resend(process.env.SCRIBASE_MAIL_API_KEY, {
|
|
baseUrl: "https://mail-api.scribase.com",
|
|
});
|
|
```
|
|
|
|
or set `RESEND_BASE_URL=https://mail-api.scribase.com`. See [Migrate from Resend](migrate-from-resend/).
|
|
|
|
## 4. Check what happened
|
|
|
|
```sh
|
|
curl https://mail-api.scribase.com/emails/$EMAIL_ID \
|
|
-H "Authorization: Bearer $SCRIBASE_MAIL_API_KEY"
|
|
```
|
|
|
|
`last_event` moves through `queued`, `sent`, `delivered` (or `bounced`, `complained`, `failed`). To be told instead of asking, add a [webhook](webhooks/).
|
|
|
|
## Next
|
|
|
|
- [Magic links and OTP](auth/): passwordless sign-in for your app without Clerk's email tier.
|
|
- [Use as Supabase's mail server](supabase/): custom SMTP and the Send Email Hook.
|
|
- [API reference](api-reference/): every endpoint, request and response.
|
|
- [Limits and pricing](limits-pricing/): Free 3,000/month, Pro $20, Scale $90.
|