Add a template entry
Registers a `.tsx` file under `templates/` or `emails/` in an existing template project as its own template and returns it with status 201.
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.
apiKeyx-api-key<token>id*string^tproj_[0-9a-hjkmnp-tv-z]{16,24}$application/json- body
entryPath*string^(?!\/)(?!.*\\)(?!.*(?:^|\/)\.{1,2}(?:\/|$))(?!.*(?:^|\/)\.git(?:\/|$))(?:templates|emails)\/.+\.tsx$length <= 1024name*string1 <= length <= 200slug*string^(?=.{1,100}$)[a-z0-9]+(?:-[a-z0-9]+)*$description?string|null|nullcategory?|null|nullSuccess
application/json- response
id*TemplateId^tmpl_[0-9a-hjkmnp-tv-z]{16,24}$slug*stringname*stringchannel*string"sms""whatsapp""email"projectId*TemplateProjectId^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*booleanWhether 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^(?!\/)(?!.*\\)(?!.*(?:^|\/)\.{1,2}(?:\/|$))(?!.*(?:^|\/)\.git(?:\/|$))(?:templates|emails)\/.+\.tsx$length <= 1024status*string"draft""pending""approved""published""rejected""archived"publishedAt*string|nullbrand*|nullfromDefault*|nullusageCount*integer0 <= value <= 9007199254740991lastUsedAt*string|nullcreatedAt*stringupdatedAt*stringfamilyId*|nulldescription*string|nullcategory*|nullreplyToDefault*array<string>|nulltrackingDefault*|nullemail*|nullsms*|nullwhatsapp*|nullpublicationId*|nullinputContractId*|nullinputSchema*|nullimport { createClient } from "samva";const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });const result = await samva.templates.addEntry({ "id": "example", "entryPath": "example", "name": "example", "slug": "example"});{ "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" }}