Skip to Content

Create a template

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

POST
/v1/templates

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

Authorization

apiKey
headerx-api-key<token>

Header Parameters

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

Request Body

application/json
  1. body
name*string
Length1 <= length <= 200
projectName?|null
slug?|null
galleryTemplateId?|null
useBrand?|null
description?string|null|null
category?|null|null
namespaceId?|

The namespace the new template project belongs to; the project and every entry added to it share it. Omit for organization level. A namespace-scoped key always creates in its own namespace.

shared?|

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.

Response Body

Success

application/json
  1. response
id*TemplateId
Match^tmpl_[0-9a-hjkmnp-tv-z]{16,24}$
slug*string
name*string
channel*string
Value in"sms""whatsapp""email"
projectId*TemplateProjectId
Match^tproj_[0-9a-hjkmnp-tv-z]{16,24}$
namespaceId*|

The namespace the template's project belongs to; every entry in a project shares it. Null at organization level. A namespace-scoped key reaches only its own namespace's templates and shared ones.

shared*boolean

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
Match^(?!\/)(?!.*\\)(?!.*(?:^|\/)\.{1,2}(?:\/|$))(?!.*(?:^|\/)\.git(?:\/|$))(?:templates|emails)\/.+\.tsx$
Lengthlength <= 1024
status*string
Value in"draft""pending""approved""published""rejected""archived"
publishedAt*string|null
brand*|null
fromDefault*|null
usageCount*integer
Range0 <= value <= 9007199254740991
lastUsedAt*string|null
createdAt*string
updatedAt*string
familyId*|null
description*string|null
category*|null
replyToDefault*array<string>|null
trackingDefault*|null
email*|null
sms*|null
whatsapp*|null
publicationId*|null
inputContractId*|null
inputSchema*|null
Example Request
import { createClient } from "samva";

const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });

const result = await samva.templates.create({
  "name": "example"
});
Example Response
{
  "id": "string",
  "slug": "string",
  "name": "string",
  "channel": "sms",
  "projectId": "string",
  "namespaceId": "string",
  "shared": true,
  "entryPath": "string",
  "status": "draft",
  "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"
  }
}

Related documentation