Skip to content

Creating Email Templates

Endpoint Overview

Create a new email template for your organization, with optional support for placeholder variable substitutions.

  • HTTP Method: POST
  • Endpoint URL: https://api.trywhiteowl.com/api/v1/email
  • Authentication: Bearer Token (API Key)
  • Required Permission: email:create (Ensure your API key has Create permission under Email)

Header Type Required Description
Authorization String Yes Bearer token format: Bearer YOUR_API_KEY
Content-Type String Yes application/json

Field Type Required Description
name String Yes The name or title of the email template.
body String Yes The content or HTML body of the email template.
variables Array (Strings) No List of variable names used as placeholders in the body (e.g., ["first_name"]).

Example Payload:

{
"name": "Course Welcome Email",
"body": "<h1>Welcome {{first_name}}!</h1><p>Thank you for enrolling in {{course_name}}.</p>",
"variables": [
"first_name",
"course_name"
]
}

cURL

Terminal window
curl -X POST "https://api.trywhiteowl.com/api/v1/email" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Course Welcome Email",
"body": "<h1>Welcome {{first_name}}!</h1><p>Thank you for enrolling in {{course_name}}.</p>",
"variables": ["first_name", "course_name"]
}'

JavaScript (Fetch)

const options = {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Course Welcome Email',
body: '<h1>Welcome {{first_name}}!</h1><p>Thank you for enrolling in {{course_name}}.</p>',
variables: ['first_name', 'course_name']
})
};
fetch('https://api.trywhiteowl.com/api/v1/email', options)
.then(response => response.json())
.then(data => console.log(data))
.catch(err => console.error(err));

Python (Requests)

import requests
url = "https://api.trywhiteowl.com/api/v1/email"
headers = {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"name": "Course Welcome Email",
"body": "<h1>Welcome {{first_name}}!</h1><p>Thank you for enrolling in {{course_name}}.</p>",
"variables": ["first_name", "course_name"]
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())

Success Response (200 OK)

{
"success": true,
"message": "Email template created successfully",
"data": [
{
"id": 101,
"name": "Course Welcome Email",
"body": "<h1>Welcome {{first_name}}!</h1><p>Thank you for enrolling in {{course_name}}.</p>",
"variables": [
"first_name",
"course_name"
],
"organization": "org_12345"
}
]
}

Error Responses

  • Missing Required Fields:
{
"success": false,
"message": "Name of the email template is required"
}
  • Missing Permissions (403 Forbidden):
{
"success": false,
"message": "Your API key does not have the 'email:create' permission"
}
  • Internal Server Error (500 Internal Server Error):
{
"success": false,
"message": "There was an error creating the email"
}