Skip to content

Transactional emails

The Transactional Email object represents a transactional email template in your Go-Mailer account. The API lets you send it to your recipients from your application.

  • POST /transactionals

Send an email

Sends the specified transactional email to the specified recipient. The recipient doesn't have to be a contact in your account.

POSThttps://api.go-mailer.com/v1/transactionals

Request body

Send transactional email request body
ParameterTypeRequiredDescription
template_codestringRequired

The transactional template's unique code.

recipient_emailstringRequired

The recipient's email address.

bccstringOptional

An email address to blind copy.

htmlstringOptional

A valid HTML document, if you want to use your own pre-built markup as the email content. It overrides the design you created in your Go-Mailer account.

dataobjectOptional

key => value pairs that replace the placeholders in your transactional email.

Each key is the placeholder's name. If your template uses @firstname, send { firstname: "Sample Name" }.

attachmentsobject[]Optional

A list of attachments to send with the email. Each attachment must be no larger than 1MB.

attachment.filenamestringOptional

The attachment's name, as the recipient will see it.

attachment.pathstringOptional

A link to the file, if the attachment is hosted on a remote server.

attachment.contentstringOptional

A base64 representation of the attachment. Best when the file isn't hosted remotely.

attachment.contentTypestringOptional

The attachment's MIME type. Supported values include application/pdf.

attachment.encodingstringOptional

The attachment's content encoding. This should be base64.

Sample request

POST /v1/transactionals
const response = await fetch("https://api.go-mailer.com/v1/transactionals", {
  method: "POST",
  headers: {
    Authorization: "Bearer <API_KEY>"
  },
  body: JSON.stringify({
    template_code: "BIRTHDAY_EMAIL",
    recipient_email: "johndoe@example.com",
    bcc: "admin@my-company.com",
    data: {
      firstname: "John",
      age: 47,
    },
    attachments: [{
      filename: "yourfile.pdf",
      path: "https://path/to/file",
    }]
  })
});