Create a template from a website

Create a template from a website. View request and response details for this Samva email API endpoint.

POST
/v1/templates/from-website

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.

Authorization

apiKey
headerx-api-key<token>

Header Parameters

idempotency-key*string
Length1 <= length <= 255

Request Body

application/json
  1. body
url*string

The website whose look the template should match: a public https address, or a bare domain such as example.com.

Length1 <= length <= 2048
name?|null
namespaceId?|

The namespace the new template project belongs to. Omit for organization level. A namespace-scoped key always creates in its own namespace.

Response Body

Success

application/json
  1. response
template*
website*
ask*string

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.

Example Request
import { createClient } from "samva";const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });const result = await samva.templates.createFromWebsite({  "url": "example"});
Example Response
{  "template": {    "id": "string",    "slug": "string",    "name": "string",    "channel": "sms",    "projectId": "string",    "namespaceId": "string",    "shared": true,    "entryPath": "string",    "status": "draft",    "isActive": true,    "publishedAt": "string",    "brand": {      "slug": "string",      "digest": "string",      "stale": true    },    "fromDefault": {      "email": "string",      "name": "string"    },    "usageCount": 0,    "lastUsedAt": "string",    "createdAt": "string",    "updatedAt": "string",    "familyId": "string",    "description": "string",    "category": "transactional",    "replyToDefault": [      "string"    ],    "trackingDefault": {      "opens": true,      "clicks": true    },    "email": {      "subject": "string",      "preheader": "string",      "headers": {        "property1": "string",        "property2": "string"      }    },    "sms": {      "body": "string",      "encoding": "string",      "estimatedSegments": -9007199254740991,      "category": "transactional"    },    "whatsapp": {      "name": "string",      "language": "string",      "category": "marketing",      "components": [        {          "type": "HEADER",          "format": "TEXT",          "text": "string",          "example": {            "header_text": [              "string"            ]          }        }      ]    },    "publicationId": "string",    "inputContractId": "string",    "inputSchema": {      "property1": "string",      "property2": "string"    }  },  "website": {    "url": "string",    "host": "string"  },  "ask": "string"}

Related documentation