Create a template from a brief
Create a template from a brief. Request: POST /v1/templates/from-brief. Scope: templates:create.
Creates an email template project from the gallery design that best fits a brief (the first of POST /v1/templates/suggestions, or the galleryTemplateId you name) and returns it with status 201, the design it started from, the other suggestions, any company email the brief named, and the request that makes the template assistant adapt the design. The assistant runs when that request is sent in the editor; an agent of your own adapts the design through the workspace endpoints instead.
apiKeyx-api-key<token>idempotency-key*string1 <= length <= 255application/json- body
brief*stringWhat the email is for, as a person would ask for it: who sends it, to whom, and why. Naming a company's email ("like the Vercel login email") starts from Samva's recreation of it when the gallery has one.
1 <= length <= 4000name?|nullgalleryTemplateId?|nulluseBrand?|nullnamespaceId?|The namespace the new template project belongs to. Omit for organization level. A namespace-scoped key always creates in its own namespace.
Success
application/json- response
A template project created from a brief. startedFrom is the gallery design the project was created from.
template*startedFrom*alternatives*array<>The other designs suggested for the brief, best first.
recreation*|||nullask*stringThe request to send the template assistant in the editor: the brief, then the design the project starts from and what the gallery has of a company email the brief names. The assistant adapts the design to it; nothing runs until it is sent.
import { createClient } from "samva";
const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
const result = await samva.templates.createFromBrief({
"brief": "example"
});{
"template": {
"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"
}
},
"startedFrom": {
"galleryTemplateId": "string",
"slug": "string",
"name": "string",
"description": "string",
"intent": "string",
"tags": [
"string"
],
"structure": "string",
"imagery": "none",
"recreates": "string",
"reason": "string"
},
"alternatives": [
{
"galleryTemplateId": "string",
"slug": "string",
"name": "string",
"description": "string",
"intent": "string",
"tags": [
"string"
],
"structure": "string",
"imagery": "none",
"recreates": "string",
"reason": "string"
}
],
"recreation": {
"status": "exact",
"company": "string",
"galleryTemplateId": "string"
},
"ask": "string"
}