API Reference - Email Templates

Link: https://support.brilliantdirectories.com/support/solutions/articles/12000108093

← Back to API Reference | Getting Started

Email Templates

Email Templates store the reusable email designs and content used by the automated email system and campaigns. Each template defines the subject, body, and formatting options for a category of outgoing email.

Model name in URL: email_templates — DB table: email_templates

The Email Template Object

FieldTypeDescription
email_idintegerUnique template ID (primary key, read-only)
email_namestringInternal template name/slug (used to reference this template) required on create
email_typestringCategory or type of email (EG transactional, campaign)
email_subjectstringEmail subject line; supports merge tags like %%%website_name%%%
email_bodytextFull HTML body of the email; supports merge tags and widget embeds
date_createdstringDate the template was created (format: YYYYMMDDHHmmss)
triggersstringComma-separated event triggers that send this template automatically
websiteintegerWebsite ID this template belongs to; 0 for platform-wide templates
email_fromstringSender name or email override; leave blank to use site default
priorityintegerSend priority; 0 normal, higher values indicate higher priority
signatureintegerWhether to append the site email signature: 1 yes, 0 no
category_idintegerTemplate category grouping ID
notemplateintegerSend as plain content without the standard email wrapper: 1 yes, 0 no
content_typestringMIME content type override (EG text/plain); blank defaults to HTML
revision_timestamptimestampTimestamp of the last modification (auto-managed)
unsubscribe_linkintegerWhether to include an unsubscribe link in outgoing emails: 1 yes, 0 no

List Email Templates

GET /api/v2/email_templates/get

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/email_templates/get?limit=25" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "email_id": "1",
      "email_name": "account-activated",
      "email_type": "",
      "email_subject": "Your Account is Activated!",
      "email_body": "

Welcome! Your account has been activated.

", "date_created": "", "triggers": "", "website": "0", "email_from": "", "priority": "0", "signature": "1", "category_id": "1", "notemplate": "0", "content_type": "", "revision_timestamp": "2024-03-01 12:00:00", "unsubscribe_link": "1" } ], "total": "21", "current_page": 1, "total_pages": 1, "next_page": "" }

Retrieve an Email Template

GET /api/v2/email_templates/get/{email_id}

Example Request

Copy
curl -X GET "https://www.yourdomain.com/api/v2/email_templates/get/1" \
  -H "X-Api-Key: your-api-key-here"

Example Response

Copy
{
  "status": "success",
  "message": [
    {
      "email_id": "1",
      "email_name": "account-activated",
      "email_type": "",
      "email_subject": "Your Account is Activated!",
      "email_body": "

Welcome! Your account has been activated.

", "date_created": "", "triggers": "", "website": "0", "email_from": "", "priority": "0", "signature": "1", "category_id": "1", "notemplate": "0", "content_type": "", "revision_timestamp": "2024-03-01 12:00:00", "unsubscribe_link": "1" } ], "total": "21", "current_page": 1, "total_pages": 1 }

Create an Email Template

POST /api/v2/email_templates/create

Example Request

Copy
curl -X POST "https://www.yourdomain.com/api/v2/email_templates/create" \
  -H "X-Api-Key: your-api-key-here" \
  -d "email_name=welcome-new-member" \
  -d "email_subject=Welcome+to+our+community%21" \
  -d "email_body=%3Cp%3EThank+you+for+joining%21%3C%2Fp%3E" \
  -d "signature=1" \
  -d "unsubscribe_link=1"

Example Response

Copy
{
  "status": "success",
  "message": {
    "email_id": "22",
    "email_name": "welcome-new-member",
    "email_type": null,
    "email_subject": "Welcome to our community!",
    "email_body": "

Thank you for joining!

", "date_created": null, "triggers": null, "website": null, "email_from": null, "priority": null, "signature": "1", "category_id": null, "notemplate": null, "content_type": null, "revision_timestamp": null, "unsubscribe_link": "1" } }

Update an Email Template

PUT /api/v2/email_templates/update

Example Request

Copy
curl -X PUT "https://www.yourdomain.com/api/v2/email_templates/update" \
  -H "X-Api-Key: your-api-key-here" \
  -d "email_id=22" \
  -d "email_subject=Welcome+to+the+family%21" \
  -d "signature=0"

Example Response

Copy
{
  "status": "success",
  "message": {
    "email_id": "22",
    "email_name": "welcome-new-member",
    "email_subject": "Welcome to the family!",
    "signature": "0",
    "unsubscribe_link": "1",
    "revision_timestamp": "2024-04-01 10:30:00"
  }
}

Delete an Email Template

DELETE /api/v2/email_templates/delete

Example Request

Copy
curl -X DELETE "https://www.yourdomain.com/api/v2/email_templates/delete" \
  -H "X-Api-Key: your-api-key-here" \
  -d "email_id=22"

Example Response

Copy
{
  "status": "success",
  "message": "email_templates record was deleted"
}