File Validation

Sunshine Conversations allows you to upload files in order to send them to the end user. It also allows end users to send files to you through SDKs and various third party messaging channels. In order to help guarantee the safety of these files, there is a layer of file validation that is done before we allow such files to be sent.

Rejections

Files having an extension outside the following list will be rejected:

3g2, 3gp, 7z, aac, amr, avi, bmp, csv, doc, docx, eml, gif, heic, heif, ics, jfif, jpeg, jpg, key, log, m4a, m4v, mov, mp3, mp4, mp4a, mpeg, mpg, mpga, neon, numbers, odt, oga, ogg, ogv, opus, pages, pdf, png, pps, ppsx, ppt, pptx, qt, svg, tif, tiff, txt, vcf, wav, webm, webp, wmv, xls, xlsx, xml, yaml, yml, zip

If the extension is contained in the list, Sunshine Conversations will also detect the mime type by reading the first bytes of the file (magic number). Any files with a mime type not corresponding to an extension in the above list will also be rejected.

Timeout: When reading the first bytes, Sunshine Conversations will wait for 15 seconds for a response from the server hosting the file. After 15 seconds, the request will be aborted and the file will be rejected.

Rejection Behavior

A file type validation can result in a failure in four different scenarios. Depending on the source of a file, Sunshine Conversations will treat rejections differently.

An upload to the Attachments API

A failed validation when uploading a file through the Attachments API will result in a 415 - Unsupported media type error with code unsupported_media_type. The error description will be one of the following:

  • File rejected. File extension not allowed
  • File rejected. File type could not be retrieved
  • File rejected. File type not allowed

An upload from Web, iOS or Android SDKs

If a file fails validation when a user uploads through the Web, iOS or Android SDK, the file will be removed from the conversation and the user will see an error message explaining why. Example: Attachment sent by the user was redacted, file type “exe” not accepted.

A file message sent from a third party channel

When a user sends an invalid file from a 3rd party channel, Sunshine Conversations can’t reject the file while providing an error message. To work around this limitation, Sunshine Conversations will redact the file from the message and append one of the following error messages based on the validation result. This error message will be part of the normal conversation:message webhook

  • Attachment sent by the user was redacted, file extension “{extension}” not accepted.
  • Attachment sent by the user was redacted, file type could not be detected.
  • Attachment sent by the user was redacted, file type “{mimeType}” not accepted.

A file message sent via API

In the case where you send a message via the POST Message API by specifying a mediaUrl, a failed validation will result in a 400 - Bad request error with code invalid_file. The error description will be one of the following:

  • File rejected. File extension not allowed
  • File rejected. File type could not be retrieved
  • File rejected. File type not allowed

File Size Limit

Files sent to Web, iOS or Android SDKs are restricted to a file size limit of 25MB. The Sunshine Conversations Attachments API imposes a file size limit of 50MB. Exceeding this size will result in a 413 error. There is no limit when sending files that are hosted outside the Sunshine Conversations platform.