Create a template
curl --request POST \
--url https://{notifuseDomain}/api/templates.create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"workspace_id": "ws_1234567890",
"id": "welcome_email",
"name": "Welcome Email",
"channel": "email",
"category": "transactional",
"template_macro_id": "<string>",
"test_data": {},
"settings": {},
"translations": {}
}
'import requests
url = "https://{notifuseDomain}/api/templates.create"
payload = {
"workspace_id": "ws_1234567890",
"id": "welcome_email",
"name": "Welcome Email",
"channel": "email",
"category": "transactional",
"template_macro_id": "<string>",
"test_data": {},
"settings": {},
"translations": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
workspace_id: 'ws_1234567890',
id: 'welcome_email',
name: 'Welcome Email',
channel: 'email',
category: 'transactional',
template_macro_id: '<string>',
test_data: {},
settings: {},
translations: {}
})
};
fetch('https://{notifuseDomain}/api/templates.create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{notifuseDomain}/api/templates.create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'workspace_id' => 'ws_1234567890',
'id' => 'welcome_email',
'name' => 'Welcome Email',
'channel' => 'email',
'category' => 'transactional',
'template_macro_id' => '<string>',
'test_data' => [
],
'settings' => [
],
'translations' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{notifuseDomain}/api/templates.create"
payload := strings.NewReader("{\n \"workspace_id\": \"ws_1234567890\",\n \"id\": \"welcome_email\",\n \"name\": \"Welcome Email\",\n \"channel\": \"email\",\n \"category\": \"transactional\",\n \"template_macro_id\": \"<string>\",\n \"test_data\": {},\n \"settings\": {},\n \"translations\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{notifuseDomain}/api/templates.create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"workspace_id\": \"ws_1234567890\",\n \"id\": \"welcome_email\",\n \"name\": \"Welcome Email\",\n \"channel\": \"email\",\n \"category\": \"transactional\",\n \"template_macro_id\": \"<string>\",\n \"test_data\": {},\n \"settings\": {},\n \"translations\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{notifuseDomain}/api/templates.create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"workspace_id\": \"ws_1234567890\",\n \"id\": \"welcome_email\",\n \"name\": \"Welcome Email\",\n \"channel\": \"email\",\n \"category\": \"transactional\",\n \"template_macro_id\": \"<string>\",\n \"test_data\": {},\n \"settings\": {},\n \"translations\": {}\n}"
response = http.request(request)
puts response.read_body{
"template": {
"id": "welcome_email",
"name": "Welcome Email",
"channel": "email",
"category": "transactional",
"version": 1,
"email": {
"subject": "Welcome, {{user_name}}!",
"compiled_preview": "<string>",
"visual_editor_tree": {
"type": "mjml",
"children": []
},
"sender_id": "sender_123",
"reply_to": "support@example.com",
"subject_preview": "Get started with your account",
"text": "<string>"
},
"web": {
"content": {},
"html": "<string>",
"plain_text": "<string>"
},
"template_macro_id": "<string>",
"integration_id": "<string>",
"test_data": {
"user_name": "John Doe",
"action_url": "https://example.com/action"
},
"settings": {},
"translations": {
"fr": {
"email": {
"subject": "Bienvenue"
}
}
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
}Templates
Create a template
Creates a new template. Each template must have a channel (email or web) with corresponding channel-specific content.
POST
/
api
/
templates.create
Create a template
curl --request POST \
--url https://{notifuseDomain}/api/templates.create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"workspace_id": "ws_1234567890",
"id": "welcome_email",
"name": "Welcome Email",
"channel": "email",
"category": "transactional",
"template_macro_id": "<string>",
"test_data": {},
"settings": {},
"translations": {}
}
'import requests
url = "https://{notifuseDomain}/api/templates.create"
payload = {
"workspace_id": "ws_1234567890",
"id": "welcome_email",
"name": "Welcome Email",
"channel": "email",
"category": "transactional",
"template_macro_id": "<string>",
"test_data": {},
"settings": {},
"translations": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
workspace_id: 'ws_1234567890',
id: 'welcome_email',
name: 'Welcome Email',
channel: 'email',
category: 'transactional',
template_macro_id: '<string>',
test_data: {},
settings: {},
translations: {}
})
};
fetch('https://{notifuseDomain}/api/templates.create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{notifuseDomain}/api/templates.create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'workspace_id' => 'ws_1234567890',
'id' => 'welcome_email',
'name' => 'Welcome Email',
'channel' => 'email',
'category' => 'transactional',
'template_macro_id' => '<string>',
'test_data' => [
],
'settings' => [
],
'translations' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{notifuseDomain}/api/templates.create"
payload := strings.NewReader("{\n \"workspace_id\": \"ws_1234567890\",\n \"id\": \"welcome_email\",\n \"name\": \"Welcome Email\",\n \"channel\": \"email\",\n \"category\": \"transactional\",\n \"template_macro_id\": \"<string>\",\n \"test_data\": {},\n \"settings\": {},\n \"translations\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{notifuseDomain}/api/templates.create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"workspace_id\": \"ws_1234567890\",\n \"id\": \"welcome_email\",\n \"name\": \"Welcome Email\",\n \"channel\": \"email\",\n \"category\": \"transactional\",\n \"template_macro_id\": \"<string>\",\n \"test_data\": {},\n \"settings\": {},\n \"translations\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{notifuseDomain}/api/templates.create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"workspace_id\": \"ws_1234567890\",\n \"id\": \"welcome_email\",\n \"name\": \"Welcome Email\",\n \"channel\": \"email\",\n \"category\": \"transactional\",\n \"template_macro_id\": \"<string>\",\n \"test_data\": {},\n \"settings\": {},\n \"translations\": {}\n}"
response = http.request(request)
puts response.read_body{
"template": {
"id": "welcome_email",
"name": "Welcome Email",
"channel": "email",
"category": "transactional",
"version": 1,
"email": {
"subject": "Welcome, {{user_name}}!",
"compiled_preview": "<string>",
"visual_editor_tree": {
"type": "mjml",
"children": []
},
"sender_id": "sender_123",
"reply_to": "support@example.com",
"subject_preview": "Get started with your account",
"text": "<string>"
},
"web": {
"content": {},
"html": "<string>",
"plain_text": "<string>"
},
"template_macro_id": "<string>",
"integration_id": "<string>",
"test_data": {
"user_name": "John Doe",
"action_url": "https://example.com/action"
},
"settings": {},
"translations": {
"fr": {
"email": {
"subject": "Bienvenue"
}
}
},
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z"
}
}Authorizations
API token for authentication
Body
application/json
The ID of the workspace
Example:
"ws_1234567890"
Unique identifier for the template (alphanumeric, underscores, and hyphens only)
Maximum string length:
32Pattern:
^[a-zA-Z0-9_-]+$Example:
"welcome_email"
Name of the template
Maximum string length:
32Example:
"Welcome Email"
Communication channel
Available options:
email, web Example:
"email"
Template category
Available options:
marketing, transactional, welcome, opt_in, unsubscribe, bounce, blocklist, blog, other Example:
"transactional"
Show child attributes
Show child attributes
Show child attributes
Show child attributes
ID of the template macro (layout) to use
Test data for template preview
Channel-specific settings
Per-language content variants, keyed by language code. Every key must be one of the workspace's configured languages.
Show child attributes
Show child attributes
Response
Template created successfully
Show child attributes
Show child attributes
