Custom headers
headers is an object of string keys to string values, written into the message as-is.
import { SpacePost } from "@spacepost/node";
const spacepost = new SpacePost(process.env.SPACEPOST_API_KEY);
await spacepost.emails.send({ from: "Acme <hello@acme.com>", to: "user@example.com", subject: "Weekly digest", html: "<p>...</p>", headers: { "List-Unsubscribe": "<https://acme.com/unsubscribe?u=1042>, <mailto:unsubscribe@acme.com>", "List-Unsubscribe-Post": "List-Unsubscribe=One-Click", "X-Entity-Ref-ID": "digest-2026-w43-1042", },});curl -X POST https://api.spacepost.dev/emails \ -H "Authorization: Bearer $SPACEPOST_API_KEY" -H "Content-Type: application/json" \ -d '{ "from": "Acme <hello@acme.com>", "to": ["user@example.com"], "subject": "Weekly digest", "html": "<p>...</p>", "headers": { "List-Unsubscribe": "<https://acme.com/unsubscribe?u=1042>", "List-Unsubscribe-Post": "List-Unsubscribe=One-Click" } }'Common uses
Section titled “Common uses”| Header | Purpose |
|---|---|
List-Unsubscribe and List-Unsubscribe-Post |
One-click unsubscribe (RFC 8058). Required by Gmail and Yahoo for bulk senders. Broadcasts add it automatically. |
X-Entity-Ref-ID |
A unique value per email. Stops Gmail from collapsing similar messages into one thread or hiding the footer. |
In-Reply-To, References |
Thread a message under an existing conversation. |
X-* |
Any application-specific metadata. Over SMTP, X-* headers are forwarded, except SpacePost’s own X-SpacePost-* control headers. |