Email Templates Mutations

CreateEmailTemplate

Create an email template

Parameters

input - EmailTemplateInput
Data of the email template
mutation CreateEmailTemplate($input: EmailTemplateInput!) {
  CreateEmailTemplate(input: $input) {
    id
    label
    document_type
    default
    active
    body
    to
    cc
    bcc
    object
    created_at
    updated_at
  }
}
{
  "input": {
    "label": "Invoice Payment Reminder",
    "document_type": "invoice",
    "default": false,
    "active": true,
    "body": "Dear {{customer_name}},\n\nThis is a reminder that payment for invoice {{invoice_number}} is overdue.\n\nAmount due: {{total_amount}}\nDue date: {{due_date}}\n\nPlease make payment as soon as possible.\n\nBest regards,\n{{company_name}}",
    "object": "Payment Reminder - Invoice {{invoice_number}}",
    "to": ["{{customer_email}}"],
    "cc": ["[email protected]"]
  }
}
{
  "data": {
    "CreateEmailTemplate": {
      "id": 100003,
      "label": "Invoice Payment Reminder",
      "document_type": "invoice",
      "default": false,
      "active": true,
      "body": "Dear {{customer_name}},\n\nThis is a reminder that payment for invoice {{invoice_number}} is overdue.\n\nAmount due: {{total_amount}}\nDue date: {{due_date}}\n\nPlease make payment as soon as possible.\n\nBest regards,\n{{company_name}}",
      "object": "Payment Reminder - Invoice {{invoice_number}}",
      "to": ["{{customer_email}}"],
      "cc": ["[email protected]"],
      "bcc": [],
      "created_at": "2025-01-15T10:30:00Z",
      "updated_at": "2025-01-15T10:30:00Z"
    }
  }
}

UpdateEmailTemplate

Update an email template

Parameters

id - ID
Id of the email template
input - EmailTemplateInput
Data of the email template
mutation UpdateEmailTemplate($id: ID!, $input: EmailTemplateInput!) {
  UpdateEmailTemplate(id: $id, input: $input) {
    id
    label
    document_type
    default
    active
    body
    object
    to
    cc
    bcc
    updated_at
  }
}
{
  "id": 100003,
  "input": {
    "label": "Urgent Payment Reminder",
    "body": "URGENT: Payment for invoice {{invoice_number}} is now {{days_overdue}} days overdue.\n\nAmount due: {{total_amount}}\nDue date: {{due_date}}\n\nPlease make payment immediately to avoid further action.\n\nBest regards,\n{{company_name}}",
    "object": "URGENT: Payment Reminder - Invoice {{invoice_number}}"
  }
}
{
  "data": {
    "UpdateEmailTemplate": {
      "id": 100003,
      "label": "Urgent Payment Reminder",
      "document_type": "invoice",
      "default": false,
      "active": true,
      "body": "URGENT: Payment for invoice {{invoice_number}} is now {{days_overdue}} days overdue.\n\nAmount due: {{total_amount}}\nDue date: {{due_date}}\n\nPlease make payment immediately to avoid further action.\n\nBest regards,\n{{company_name}}",
      "object": "URGENT: Payment Reminder - Invoice {{invoice_number}}",
      "to": ["{{customer_email}}"],
      "cc": ["[email protected]"],
      "bcc": [],
      "updated_at": "2025-01-15T11:00:00Z"
    }
  }
}

DisableEmailTemplate

Disable an email template

Parameters

id - ID
Id of the email template
mutation DisableEmailTemplate($id: ID!) {
  DisableEmailTemplate(id: $id) {
    id
    label
    active
    updated_at
  }
}
{
  "id": 100003
}
{
  "data": {
    "DisableEmailTemplate": {
      "id": 100003,
      "label": "Urgent Payment Reminder",
      "active": false,
      "updated_at": "2025-01-15T12:00:00Z"
    }
  }
}

EnableEmailTemplate

Enable an email template

Parameters

