Skip to content

Tags

Tags are { name, value } pairs attached to an email. They are stored with the email, returned by GET /emails/{id} and echoed in every webhook payload for that email (as an object, "tags": { "category": "welcome" }). Use them to tie events back to your own records without storing the SpacePost id.

tags.ts
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: "Welcome",
html: "<p>Hi</p>",
tags: [
{ name: "category", value: "welcome" },
{ name: "user_id", value: "u_1042" },
],
});
  • Up to 50 tags per email.
  • name and value are each 1 to 256 characters and may contain only ASCII letters, numbers, underscores and dashes (A-Z a-z 0-9 _ -).
  • Spaces, dots, @ and non-ASCII characters are rejected with a 422. Hash or slug values such as email addresses first, for example user_1042 or a SHA-256 hex digest.