Sending with attachments
While sending with a template or sending without a template, file attachments can be included as part of the API request. To do so, simply add an array of attachment objects within the 'attachments' property of the API call. Each attachment object includes:
Property | Description |
---|---|
name | The filename shown to the receiver. eg. invoice-352.pdf |
contentBlob | Base64-encoded string of file attachment content. |
contentType | MIME Type for the file attachment. eg. application/pdf |
Note that the 'contentBlob' (file attachment content) is a Base64-encoded string. Most programming langauges (Ruby, .NET, Java, PHP) will have built-in tools for this.
Code examples
Node.js example:
const axios = require('axios'); const fs = require('fs'); // Read and encode the file to base64 const filePath = './order-receipt.pdf'; const fileContent = fs.readFileSync(filePath); const base64Content = fileContent.toString('base64'); // Send the email with attachment axios({ method: "post", url: "https://live.waypointapi.com/v1/email_messages", headers: { "Content-Type": "application/json" }, auth: { username: API_KEY_USERNAME, password: API_KEY_PASSWORD }, data: { "templateId": "wptemplate_ABc123XYZ", "to": "jordan@usewaypoint.com", "variables": { "user": { "displayName": "Jordan", }, "product": { "title": "Beechers Mac & Cheese", "id": "02934203942" } }, attachments: [ { name: `order-receipt.pdf`, contentBlob: base64Content, contentType: 'application/pdf', }, ], } }) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); })
Activity Logs
Within your Activity, if you view a message log that was sent with one or many attachments, they will show up underneath the message preview.
Logs only show the filename, the full content of the attachment is not stored on Waypoint.
Limitations
- Messages have size limitations. On our Free and Starter plan, the max total size of the email (including attachments) is 2mb. On our Growth and Pro plans, the max total size is 5mb.
- Attachments are currently not supported by email batch sending
- Attachments with following file extensions are not supported and will cause the email to not be sent: .ade, .adp, .app, .asp, .bas, .bat, .cer, .chm, .cmd, .com, .cpl, .crt, .csh, .der, .exe, .fxp, .gadget, .hlp, .hta, .inf, .ins, .isp, .its, .js, .jse, .ksh, .lib, .lnk, .mad, .maf, .mag, .mam, .maq, .mar, .mas, .mat, .mau, .mav, .maw, .mda, .mdb, .mde, .mdt, .mdw, .mdz, .msc, .msh, .msh1, .msh2, .mshxml, .msh1xml, .msh2xml, .msi, .msp, .mst, .ops, .pcd, .pif, .plg, .prf, .prg, .reg, .scf, .scr, .sct, .shb, .shs, .sys, .ps1, .ps1xml, .ps2, .ps2xml, .psc1, .psc2, .tmp, .url, .vb, .vbe, .vbs, .vps, .vsmacros, .vss, .vst, .vsw, .vxd, .ws, .wsc, .wsf, .wsh, .xnk.