id - ID
Id of the email template
mutation EnableEmailTemplate($id: ID!) {
  EnableEmailTemplate(id: $id) {
    id
    label
    active
    updated_at
  }
}
{
  "id": 100003
}
{
  "data": {
    "EnableEmailTemplate": {
      "id": 100003,
      "label": "Urgent Payment Reminder",
      "active": true,
      "updated_at": "2025-01-15T13:00:00Z"
    }
  }
}

DeleteEmailTemplate

Delete an email template

Parameters

id - ID
Id of the email template
mutation DeleteEmailTemplate($id: ID!) {
  DeleteEmailTemplate(id: $id)
}
{
  "id": 100003
}
{
  "data": { "DeleteEmailTemplate": true }
}

GenerateEmailTemplate

Generate an email template for a specific document

Parameters

id - ID
Id of the email template
documentId - ID
Id of the document to generate email for
mutation GenerateEmailTemplate($id: ID!, $documentId: ID!) {
  GenerateEmailTemplate(id: $id, documentId: $documentId) {
    id
    label
    body
    object
    to
    cc
    bcc
  }
}
{
  "id": 100003,
  "documentId": 200045
}
{
  "data": {
    "GenerateEmailTemplate": {
      "id": 100003,
      "label": "Urgent Payment Reminder",
      "body": "URGENT: Payment for invoice INV-2025-001 is now 15 days overdue.\n\nAmount due: €1,250.00\nDue date: 2025-01-01\n\nPlease make payment immediately to avoid further action.\n\nBest regards,\nAcme Corp",
      "object": "URGENT: Payment Reminder - Invoice INV-2025-001",
      "to": ["[email protected]"],
      "cc": ["[email protected]"],
      "bcc": []
    }
  }
}

GetEmailTemplateVariables

Get available variables for a document type

Parameters

document_type - Type
Document type to get variables for
mutation GetEmailTemplateVariables($document_type: Type!) {
  GetEmailTemplateVariables(document_type: $document_type)
}
{
  "document_type": "invoice"
}
{
  "data": {
    "GetEmailTemplateVariables": [
      "{{customer_name}}",
      "{{customer_email}}",
      "{{invoice_number}}",
      "{{invoice_date}}",
      "{{due_date}}",
      "{{total_amount}}",
      "{{company_name}}",
      "{{company_email}}"
    ]
  }
}

UploadEmailTemplateFile

Upload a file for an email template

Parameters

file - TmpBucketFileInput
File to upload
type - EmailTemplateFileType
Type of file (emailTemplateFiles)
mutation UploadEmailTemplateFile($file: TmpBucketFileInput!, $type: EmailTemplateFileType!) {
  UploadEmailTemplateFile(file: $file, type: $type) {
    id
    filename
    url
  }
}
{
  "file": {
    "filename": "attachment.pdf",
    "content": "base64_encoded_content"
  },
  "type": "emailTemplateFiles"
}
{
  "data": {
    "UploadEmailTemplateFile": {
      "id": 5001,
      "filename": "attachment.pdf",
      "url": "https://cdn.example.com/files/attachment.pdf"
    }
  }
}

EmailTemplateInput data type

label - String
Label of the email template
document_type - Type
Type of document (invoice, estimate, order, etc.)
default - Boolean
Whether this is the default template for the document type
active - Boolean
Whether the email template is active
body - String
Email body content
object - String
Email subject line
to - [String]
Default TO recipients
cc - [String]
Default CC recipients
bcc - [String]
Default BCC recipients
files - [FileInput]
Attached files

Enums

Type (EmailTemplate)

ValueDescription
invoiceInvoice document.
estimateEstimate/quote document.
orderSales order document.
shipping_orderShipping order document.
credit_noteCredit note document.
purchasePurchase order document.
purchase_receiptPurchase receipt document.
product_returnProduct return document.
deliveryDelivery document.
refundRefund document.
stock_adjustmentStock adjustment document.
stock_entryStock entry document.
stock_removalStock removal document.
stock_transferStock transfer document.
subscriptionSubscription document.
b2b_storeB2B store document.

EmailTemplateFileType

ValueDescription
emailTemplateFilesFiles attached to the email template.