Message Attachments

Spark has native support for posting messages with file attachments. Using the Messages API you can send messages containing text, text with attachments, or just share a file with the room without any text. Message attachments are limited to 2GB each.

What you may not know is that Spark has special support for most PDFs, Microsoft Word, Microsoft PowerPoint, and most popular image formats. For these file types, Spark clients will render a preview in the room and a full view when clicked.

Here is the complete list of supported file types and extensions:

  • Microsoft Word (doc, docx)
  • Microsoft PowerPoint (ppt, pptx)
  • Adobe Portable Document Format (pdf)
  • JPEG (jpg, jpeg)
  • Windows Bitmap (bmp)
  • Graphics Interchange Format (gif)
  • Portable Network Graphics (png)

Send a Message with Attachments

To send attachments, simply post a message by including your access token in the Authorization header and attach your local file with files property. Optionally, you can also include your plain-text message as part of the attachment in text property.

curl --request POST \
  --header "Authorization: Bearer ACCESS_TOKEN" \
  --form "files=@/home/desktop/example.png;type=image/png" \
  --form "roomId=Y2lzY2....." \
  --form "text=example attached" \

Alternatively, if you have public URL that you wish to share, you can add the URL as a value in the files attribute in JSON instead of attaching your local file in multipart message. The files atrribute currently takes one URL as an input. The plain-text message can also be included in the text attribute.

curl --request POST \
  --header "Authorization: Bearer ACCESS_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{"roomId":"Y2lzY2.....","text":"Example file","files":[""]}' \

Retrieving Message Details

In order to retrieve the file details such as filename and content-type, you can simply use HEAD request with your access token in the Authorization header. This is particularly useful if you just want to verify the filename and type before downloading the content.

curl -I -H "Authorization: Bearer ACCESS_TOKEN"

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Disposition: attachment; filename="example.png"
Content-Length: 44752
Content-Type: image/png

Retrieving Message Attachments

Files attached to a message are returned in the files property of the message object. To retrieve one of these files you should issue a GET request on the file URL including your Access Token in the Authorization header.

curl -H "Authorization: Bearer ACCESS_TOKEN"