Skip to Content

Create a template from a brief

Create a template from a brief. Request: POST /v1/templates/from-brief. Scope: templates:create.

POST
/v1/templates/from-brief

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.

Authorization

apiKey
headerx-api-key<token>

Header Parameters

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

Request Body

application/json
  1. body
brief*string

What 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.

Length1 <= length <= 4000
name?|null
galleryTemplateId?|null
useBrand?|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

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*|||null
ask*string

The 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.

Example Request
import { createClient } from "samva";

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

const result = await samva.templates.createFromBrief({
  "brief": "example"
});
Example Response
{
  "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"
}

Related documentation