Skip to content

Quickstart

This guide takes you from nothing to a real email sent from your own domain.

  1. Create an API key

    Open the dashboard, go to API keys and click Create API key. Choose full_access while you experiment. Copy the key right away: it starts with sp_live_ and is shown only once.

    Terminal window
    export SPACEPOST_API_KEY="sp_live_YOUR_API_KEY"
  2. Send a test email

    You can send immediately, without a domain, using the shared test sender onboarding@test.spacepost.dev. It can only deliver to your own team members’ email addresses and to the test addresses such as delivered@test.spacepost.dev.

    Terminal window
    npm install @spacepost/node
    send.ts
    import { SpacePost } from "@spacepost/node";
    const spacepost = new SpacePost(process.env.SPACEPOST_API_KEY);
    const { data, error } = await spacepost.emails.send({
    from: "Acme <onboarding@test.spacepost.dev>",
    to: ["delivered@test.spacepost.dev"],
    subject: "Hello from SpacePost",
    html: "<strong>It works!</strong>",
    });
    if (error) {
    console.error(error); // { statusCode, name, message }
    } else {
    console.log("Sent", data.id);
    }

    The response is { "id": "0192e1c4-7a3b-7c1e-9d2f-3b5a8e6f4c10" }. Open the email in the dashboard to see its timeline: sent, then delivered.

  3. Add and verify your domain

    To send to anyone, send from a domain you own.

    Terminal window
    curl -X POST https://api.spacepost.dev/domains \
    -H "Authorization: Bearer $SPACEPOST_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{ "name": "acme.com" }'

    The response lists the DNS records to create: three DKIM CNAMEs, plus an MX and a TXT record for the send subdomain (the custom return path). Add them at your DNS provider (guides for Cloudflare, Route 53 and more), then ask SpacePost to check:

    Terminal window
    curl -X POST https://api.spacepost.dev/domains/$DOMAIN_ID/verify \
    -H "Authorization: Bearer $SPACEPOST_API_KEY"

    Or let the CLI do the work and watch DNS live:

    Terminal window
    npx spacepost domains doctor acme.com

    Verification usually completes within minutes. The domain status turns verified once DKIM is confirmed.

  4. Send from your domain

    await spacepost.emails.send({
    from: "Acme <hello@acme.com>",
    to: ["you@example.com"],
    subject: "First real email",
    html: "<p>Sent from my own domain.</p>",
    });