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
| Field | Type | Required | Description |
|---|---|---|---|
name | string | required | Template name (1–255 characters). |
type | string | required | editor or code. |
import_format | string | required if code | How the coded template is provided. Must be html, zip, or url. |
content_base64 | string | required if html or zip | Base64-encoded file content. |
url | string | required if url | URL 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
| Status | Message | Cause |
|---|---|---|
400 | Invalid request body. | Request body could not be parsed. |
400 | Please provide a name for this template. | name is empty or whitespace. |
400 | Template name must not exceed 255 characters. | name exceeds 255 characters. |
400 | You must provide a valid template type. Must be 'editor' or 'code'. | type is invalid. |
400 | The import format is required for coded templates. Must be 'html', 'zip', or 'url'. | import_format missing for coded template. |
400 | Please provide a valid import format. Must be 'html', 'zip', or 'url'. | import_format is invalid. |
400 | Please provide the content_base64 field for HTML and ZIP coded templates. | content_base64 missing for html/zip. |
400 | We were unable to decode the base64 content. | content_base64 is not valid base64. |
400 | The url field is required for URL-based coded templates. | url missing for url format. |
400 | The url must start with http:// or https:// | url has an invalid scheme. |
500 | We had an internal issue while processing your template. | S3 upload or key generation failed. |