File Validation

Smooch 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

Smooch will reject any files having an extension outside the following list:

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

If the extension is contained in the list, Smooch 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.

Rejection Behavior

A file type validation can result in a failure in four different scenarios. Depending on the source of a file, Smooch 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 retracted, 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, Smooch can’t reject the file while providing an error message. To work around this limitation, Smooch will retract 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 message:appUser webhook

  • Attachment sent by the user was retracted, file extension “{extension}” not accepted.
  • Attachment sent by the user was retracted, file type could not be detected.
  • Attachment sent by the user was retracted, 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

The Smooch API imposes a file size limit of 25MB for any file being uploaded to Smooch. Exceeding this size will result in a 413 error. There is no limit when sending files that are hosted outside the Smooch platform