---
title: "Add a template entry"
method: POST
path: "/v1/templates/projects/{id}/entries"
tags: ["Templates"]
---

# Add a template entry

`POST /v1/templates/projects/{id}/entries`

## Request

- Base URL: `https://api.samva.dev`
- URL: `https://api.samva.dev/v1/templates/projects/{id}/entries`
- Auth: API key in header `x-api-key`

Registers a `.tsx` file under `templates/` or `emails/` in an existing template project as its own template and returns it with status 201. The file does not need to exist yet; publishing fails until a commit contains it. Repeating the call with the same entry path, name, and slug returns the existing template.

## Path parameters

- `id` string, required

## Request body

- AddTemplateEntryPayload
  - `entryPath` string, required
  - `name` string, required
  - `slug` string, required
  - `description` string, nullable
  - `category` 'transactional' | 'marketing' | 'support' | 'notification' | 'verification' | 'reminder' | 'alert', nullable

## 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)
