Appearance
Template tiers
Mail Lune supports three template scopes under one API key:
| Tier | Who sees it | How to create |
|---|---|---|
| User template | Only that user | POST /v1/templates with userId |
| Shared template | All users of your API key | POST /v1/templates without userId |
| Mail Lune library | Everyone | Curated by Mail Lune — GET /v1/templates/library |
The SDK template picker shows user templates and shared templates together under "My Templates", and Mail Lune starter templates under "Mail Lune".
List templates
bash
GET /v1/templates?userId=user_123
Authorization: Bearer mms_live_YOUR_KEYWhen userId is provided, returns both that user's own templates and any account-shared templates (those created without a userId). This is what the SDK uses to populate the "My Templates" tab.
Without userId, returns all templates for your API key (useful for server-side admin tasks).
Filter by metadata:
bash
GET /v1/templates?userId=user_123&meta[customerId]=cust_456Any meta[key]=value query parameter filters by that metadata entry, letting you scope templates to a specific customer or category.
Response:
json
[
{
"_id": "664f1a2b3c4d5e6f7a8b9c0d",
"name": "Welcome email",
"thumbnail": "https://assets.maillune.com/mms/key/uuid.jpg",
"tags": ["onboarding"],
"metadata": { "customerId": "cust_456" },
"userId": "user_123",
"updatedAt": "2026-05-19T10:23:00.000Z"
},
{
"_id": "774f1a2b3c4d5e6f7a8b9c0e",
"name": "Company footer",
"thumbnail": null,
"tags": ["shared"],
"metadata": {},
"updatedAt": "2026-05-18T08:00:00.000Z"
}
]The second entry has no userId — it's an account-shared template visible to all your users.
Get a template
bash
GET /v1/templates/:id
Authorization: Bearer mms_live_YOUR_KEYReturns the full template including blockTree and metadata:
json
{
"_id": "664f1a2b3c4d5e6f7a8b9c0d",
"name": "Welcome email",
"blockTree": { "canvas": {}, "metadata": {}, "blocks": [] },
"metadata": { "customerId": "cust_456", "category": "onboarding" },
"updatedAt": "2026-05-19T10:23:00.000Z"
}Create a template
bash
POST /v1/templates
Authorization: Bearer mms_live_YOUR_KEY
Content-Type: application/json
{
"name": "Welcome email",
"userId": "user_123",
"blockTree": { ... },
"metadata": {
"customerId": "cust_456",
"category": "onboarding"
}
}userId— omit to create an account-shared template visible to all users of your API key.metadata— optional free-form key/value pairs. Use these to attach any business context (customer ID, campaign, category, etc.) and filter on them later via?meta[key]=value.
Returns the created template with its _id.
INFO
Templates count against the plan limit (limits.templates). Free plan: 3 templates. Pro+: unlimited.
Update a template
bash
PUT /v1/templates/:id
Authorization: Bearer mms_live_YOUR_KEY
Content-Type: application/json
{
"name": "Updated name",
"blockTree": { ... },
"metadata": { "category": "transactional" }
}All fields are optional — only provided fields are updated. Sending metadata replaces the entire metadata map.
Delete a template
bash
DELETE /v1/templates/:id
Authorization: Bearer mms_live_YOUR_KEYReturns { "ok": true }.
Template library
The curated Mail Lune starter library. No authentication required.
bash
GET /v1/templates/libraryjson
[
{
"_id": "seed-0",
"name": "Newsletter",
"tags": ["newsletter"],
"thumbnail": null,
"blockTree": { ... }
}
]Multi-tenant example
A SaaS CRM embedding the SDK for their own customers:
js
// Each of your customers gets their own userId
const builder = document.querySelector('email-builder');
builder.setAttribute('user-id', currentUser.id);
// Server-side: create a shared company template visible to all users
await fetch('https://api.maillune.com/v1/templates', {
method: 'POST',
headers: {
Authorization: 'Bearer mms_live_YOUR_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Company Newsletter',
// no userId → shared with all users of this API key
blockTree: { ... },
metadata: { category: 'newsletter' },
}),
});
// Server-side: list only templates for a specific customer
const res = await fetch(
`https://api.maillune.com/v1/templates?userId=${customerId}&meta[category]=newsletter`,
{ headers: { Authorization: 'Bearer mms_live_YOUR_KEY' } }
);