Web Messaging SDK: File upload MIME/size limits?

Hey folks,

Running into a 400 Bad Request when a customer tries to upload a PDF via the Web Messaging SDK. The file is small, just 200KB. Is there a hardcoded list of accepted MIME types in the guest API, or does it rely on the widget config? I can’t find the error details in the console, just a generic failure. Does the SDK validate size before sending, or does the backend reject it after?

You’re hitting the backend validation, not the SDK client-side check. The Web Messaging widget doesn’t strictly block uploads before sending; it trusts the browser’s MIME type until the API says otherwise. The guest API for messaging is pretty strict about allowed types for security reasons. PDFs are often blocked by default unless explicitly permitted in the channel configuration.

You need to check your messaging channel settings in Genesys Cloud. Go to Admin > Channels > Messaging > [Your Channel] > Features. Look for “File Sharing” or “Allowed File Types.” If it’s set to a restrictive list like images only, your PDF is getting rejected with that generic 400.

To fix this programmatically, you can update the channel config using the CXone Admin API. Here’s how you’d patch the allowed file types:

curl -X PATCH "https://api.mypurecloud.com/api/v2/messaging/channels/{channelId}" \
 -H "Authorization: Bearer $ACCESS_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{
 "features": {
 "fileSharing": {
 "enabled": true,
 "allowedTypes": ["image/png", "image/jpeg", "application/pdf"]
 }
 }
 }'

If you’re managing this with Terraform, you’d update the genesyscloud_messaging_channel resource. Make sure the features block includes the PDF MIME type. State drift can sneak in here if someone manually toggles it in the UI, so keep an eye on your terraform plan output.

Also, check the file size limit. The default is usually around 5MB, so 200KB shouldn’t be the issue. If you’ve increased the limit, ensure the maxFileSize property is set correctly in the same payload. The error is almost certainly the MIME type whitelist. Double-check the channel config first.

is spot on here. The backend is definitely doing the heavy lifting on validation, but the real pain point for most admins is figuring out exactly what is allowed because the UI doesn’t always make it obvious. It’s not just about PDFs being blocked; it’s about the specific MIME type mapping in the channel configuration.

You need to dig into the Web Messaging channel settings. Go to Admin > Channels > Messaging. Select your specific web messaging channel. In the configuration panel, look for the “Allowed file types” or “Upload settings” section. This is where you define the whitelist. If you don’t see it there, check the associated routing queue settings, as some legacy configs push this down to the queue level.

Here is a quick cURL command to check your channel configuration via the API if the UI is confusing you. This will show you the allowed_file_types array directly. You’ll need a valid access token with the messaging:channel:read scope.

curl -X GET "https://api.mypurecloud.com/api/v2/messaging/channels/{channelId}/config" \
 -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
 -H "Content-Type: application/json"

Look for the allowedFileTypes property in the JSON response. If application/pdf isn’t in that list, add it. The API expects the standard MIME type string. Also, keep an eye on the maxFileSize property. The default is usually 5MB, but if you’ve customized it, it might be lower than you think.

One thing to watch out for is the browser’s reported MIME type. Sometimes older PDFs or corrupted files send a generic application/octet-stream which might be blocked even if application/pdf is allowed. You might want to test with a fresh, clean PDF file first to rule out client-side header issues. If the upload still fails after updating the channel config, check the Web Console logs for the specific error code. It usually gives a more detailed reason than the generic 400.

Also, remember that changes to channel config don’t always propagate instantly to active sessions. You might need to refresh the widget or start a new conversation to pick up the new rules. It’s a bit annoying, but necessary.