Skip to main content

Create Template

Create a new template. Supports both editor (drag-and-drop) and coded (HTML/ZIP/URL) templates.


Endpoint

POST https://api.campaignlark.com/v1/templates

Request Body

FieldTypeRequiredDescription
namestringrequiredTemplate name (1–255 characters).
typestringrequirededitor or code.
import_formatstringrequired if codeHow the coded template is provided. Must be html, zip, or url.
content_base64stringrequired if html or zipBase64-encoded file content.
urlstringrequired if urlURL to fetch the HTML template from. Must start with http:// or https://.

Sample Request — Editor Template

POST https://api.campaignlark.com/v1/templates
Content-Type: application/json

{
"name": "Welcome Email",
"type": "editor"
}

Sample Request — Coded Template (HTML)

POST https://api.campaignlark.com/v1/templates
Content-Type: application/json

{
"name": "Custom Newsletter",
"type": "code",
"import_format": "html",
"content_base64": "PCFET0NUWVBFIGh0bWw+..."
}

Sample Request — Coded Template (URL)

POST https://api.campaignlark.com/v1/templates
Content-Type: application/json

{
"name": "External Template",
"type": "code",
"import_format": "url",
"url": "https://example.com/template.html"
}

Response

Success — 201 Created

Returns the created template object (see Template Object).


Errors

StatusMessageCause
400Invalid request body.Request body could not be parsed.
400Please provide a name for this template.name is empty or whitespace.
400Template name must not exceed 255 characters.name exceeds 255 characters.
400You must provide a valid template type. Must be 'editor' or 'code'.type is invalid.
400The import format is required for coded templates. Must be 'html', 'zip', or 'url'.import_format missing for coded template.
400Please provide a valid import format. Must be 'html', 'zip', or 'url'.import_format is invalid.
400Please provide the content_base64 field for HTML and ZIP coded templates.content_base64 missing for html/zip.
400We were unable to decode the base64 content.content_base64 is not valid base64.
400The url field is required for URL-based coded templates.url missing for url format.
400The url must start with http:// or https://url has an invalid scheme.
500We had an internal issue while processing your template.S3 upload or key generation failed.