---
title: "Create a template"
method: POST
path: "/v1/templates"
tags: ["Templates"]
---

# Create a template

`POST /v1/templates`

## Request

- Base URL: `https://api.samva.dev`
- URL: `https://api.samva.dev/v1/templates`
- Auth: API key in header `x-api-key`

Creates an email template project from Samva's canonical TSX starter and returns its template entry with status 201.

## Request body

- CreateTemplatePayload
  - `name` string, required
  - `projectName` string, nullable
  - `slug` string, nullable
  - `galleryTemplateId` string, nullable
  - `useBrand` boolean, nullable: With `galleryTemplateId`: whether the new project's `theme.css` imports the organization's default brand (`@import "samva:brand";`) over the starter's look. Defaults to false.
  - `description` string, nullable
  - `category` 'transactional' | 'marketing' | 'support' | 'notification' | 'verification' | 'reminder' | 'alert', nullable
  - `isActive` boolean, nullable
  - `namespaceId` string
  - `shared` boolean, nullable: Share the new organization-level project with every namespace: namespace-scoped keys read and send its entries but cannot change them. Defaults to false. Not with `namespaceId`, and not from a namespace-scoped key.
  - `idempotencyKey` string, required

## Response `201`

Success

- Template
  - `id` string, required
  - `slug` string, required
  - `name` string, required
  - `channel` 'email', required
  - `projectId` string, required
  - `namespaceId` string, required
  - `shared` boolean, required: Whether the template's project is shared with every namespace. Every entry in a project shares it. A namespace-scoped key reads and sends a shared template in its own namespace but cannot change it. Only an organization-level project is shared.
  - `entryPath` string, required
  - `status` 'draft' | 'pending' | 'approved' | 'published' | 'rejected' | 'archived', required
  - `isActive` boolean, required
  - `publishedAt` string, nullable, required
  - `brand` TemplatePublicationBrand, required
    - `slug` string, required: The brand the publication imports.
    - `digest` string, required: The brand's digest when the publication was built.
    - `stale` boolean, required: Whether the brand has changed since this publication was built. Publishing the same commit again picks up the change.
  - `fromDefault` TemplateFromDefault, required
    - `email` string, required
    - `name` string, nullable
  - `usageCount` integer, required
  - `lastUsedAt` string, nullable, required
  - `createdAt` string, required
  - `updatedAt` string, required
  - `familyId` string, required
  - `description` string, nullable, required
  - `category` 'transactional' | 'marketing' | 'support' | 'notification' | 'verification' | 'reminder' | 'alert', nullable, required
  - `replyToDefault` string[], nullable, required
  - `trackingDefault` object, nullable, required
    - `opens` boolean, nullable
    - `clicks` boolean, nullable
  - `email` object, nullable, required
    - `subject` string, required
    - `preheader` string, nullable, required
    - `headers` object, nullable, required
  - `publicationId` string, required
  - `inputContractId` string, required
  - `inputSchema` object, nullable, required

## Other responses

- `401`: UnauthorizedError
- `403`: ForbiddenError
- `404`: ResourceNotFoundError
- `409`: ConflictError
- `422`: ValidationError
- `500`: InternalError
- `504`: GatewayTimeoutError

---

[API](https://skmtc.dev/samva/apis/samva-api.md) · [All operations](https://skmtc.dev/samva/apis/samva-api/llms.txt) · [OpenAPI document](https://skmtc.dev/samva/apis/samva-api/revisions/a99408542cc3?raw)
