Sending attachments via API

It's possible to use our API for sending personalized attachments to recipients. 

You could use this functionality within the following REST API calls:

POST

/api/index.php/rest/{campaignId}/contact/sendSingleMail

POST

/api/index.php/rest/{campaignId}/mailing/{id}/sendSingle

 

The API calls require the following parameters:

 "attachments": [
    {
      "filename": "string",
      "md5": "string",
      "data": "string"
    }
  ]

filename: This can be anything, for example invoice12345.pdf

md5: This should be an md5 hash of your file. It functions as a checksum on the data.

data: This should be your file, base64 encoded. 

 

Testing the API Call
To test this API call, you'll need to provide the MD5 hash and Base64-encoded content of your file. If you're already familiar with generating these, you can quickly use command line for generating the input:

md5sum yourfile.pdf
base64 yourfile.pdf

A simple example PHP script for generating the input:

<?php

$filename = '<File name of the attachment>';

$fileContents = file_get_contents($filename);
$fileData = base64_encode($fileContents);

$fileMd5 = md5($fileContents);
// or
$fileMd5 = md5_file($filename);

If you're not entirely familiar with hashing/encryption, it’s also possible to use online tools to create the input for md5 and data. While convenient, we recommend caution and not uploading sensitive data, as these tools may not ensure privacy or security.