Multi part messages

The Enterprise Communications API can send multi part messages to any channel allowing you to easily add images, files and any other MIME type attachment to your messages.

How to create a multi part message

You will not need to specify a body property in your call to the API as you will be specifying the message content using the messageParts property. The messageParts property should contain an array of the parts you want to use to create your message.

🚧

Choose your message content source

The "One" API will use either a body property or messageParts property to create your message content but not both! Any custom bodies that have been defined will override the message parts for that channel.

Part 1 is the text for the message

The first part in your array will be used for the text in your message and so is usually the MIME type text/plain, but could be text/html but this will only work with channels that support HTML.

Additional parts

You can add any number of additional parts to your call of any valid MIME type; common uses will be adding images and files. The data for the parts can be defined either inline in the data property or in a URL in the url property. If you have large files we recommend using the URL approach and if necessary uploading the files to our content hosting service to obtain a URL for accessing the file.

Attachments using URLs

When attaching a file using a URL in the message part please ensure the following properties are populated and no others, as we will calculate the name and size from the file at the URL:

  • type
  • url

Attachments using Base64

When attaching a file using a Base64 data string in the message part please ensure the following properties are populated and no others, as we will to understand what the file should look like:

  • name
  • type
  • data
  • size (Optional)

messageParts structure

The messageParts property is an array of messagePart as defined below:

messagePart

Property

Type

Description

name*

string

The name of your part, usually the file name

type*

string

The MIME type for the part e.g. image/png

channels

array of string

If specified this message part will only be applied to the list of channels in this array. This is a list of channel identifier strings e.g. sms, whatsApp etc...

url

string

The URL to the file data.

If this isn't specified then the data property must be

data

string

The base64 encoded data for the file.

If this isn't specified then the url property must be

size

int

The size in bytes of the data for the message part; optional.

🚧

Choose URL or base64 data

You must choose to get your file data from either a URL or inline using base64 encoded data but not both!

Examples:

{
  "title": "Your order has been dispatched",
  "to": {
    "email": "[email protected]"
  },
  "rules": [
    "email"
  ],
  "messageParts": [
    {
      "name": "Body html",
      "type": "text/html",
      "data": "<h2>Item Repaired</h2><p>Your return number: <b>ABC1245</b> has been repaired and is being retuned to you</p>"
    },
    {
      "type": "image/png",
      "url": "http://cdn.dnky.co/3rdparty/comapi/images/laptop.png"
    }
  ],
  "metadata": {
    "data": "My correlation data"
  }
}
{
  "title": "Your order has been dispatched",
  "to": {
    "email": "[email protected]"
  },
  "rules": [
    "email"
  ],
  "messageParts": [
    {
      "name": "Body html",
      "type": "text/html",
      "data": "<h2>Item Repaired</h2><p>Your return number: <b>ABC1245</b> has been repaired and is being retuned to you</p>"
    },
    {
      "name": "image.png",
      "type": "image/png",
      "data": "iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAMAAADW3miqAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAkxQTFRFAAAAK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwK5jwKZfwKpfwLJjwbLf1ptT5qNX5cbr1Lpnwa7f17fb+////8/n+e7/2KpjwNZ3xxuP71uv8PaHxRqXy5vP98Pj+VKzzKJfw2Oz85fP9SKbyk8v3/f7/LprwUarzntD4ZLT0OJ7xksr30un81Or8mM34PqHxQ6Tyy+b75fL9OZ/xO6DxgsL2qdX5i8f3QKLyvN763e79TqnyL5rwp9T5/v7//v//xOL7QaPyvd/6j8n3YrP08vn+lMv3NJ3xs9r6kcr3KJbwicb3u976MZvwnM/4+/3/5PL9Vazzer72r9j5LJnwotL4+fz/3+/9ZrX0QqPy0en86/X+mc348vj+cLn1LZnwZ7X0odL4N57xX7H05/T9z+f8brj1fcD29fr+hsT2d7318fj+/P7/Np3xR6by7/f+bbj1/P3/pNP5Mpvwt9z6abb06PT97Pb+T6nztdv6XrH04/H97vf+1ev8rdf5NJzxcrv1pdP5T6rzut76bLj1isb3PKDxzOb7weH70Oj8UKrzrtj51er83O79V67zTany6vX+Y7P0MJrw6fT9arf1c7v1S6fyZb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MGVLszQAAABGdEVYdHNvZnR3YXJlAEltYWdlTWFnaWNrIDYuNy44LTkgMjAxNC0wNS0xMiBRMTYgaHR0cDovL3d3dy5pbWFnZW1hZ2ljay5vcmfchu0AAAAAGHRFWHRUaHVtYjo6RG9jdW1lbnQ6OlBhZ2VzADGn/7svAAAAGHRFWHRUaHVtYjo6SW1hZ2U6OmhlaWdodAAxOTIPAHKFAAAAF3RFWHRUaHVtYjo6SW1hZ2U6OldpZHRoADE5MtOsIQgAAAAZdEVYdFRodW1iOjpNaW1ldHlwZQBpbWFnZS9wbmc/slZOAAAAF3RFWHRUaHVtYjo6TVRpbWUAMTQ5MTgyNTQ0NFCEz4QAAAAPdEVYdFRodW1iOjpTaXplADBCQpSiPuwAAABWdEVYdFRodW1iOjpVUkkAZmlsZTovLy9tbnRsb2cvZmF2aWNvbnMvMjAxNy0wNC0xMC8zOGIzNWFjOWViZjFhZTU2YzVkZmE2MmU0ZmNmMmE4Zi5pY28ucG5n/L7enQAAAABJRU5ErkJggg=="
    }
  ],
  "metadata": {
    "data": "My correlation data"
  }
}
{
  "title": "Your order has been dispatched",
  "to": {
    "phoneNumber": "447123123123"
  },
  "rules": [
    "sms"
  ],
  "messageParts": [
    {
      "name": "Body text",
      "type": "text/plain",
      "data": "Your order: ABC1245 has been dispatched."
    },
    {
      "type": "image/png",
      "url": "http://cdn.dnky.co/3rdparty/comapi/images/laptop.png"
    }
  ],
  "metadata": {
    "data": "My correlation data"
  }
}
{
  "title": "Your order has been dispatched",
  "to": {
    "phoneNumber": "447123123123"
  },
  "rules": [
    "whatsApp",
    "sms"
  ],
  "messageParts": [
    {
      "channels": [
        "whatsApp"
      ],
      "type": "whatsapp/hsm",
      "data": {
        "namespace": "ce0464f9_3d87_fb42_b0d7_d7651ab3337a",
        "templateName": "dispatch_confirmation",
        "languageCode": "en",
        "parameters": [
          {
            "default": "{{profile.forename}}"
          },
          {
            "default": "1234"
          }
        ]
      }
    },
    {
      "channels": [
        "sms"
      ],
      "name": "Body text",
      "type": "text/plain",
      "data": "Your order: ABC1245 has been dispatched."
    },
    {
      "channels": [
        "sms"
      ],
      "type": "image/png",
      "url": "http://cdn.dnky.co/3rdparty/comapi/images/laptop.png"
    }
  ],
  "metadata": {
    "data": "My correlation data"
  }
}