Skip to main content
POST
https://api-dev.weir.ai/
/
mail
/
create
/
template
curl -X POST 'https://api.weir.ai/mail/create/template' \
  -H 'Authorization: Bearer YOUR_ADMIN_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Welcome Email",
    "subject": "Welcome to Weir AI",
    "body": "<html>...</html>",
    "type": "system"
  }'
{
  "data": {
    "templateId": "tpl_123456789",
    "name": "Welcome Email",
    "type": "system",
    "createdAt": "2024-01-22T15:30:00Z"
  },
  "message": "Template created successfully",
  "status": "success"
}

Create Mail Template

Create a new email template for system notifications.
curl -X POST 'https://api.weir.ai/mail/create/template' \
  -H 'Authorization: Bearer YOUR_ADMIN_ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Welcome Email",
    "subject": "Welcome to Weir AI",
    "body": "<html>...</html>",
    "type": "system"
  }'
{
  "data": {
    "templateId": "tpl_123456789",
    "name": "Welcome Email",
    "type": "system",
    "createdAt": "2024-01-22T15:30:00Z"
  },
  "message": "Template created successfully",
  "status": "success"
}

Request Body

name
string
required
Template name.
subject
string
required
Email subject line.
body
string
required
HTML email body.
type
string
required
Template type (system, marketing, transactional).

Usage Examples

const createMailTemplate = async (templateData, accessToken) => {
  const response = await fetch('https://api.weir.ai/mail/create/template', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${accessToken}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(templateData)
  });
  if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
  return await response.json();
};