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

# Create a template from a website

`POST /v1/templates/from-website`

## Request

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

Checks that the website is a public page Samva can read, creates an email template project from Samva's canonical TSX starter, and returns the template with status 201 and the request that makes the template assistant match the site. The assistant runs when the request is sent in the editor; it rebuilds the project's theme and blocks from the site and proposes a brand that applies only after the customer approves it. A 422 names why the site cannot be matched: not a web address, not public, no answer, a missing page, refused automated visits, or not a web page.

## Request body

- CreateTemplateFromWebsitePayload
  - `url` string, required: The website whose look the template should match: a public https address, or a bare domain such as `example.com`.
  - `name` string, nullable
  - `namespaceId` string
  - `idempotencyKey` string, required: Repeating a request with the same key, address, name, and namespace returns the project the first one created, even if the site has since stopped answering. The same key with another address, name, or namespace is refused with a 409.

## Response `201`

Success

- TemplateFromWebsite
  - `template` Template, required
    - `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
  - `website` object, required
    - `url` string, required: The address Samva checked, normalized.
    - `host` string, required
  - `ask` string, required: The request to send the template assistant in the editor. The assistant reads the site, rebuilds the project's theme and blocks to match it, and proposes a brand that changes nothing until the customer applies it.

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