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 a new email 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"
}
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"
}
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();
};
Was this page helpful?